#include <assert.h>
#include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>

#define GRAPH_SIZE 2000

#define EDGE_COST(graph, graph_size, a, b) graph[a * graph_size + b]
#define D(a, b) EDGE_COST(output, graph_size, a, b)

#define INF 0x1fffffff

void generate_random_graph(int *output, int graph_size) {
  int i, j;

  srand(0xdadadada);

  for (i = 0; i < graph_size; i++) {
    for (j = 0; j < graph_size; j++) {
      if (i == j) {
        D(i, j) = 0;
      } else {
        int r;
        r = rand() % 40;
        if (r > 20) {
          r = INF;
        }

        D(i, j) = r;
      }
    }
  }
}

void floyd_warshall_gpu(const int *graph, int graph_size, int *output) {
  // TODO
}

void floyd_warshall_cpu(const int *graph, int graph_size, int *output) {
  int i, j, k;

  memcpy(output, graph, sizeof(int) * graph_size * graph_size);

  for (k = 0; k < graph_size; k++) {
    for (i = 0; i < graph_size; i++) {
      for (j = 0; j < graph_size; j++) {
        if (D(i, k) + D(k, j) < D(i, j)) {
          D(i, j) = D(i, k) + D(k, j);
        }
      }
    }
  }
}

int main(int argc, char **argv) {
#define TIMER_START() gettimeofday(&tv1, NULL)
#define TIMER_STOP()                                                           \
  gettimeofday(&tv2, NULL);                                                    \
  timersub(&tv2, &tv1, &tv);                                                   \
  time_delta = (float)tv.tv_sec + tv.tv_usec / 1000000.0

  struct timeval tv1, tv2, tv;
  float time_delta;

  int *graph, *output_cpu, *output_gpu;
  int size;

  size = sizeof(int) * GRAPH_SIZE * GRAPH_SIZE;

  graph = (int *)malloc(size);
  assert(graph);

  output_cpu = (int *)malloc(size);
  assert(output_cpu);
  memset(output_cpu, 0, size);

  output_gpu = (int *)malloc(size);
  assert(output_gpu);

  generate_random_graph(graph, GRAPH_SIZE);

  fprintf(stderr, "running on cpu...\n");
  TIMER_START();
  floyd_warshall_cpu(graph, GRAPH_SIZE, output_cpu);
  TIMER_STOP();
  fprintf(stderr, "%f secs\n", time_delta);

  fprintf(stderr, "running on gpu...\n");
  TIMER_START();
  floyd_warshall_gpu(graph, GRAPH_SIZE, output_gpu);
  TIMER_STOP();
  fprintf(stderr, "%f secs\n", time_delta);

  if (memcmp(output_cpu, output_gpu, size) != 0) {
    fprintf(stderr, "FAIL!\n");
  }

  return 0;
}

	.file	"tmpxft_0026cee0_00000000-6_fw_gpu.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z21generate_random_graphPii
	.type	_Z21generate_random_graphPii, @function
_Z21generate_random_graphPii:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r15d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	movl	$-623191334, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%esi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	srand@PLT
	movslq	%ebx, %rax
	movq	%rax, 8(%rsp)
.L3:
	cmpl	%ebx, %r15d
	jge	.L13
	movslq	%r13d, %rax
	xorl	%ebp, %ebp
	leaq	(%r12,%rax,4), %r14
.L6:
	xorl	%edx, %edx
	cmpl	%ebp, %r15d
	je	.L4
	call	rand@PLT
	movl	$40, %ecx
	cltd
	idivl	%ecx
	movl	$536870911, %eax
	cmpl	$21, %edx
	cmovge	%eax, %edx
.L4:
	movl	%edx, (%r14,%rbp,4)
	incq	%rbp
	cmpq	%rbp, 8(%rsp)
	jne	.L6
	incl	%r15d
	addl	%ebx, %r13d
	jmp	.L3
.L13:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z21generate_random_graphPii, .-_Z21generate_random_graphPii
	.globl	_Z18floyd_warshall_gpuPKiiPi
	.type	_Z18floyd_warshall_gpuPKiiPi, @function
_Z18floyd_warshall_gpuPKiiPi:
.LFB2028:
	.cfi_startproc
	endbr64
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z18floyd_warshall_gpuPKiiPi, .-_Z18floyd_warshall_gpuPKiiPi
	.globl	_Z18floyd_warshall_cpuPKiiPi
	.type	_Z18floyd_warshall_cpuPKiiPi, @function
_Z18floyd_warshall_cpuPKiiPi:
.LFB2029:
	.cfi_startproc
	endbr64
	movq	%rdx, %r8
	movslq	%esi, %rdx
	movq	%rdi, %r9
	movl	%esi, %eax
	movq	%rdx, %rcx
	movq	%r8, %rdi
	movq	%r9, %rsi
	movq	%r8, %r11
	imulq	%rdx, %rcx
	salq	$2, %rdx
	salq	$2, %rcx
	rep movsb
	cmpl	%ecx, %eax
	jg	.L25
	ret
.L25:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
.L21:
	movq	%r8, %r9
	xorl	%ebx, %ebx
.L20:
	movq	%r9, %rdi
	xorl	%esi, %esi
.L18:
	movl	(%r11,%rsi,4), %r10d
	addl	(%r9,%rcx,4), %r10d
	cmpl	(%rdi), %r10d
	jge	.L17
	movl	%r10d, (%rdi)
.L17:
	incq	%rsi
	addq	$4, %rdi
	cmpl	%esi, %eax
	jg	.L18
	incl	%ebx
	addq	%rdx, %r9
	cmpl	%ebx, %eax
	jne	.L20
	incq	%rcx
	addq	%rdx, %r11
	cmpl	%ecx, %eax
	jg	.L21
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z18floyd_warshall_cpuPKiiPi, .-_Z18floyd_warshall_cpuPKiiPi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"running on cpu...\n"
.LC2:
	.string	"%f secs\n"
.LC3:
	.string	"running on gpu...\n"
.LC4:
	.string	"FAIL!\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$16000000, %edi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$48, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %r14
	leaq	24(%rsp), %r13
	call	malloc@PLT
	movl	$16000000, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movl	$4000000, %ecx
	movq	%rax, %rbx
	xorl	%eax, %eax
	movq	%rbx, %rdi
	rep stosl
	movl	$16000000, %edi
	call	malloc@PLT
	movl	$2000, %esi
	movq	%r12, %rdi
	movq	%rax, %rbp
	call	_Z21generate_random_graphPii
	movq	stderr(%rip), %rdi
	leaq	.LC0(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	xorl	%esi, %esi
	movq	%r14, %rdi
	call	gettimeofday@PLT
	movq	%rbx, %rdx
	movl	$2000, %esi
	movq	%r12, %rdi
	call	_Z18floyd_warshall_cpuPKiiPi
	xorl	%esi, %esi
	movq	%r13, %rdi
	call	gettimeofday@PLT
	movq	24(%rsp), %rdx
	movq	32(%rsp), %rax
	subq	8(%rsp), %rdx
	subq	16(%rsp), %rax
	jns	.L27
	decq	%rdx
	addq	$1000000, %rax
.L27:
	cvtsi2ssq	%rdx, %xmm1
	movq	stderr(%rip), %rdi
	leaq	.LC2(%rip), %r12
	movl	$2, %esi
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC1(%rip), %xmm0
	movq	%r12, %rdx
	movb	$1, %al
	cvtss2sd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__fprintf_chk@PLT
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC3(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	xorl	%esi, %esi
	movq	%r14, %rdi
	call	gettimeofday@PLT
	xorl	%esi, %esi
	movq	%r13, %rdi
	call	gettimeofday@PLT
	movq	24(%rsp), %rdx
	movq	32(%rsp), %rax
	subq	8(%rsp), %rdx
	subq	16(%rsp), %rax
	jns	.L28
	decq	%rdx
	addq	$1000000, %rax
.L28:
	cvtsi2ssq	%rdx, %xmm1
	movq	stderr(%rip), %rdi
	movq	%r12, %rdx
	movl	$2, %esi
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC1(%rip), %xmm0
	movb	$1, %al
	cvtss2sd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__fprintf_chk@PLT
	movq	%rbp, %rsi
	movl	$16000000, %edx
	movq	%rbx, %rdi
	call	memcmp@PLT
	testl	%eax, %eax
	je	.L29
	movq	stderr(%rip), %rdi
	leaq	.LC4(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L29:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	addq	$48, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2056:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2056:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1093567616
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <assert.h>
#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>

#define GRAPH_SIZE 2000

#define EDGE_COST(graph, graph_size, a, b) graph[a * graph_size + b]
#define D(a, b) EDGE_COST(output, graph_size, a, b)

#define INF 0x1fffffff

void generate_random_graph(int *output, int graph_size) {
  int i, j;

  srand(0xdadadada);

  for (i = 0; i < graph_size; i++) {
    for (j = 0; j < graph_size; j++) {
      if (i == j) {
        D(i, j) = 0;
      } else {
        int r;
        r = rand() % 40;
        if (r > 20) {
          r = INF;
        }

        D(i, j) = r;
      }
    }
  }
}

void floyd_warshall_gpu(const int *graph, int graph_size, int *output) {
  // TODO
}

void floyd_warshall_cpu(const int *graph, int graph_size, int *output) {
  int i, j, k;

  memcpy(output, graph, sizeof(int) * graph_size * graph_size);

  for (k = 0; k < graph_size; k++) {
    for (i = 0; i < graph_size; i++) {
      for (j = 0; j < graph_size; j++) {
        if (D(i, k) + D(k, j) < D(i, j)) {
          D(i, j) = D(i, k) + D(k, j);
        }
      }
    }
  }
}

int main(int argc, char **argv) {
#define TIMER_START() gettimeofday(&tv1, NULL)
#define TIMER_STOP()                                                           \
  gettimeofday(&tv2, NULL);                                                    \
  timersub(&tv2, &tv1, &tv);                                                   \
  time_delta = (float)tv.tv_sec + tv.tv_usec / 1000000.0

  struct timeval tv1, tv2, tv;
  float time_delta;

  int *graph, *output_cpu, *output_gpu;
  int size;

  size = sizeof(int) * GRAPH_SIZE * GRAPH_SIZE;

  graph = (int *)malloc(size);
  assert(graph);

  output_cpu = (int *)malloc(size);
  assert(output_cpu);
  memset(output_cpu, 0, size);

  output_gpu = (int *)malloc(size);
  assert(output_gpu);

  generate_random_graph(graph, GRAPH_SIZE);

  fprintf(stderr, "running on cpu...\n");
  TIMER_START();
  floyd_warshall_cpu(graph, GRAPH_SIZE, output_cpu);
  TIMER_STOP();
  fprintf(stderr, "%f secs\n", time_delta);

  fprintf(stderr, "running on gpu...\n");
  TIMER_START();
  floyd_warshall_gpu(graph, GRAPH_SIZE, output_gpu);
  TIMER_STOP();
  fprintf(stderr, "%f secs\n", time_delta);

  if (memcmp(output_cpu, output_gpu, size) != 0) {
    fprintf(stderr, "FAIL!\n");
  }

  return 0;
}

	.text
	.file	"fw_gpu.hip"
	.globl	_Z21generate_random_graphPii    # -- Begin function _Z21generate_random_graphPii
	.type	_Z21generate_random_graphPii,@function
_Z21generate_random_graphPii:           # @_Z21generate_random_graphPii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebp
	movq	%rdi, 8(%rsp)                   # 8-byte Spill
	movl	$-623191334, %edi               # imm = 0xDADADADA
	callq	srand
	testl	%ebp, %ebp
	jle	.LBB0_8
# %bb.1:                                # %.preheader.lr.ph
	movl	%ebp, %r15d
	xorl	%eax, %eax
	xorl	%r13d, %r13d
	movl	%ebp, 4(%rsp)                   # 4-byte Spill
.LBB0_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_3 Depth 2
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	%eax, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %r14
	movl	%r13d, %ebx
	imull	%ebp, %ebx
	leaq	(%rcx,%r13,4), %r12
	xorl	%ebp, %ebp
.LBB0_3:                                #   Parent Loop BB0_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpq	%rbp, %r13
	jne	.LBB0_5
# %bb.4:                                #   in Loop: Header=BB0_3 Depth=2
	movl	$0, (%r12,%rbx,4)
	jmp	.LBB0_6
.LBB0_5:                                #   in Loop: Header=BB0_3 Depth=2
	callq	rand
	cltq
	imulq	$1717986919, %rax, %rcx         # imm = 0x66666667
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$36, %rcx
	addl	%edx, %ecx
	shll	$3, %ecx
	leal	(%rcx,%rcx,4), %ecx
	subl	%ecx, %eax
	cmpl	$21, %eax
	movl	$536870911, %ecx                # imm = 0x1FFFFFFF
	cmovgel	%ecx, %eax
	movl	%eax, (%r14,%rbp,4)
.LBB0_6:                                #   in Loop: Header=BB0_3 Depth=2
	incq	%rbp
	cmpq	%rbp, %r15
	jne	.LBB0_3
# %bb.7:                                # %._crit_edge
                                        #   in Loop: Header=BB0_2 Depth=1
	incq	%r13
	movl	4(%rsp), %ebp                   # 4-byte Reload
	movq	16(%rsp), %rax                  # 8-byte Reload
	addl	%ebp, %eax
	cmpq	%r15, %r13
	jne	.LBB0_2
.LBB0_8:                                # %._crit_edge21
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z21generate_random_graphPii, .Lfunc_end0-_Z21generate_random_graphPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z18floyd_warshall_gpuPKiiPi    # -- Begin function _Z18floyd_warshall_gpuPKiiPi
	.type	_Z18floyd_warshall_gpuPKiiPi,@function
_Z18floyd_warshall_gpuPKiiPi:           # @_Z18floyd_warshall_gpuPKiiPi
	.cfi_startproc
# %bb.0:
	retq
.Lfunc_end1:
	.size	_Z18floyd_warshall_gpuPKiiPi, .Lfunc_end1-_Z18floyd_warshall_gpuPKiiPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z18floyd_warshall_cpuPKiiPi    # -- Begin function _Z18floyd_warshall_cpuPKiiPi
	.type	_Z18floyd_warshall_cpuPKiiPi,@function
_Z18floyd_warshall_cpuPKiiPi:           # @_Z18floyd_warshall_cpuPKiiPi
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %rbx
	movl	%esi, %ebp
	movq	%rdi, %rsi
	movslq	%ebp, %r14
	movq	%r14, %rdx
	imulq	%r14, %rdx
	shlq	$2, %rdx
	movq	%rbx, %rdi
	callq	memcpy@PLT
	testl	%r14d, %r14d
	jle	.LBB2_9
# %bb.1:                                # %.preheader40.lr.ph
	movl	%ebp, %eax
	xorl	%ecx, %ecx
	xorl	%edx, %edx
.LBB2_2:                                # %.preheader.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_3 Depth 2
                                        #       Child Loop BB2_4 Depth 3
	movl	%ecx, %esi
	leaq	(%rbx,%rsi,4), %rsi
	leaq	(%rbx,%rdx,4), %rdi
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
.LBB2_3:                                # %.preheader
                                        #   Parent Loop BB2_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_4 Depth 3
	movl	%r8d, %r10d
	leaq	(%rbx,%r10,4), %r10
	movq	%r9, %r11
	imulq	%r14, %r11
	xorl	%r15d, %r15d
.LBB2_4:                                #   Parent Loop BB2_2 Depth=1
                                        #     Parent Loop BB2_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%rsi,%r15,4), %r12d
	addl	(%rdi,%r11,4), %r12d
	cmpl	(%r10,%r15,4), %r12d
	jge	.LBB2_6
# %bb.5:                                #   in Loop: Header=BB2_4 Depth=3
	movl	%r12d, (%r10,%r15,4)
.LBB2_6:                                #   in Loop: Header=BB2_4 Depth=3
	incq	%r15
	cmpq	%r15, %rax
	jne	.LBB2_4
# %bb.7:                                # %._crit_edge
                                        #   in Loop: Header=BB2_3 Depth=2
	incq	%r9
	addl	%ebp, %r8d
	cmpq	%rax, %r9
	jne	.LBB2_3
# %bb.8:                                # %._crit_edge43
                                        #   in Loop: Header=BB2_2 Depth=1
	incq	%rdx
	addl	%ebp, %ecx
	cmpq	%rax, %rdx
	jne	.LBB2_2
.LBB2_9:                                # %._crit_edge45
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z18floyd_warshall_cpuPKiiPi, .Lfunc_end2-_Z18floyd_warshall_cpuPKiiPi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$16000000, %edi                 # imm = 0xF42400
	callq	malloc
	movq	%rax, %r12
	movl	$1, %edi
	movl	$16000000, %esi                 # imm = 0xF42400
	callq	calloc@PLT
	movq	%rax, %rbx
	movl	$16000000, %edi                 # imm = 0xF42400
	callq	malloc
	movq	%rax, %r14
	movq	%r12, %rdi
	movl	$2000, %esi                     # imm = 0x7D0
	callq	_Z21generate_random_graphPii
	movq	stderr(%rip), %rcx
	movl	$.L.str, %edi
	movl	$18, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	leaq	16(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	%r12, %rdi
	movl	$2000, %esi                     # imm = 0x7D0
	movq	%rbx, %rdx
	callq	_Z18floyd_warshall_cpuPKiiPi
	movq	%rsp, %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r12), %rax
	subq	(%r15), %rax
	movq	8(%r12), %rcx
	subq	8(%r15), %rcx
	movl	$1000000, %r13d                 # imm = 0xF4240
	leaq	(%rcx,%r13), %rdx
	movq	%rcx, %rsi
	sarq	$63, %rsi
	addq	%rax, %rsi
	testq	%rcx, %rcx
	cvtsi2ss	%rsi, %xmm0
	cmovnsq	%rcx, %rdx
	cvtsi2sd	%rdx, %xmm1
	cvtss2sd	%xmm0, %xmm0
	divsd	.LCPI3_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	xorps	%xmm0, %xmm0
	cvtsd2ss	%xmm1, %xmm0
	movq	stderr(%rip), %rdi
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.1, %esi
	movb	$1, %al
	callq	fprintf
	movq	stderr(%rip), %rcx
	movl	$.L.str.2, %edi
	movl	$18, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r12), %rax
	movq	8(%r12), %rcx
	subq	(%r15), %rax
	subq	8(%r15), %rcx
	addq	%rcx, %r13
	movq	%rcx, %rdx
	sarq	$63, %rdx
	addq	%rax, %rdx
	testq	%rcx, %rcx
	cmovnsq	%rcx, %r13
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rdx, %xmm0
	cvtss2sd	%xmm0, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sd	%r13, %xmm1
	divsd	.LCPI3_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	xorps	%xmm0, %xmm0
	cvtsd2ss	%xmm1, %xmm0
	movq	stderr(%rip), %rdi
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.1, %esi
	movb	$1, %al
	callq	fprintf
	movl	$16000000, %edx                 # imm = 0xF42400
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	bcmp@PLT
	testl	%eax, %eax
	jne	.LBB3_1
.LBB3_2:
	xorl	%eax, %eax
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB3_1:
	.cfi_def_cfa_offset 80
	movq	stderr(%rip), %rcx
	movl	$.L.str.3, %edi
	movl	$6, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	jmp	.LBB3_2
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"running on cpu...\n"
	.size	.L.str, 19

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"%f secs\n"
	.size	.L.str.1, 9

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"running on gpu...\n"
	.size	.L.str.2, 19

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"FAIL!\n"
	.size	.L.str.3, 7

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
