#include "cuda.h"
#include "stdio.h"

int main(int argc, char *argv[]) {
  int version, log2N_min, log2N_max;
  float dur_max;
  if (argc == 5) {
    version = atoi(argv[1]);
    log2N_min = atoi(argv[2]);
    log2N_max = atoi(argv[3]);
    dur_max = atof(argv[4]) * 1000.f;
  } else {
    printf("Usage: ./p1 <version> <log2N_min> <log2N_max> <time>\n");
    printf("Version 0: Copy non-pinned memory from host to device\n");
    printf("Version 1: Copy pinned memory from host to device\n");
    printf(
        "Version 2: Copy non-pinned memory from host to device and back "
        "again\n");
    printf(
        "Version 3: Copy pinned memory from host to device and back again\n");
    printf("Time in ms\n");
    return 0;
  }
  int N_min = 1 << log2N_min;
  int N_max = 1 << log2N_max;
  float dur, dur_total;
  int num_runs;

  // Allocate host resources
  int *h;
  if (version == 0 || version == 2)
    h = (int *)malloc(N_max);
  else if (version == 1 || version == 3)
    cudaMallocHost(&h, N_max);

  // Allocate device resources
  int *d1, *d2;
  cudaMalloc(&d1, N_max);
  if (version == 2 || version == 3) cudaMalloc(&d2, N_max);

  printf("%8s %8s %12s %8s %12s\n", "Version", "log2N", "Bytes", "Runs",
         "Time");
  int log2N = log2N_min;
  int N = N_min;

  while (log2N <= log2N_max) {
    dur_total = 0.f;
    num_runs = 0;

    while (dur_total < dur_max) {
      num_runs++;

      // Setup timing
      cudaEvent_t start, end;
      cudaEventCreate(&start);
      cudaEventCreate(&end);

      if (version == 0 || version == 1) {
        // Copy to device
        cudaEventRecord(start, 0);
        cudaMemcpy(d1, h, N, cudaMemcpyHostToDevice);
        cudaEventRecord(end, 0);
        cudaEventSynchronize(end);
      } else if (version == 2 || version == 3) {
        // Copy to device and back again
        cudaEventRecord(start, 0);
        cudaMemcpy(d1, h, N, cudaMemcpyHostToDevice);
        cudaMemcpy(h, d2, N, cudaMemcpyDeviceToHost);
        cudaEventRecord(end, 0);
        cudaEventSynchronize(end);
      }

      // Calculate duration
      cudaEventElapsedTime(&dur, start, end);
      dur_total += dur;
    }

    dur = dur_total / num_runs;
    printf("%8d %8d %12d %8d %12.6f\n", version, log2N, N, num_runs, dur);

    log2N++;
    N *= 2;
  }

  printf("\n");

  // Free resources
  if (version == 0 || version == 2)
    free(h);
  else if (version == 1 || version == 3)
    cudaFree(h);
  cudaFree(d1);
  if (version == 2 || version == 3) cudaFree(d2);

  return 0;
}

	.file	"tmpxft_0035e96c_00000000-6_p1.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"Usage: ./p1 <version> <log2N_min> <log2N_max> <time>\n"
.LC3:
	.string	"Version 0: Copy non-pinned memory from host to device\n"
.LC4:
	.string	"Version 1: Copy pinned memory from host to device\n"
.LC5:
	.string	"Version 2: Copy non-pinned memory from host to device and back again\n"
.LC6:
	.string	"Version 3: Copy pinned memory from host to device and back again\n"
.LC7:
	.string	"Time in ms\n"
.LC8:
	.string	"Runs"
.LC9:
	.string	"Bytes"
.LC10:
	.string	"log2N"
.LC11:
	.string	"Version"
.LC12:
	.string	"%8s %8s %12s %8s %12s\n"
.LC13:
	.string	"Time"
.LC14:
	.string	"%8d %8d %12d %8d %12.6f\n"
.LC15:
	.string	"\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	cmpl	$5, %edi
	jne	.L3
	movq	8(%rsi), %rdi
	movq	%rsi, %r12
	call	atoi@PLT
	movq	16(%r12), %rdi
	movl	%eax, %ebp
	call	atoi@PLT
	movq	24(%r12), %rdi
	movl	%ebp, %r15d
	movl	%eax, %ebx
	call	atoi@PLT
	movq	32(%r12), %rdi
	movl	%eax, 24(%rsp)
	call	atof@PLT
	movl	$1, %eax
	movl	%ebx, %ecx
	mulsd	.LC1(%rip), %xmm0
	movl	%eax, %r12d
	sall	%cl, %r12d
	movb	24(%rsp), %cl
	sall	%cl, %eax
	movslq	%eax, %r13
	cvtsd2ss	%xmm0, %xmm3
	movss	%xmm3, 28(%rsp)
	andl	$-3, %r15d
	jne	.L18
	movq	%r13, %rdi
	call	malloc@PLT
	movq	%rax, 48(%rsp)
	jmp	.L7
.L3:
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L6
.L18:
	cmpl	$1, %r15d
	jne	.L7
	leaq	48(%rsp), %rdi
	xorl	%edx, %edx
	movq	%r13, %rsi
	call	cudaHostAlloc@PLT
.L7:
	leaq	56(%rsp), %rdi
	movq	%r13, %rsi
	leal	-2(%rbp), %r14d
	call	cudaMalloc@PLT
	cmpl	$1, %r14d
	ja	.L8
	leaq	64(%rsp), %rdi
	movq	%r13, %rsi
	call	cudaMalloc@PLT
.L8:
	pushq	%rax
	.cfi_def_cfa_offset 168
	leaq	.LC13(%rip), %rax
	leaq	.LC10(%rip), %rcx
	movl	$2, %edi
	pushq	%rax
	.cfi_def_cfa_offset 176
	leaq	.LC11(%rip), %rdx
	xorl	%eax, %eax
	leaq	.LC8(%rip), %r9
	leaq	.LC9(%rip), %r8
	leaq	.LC12(%rip), %rsi
	call	__printf_chk@PLT
	popq	%rdx
	.cfi_def_cfa_offset 168
	popq	%rcx
	.cfi_def_cfa_offset 160
.L9:
	movl	24(%rsp), %eax
	cmpl	%eax, %ebx
	jg	.L22
	movslq	%r12d, %rax
	movl	$0x00000000, 12(%rsp)
	xorl	%r13d, %r13d
	movq	%rax, 16(%rsp)
.L13:
	movss	28(%rsp), %xmm4
	comiss	12(%rsp), %xmm4
	jbe	.L23
	leaq	72(%rsp), %rdi
	incl	%r13d
	call	cudaEventCreate@PLT
	leaq	80(%rsp), %rdi
	call	cudaEventCreate@PLT
	cmpl	$1, %ebp
	movq	72(%rsp), %rdi
	ja	.L10
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	16(%rsp), %rdx
	movq	48(%rsp), %rsi
	movl	$1, %ecx
	movq	56(%rsp), %rdi
	jmp	.L20
.L10:
	cmpl	$1, %r14d
	ja	.L11
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	16(%rsp), %rdx
	movq	48(%rsp), %rsi
	movl	$1, %ecx
	movq	56(%rsp), %rdi
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rdx
	movq	64(%rsp), %rsi
	movl	$2, %ecx
	movq	48(%rsp), %rdi
.L20:
	call	cudaMemcpy@PLT
	movq	80(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	80(%rsp), %rdi
	call	cudaEventSynchronize@PLT
.L11:
	movq	80(%rsp), %rdx
	movq	72(%rsp), %rsi
	leaq	44(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movss	12(%rsp), %xmm2
	addss	44(%rsp), %xmm2
	movss	%xmm2, 12(%rsp)
	jmp	.L13
.L23:
	cvtsi2ssl	%r13d, %xmm1
	movss	12(%rsp), %xmm0
	movl	%r12d, %r8d
	movl	%ebx, %ecx
	movl	%r13d, %r9d
	movl	%ebp, %edx
	leaq	.LC14(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	incl	%ebx
	addl	%r12d, %r12d
	divss	%xmm1, %xmm0
	movss	%xmm0, 44(%rsp)
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	jmp	.L9
.L22:
	xorl	%eax, %eax
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	testl	%r15d, %r15d
	jne	.L14
	movq	48(%rsp), %rdi
	call	free@PLT
	jmp	.L15
.L14:
	decl	%r15d
	jne	.L15
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
.L15:
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	cmpl	$1, %r14d
	ja	.L6
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
.L6:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2053:
	.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
.LFE2053:
	.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	1083129856
	.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 "hip/hip_runtime.h"
#include "stdio.h"

int main(int argc, char *argv[]) {
  int version, log2N_min, log2N_max;
  float dur_max;
  if (argc == 5) {
    version = atoi(argv[1]);
    log2N_min = atoi(argv[2]);
    log2N_max = atoi(argv[3]);
    dur_max = atof(argv[4]) * 1000.f;
  } else {
    printf("Usage: ./p1 <version> <log2N_min> <log2N_max> <time>\n");
    printf("Version 0: Copy non-pinned memory from host to device\n");
    printf("Version 1: Copy pinned memory from host to device\n");
    printf(
        "Version 2: Copy non-pinned memory from host to device and back "
        "again\n");
    printf(
        "Version 3: Copy pinned memory from host to device and back again\n");
    printf("Time in ms\n");
    return 0;
  }
  int N_min = 1 << log2N_min;
  int N_max = 1 << log2N_max;
  float dur, dur_total;
  int num_runs;

  // Allocate host resources
  int *h;
  if (version == 0 || version == 2)
    h = (int *)malloc(N_max);
  else if (version == 1 || version == 3)
    hipHostMalloc(&h, N_max, hipHostMallocDefault);

  // Allocate device resources
  int *d1, *d2;
  hipMalloc(&d1, N_max);
  if (version == 2 || version == 3) hipMalloc(&d2, N_max);

  printf("%8s %8s %12s %8s %12s\n", "Version", "log2N", "Bytes", "Runs",
         "Time");
  int log2N = log2N_min;
  int N = N_min;

  while (log2N <= log2N_max) {
    dur_total = 0.f;
    num_runs = 0;

    while (dur_total < dur_max) {
      num_runs++;

      // Setup timing
      hipEvent_t start, end;
      hipEventCreate(&start);
      hipEventCreate(&end);

      if (version == 0 || version == 1) {
        // Copy to device
        hipEventRecord(start, 0);
        hipMemcpy(d1, h, N, hipMemcpyHostToDevice);
        hipEventRecord(end, 0);
        hipEventSynchronize(end);
      } else if (version == 2 || version == 3) {
        // Copy to device and back again
        hipEventRecord(start, 0);
        hipMemcpy(d1, h, N, hipMemcpyHostToDevice);
        hipMemcpy(h, d2, N, hipMemcpyDeviceToHost);
        hipEventRecord(end, 0);
        hipEventSynchronize(end);
      }

      // Calculate duration
      hipEventElapsedTime(&dur, start, end);
      dur_total += dur;
    }

    dur = dur_total / num_runs;
    printf("%8d %8d %12d %8d %12.6f\n", version, log2N, N, num_runs, dur);

    log2N++;
    N *= 2;
  }

  printf("\n");

  // Free resources
  if (version == 0 || version == 2)
    free(h);
  else if (version == 1 || version == 3)
    hipFree(h);
  hipFree(d1);
  if (version == 2 || version == 3) hipFree(d2);

  return 0;
}

	.text
	.file	"p1.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI0_0:
	.quad	0x408f400000000000              # double 1000
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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	$88, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$5, %edi
	jne	.LBB0_25
# %bb.1:
	movq	%rsi, %r14
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %ebx
	movq	16(%r14), %rdi
	callq	atoi
	movl	%eax, %r15d
	movq	24(%r14), %rdi
	callq	atoi
	movl	%eax, %ebp
	movq	32(%r14), %rdi
	callq	atof
	movl	$1, %eax
	movl	$1, %r12d
	movl	%r15d, %ecx
	shll	%cl, %r12d
	movl	%ebp, 16(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	shll	%cl, %eax
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	movl	%ebx, %ecx
	andl	$-3, %ecx
	movl	%ecx, 68(%rsp)                  # 4-byte Spill
	movslq	%eax, %r14
	je	.LBB0_2
# %bb.3:
	cmpl	$1, %ecx
	jne	.LBB0_5
# %bb.4:
	leaq	8(%rsp), %rdi
	movq	%r14, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
	jmp	.LBB0_5
.LBB0_25:
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	jmp	.LBB0_24
.LBB0_2:
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, 8(%rsp)
.LBB0_5:                                # %._crit_edge79
	leaq	56(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movl	%ebx, %eax
	andl	$-2, %eax
	movl	%eax, 20(%rsp)                  # 4-byte Spill
	cmpl	$2, %eax
	jne	.LBB0_7
# %bb.6:
	leaq	72(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
.LBB0_7:
	movl	$.L.str.6, %edi
	movl	$.L.str.7, %esi
	movl	$.L.str.8, %edx
	movl	$.L.str.9, %ecx
	movl	$.L.str.10, %r8d
	movl	$.L.str.11, %r9d
	xorl	%eax, %eax
	callq	printf
	cmpl	16(%rsp), %r15d                 # 4-byte Folded Reload
	jg	.LBB0_18
# %bb.8:                                # %.preheader.lr.ph
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	mulsd	.LCPI0_0(%rip), %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 24(%rsp)                 # 4-byte Spill
	leaq	40(%rsp), %r13
	leaq	28(%rsp), %rbp
.LBB0_9:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_11 Depth 2
	movq	%r15, 80(%rsp)                  # 8-byte Spill
	xorps	%xmm1, %xmm1
	movss	24(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	ucomiss	%xmm1, %xmm0
	movl	$0, %r14d
	jbe	.LBB0_17
# %bb.10:                               # %.lr.ph
                                        #   in Loop: Header=BB0_9 Depth=1
	movslq	%r12d, %r15
	xorl	%r14d, %r14d
.LBB0_11:                               #   Parent Loop BB0_9 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	%xmm1, 32(%rsp)                 # 4-byte Spill
	leaq	48(%rsp), %rdi
	callq	hipEventCreate
	movq	%r13, %rdi
	callq	hipEventCreate
	cmpl	$1, %ebx
	ja	.LBB0_13
# %bb.12:                               #   in Loop: Header=BB0_11 Depth=2
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	56(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	jmp	.LBB0_15
.LBB0_13:                               #   in Loop: Header=BB0_11 Depth=2
	cmpl	$2, 20(%rsp)                    # 4-byte Folded Reload
	jne	.LBB0_16
# %bb.14:                               #   in Loop: Header=BB0_11 Depth=2
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	56(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	8(%rsp), %rdi
	movq	72(%rsp), %rsi
	movq	%r15, %rdx
	movl	$2, %ecx
.LBB0_15:                               # %.sink.split
                                        #   in Loop: Header=BB0_11 Depth=2
	callq	hipMemcpy
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	40(%rsp), %rdi
	callq	hipEventSynchronize
.LBB0_16:                               #   in Loop: Header=BB0_11 Depth=2
	movq	48(%rsp), %rsi
	movq	40(%rsp), %rdx
	movq	%rbp, %rdi
	callq	hipEventElapsedTime
	movss	32(%rsp), %xmm1                 # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	addss	28(%rsp), %xmm1
	incl	%r14d
	movss	24(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	ucomiss	%xmm1, %xmm0
	ja	.LBB0_11
.LBB0_17:                               # %._crit_edge
                                        #   in Loop: Header=BB0_9 Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r14d, %xmm0
	divss	%xmm0, %xmm1
	movss	%xmm1, 28(%rsp)
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm0
	movl	$.L.str.12, %edi
	movl	%ebx, %esi
	movq	80(%rsp), %r15                  # 8-byte Reload
	movl	%r15d, %edx
	movl	%r12d, %ecx
	movl	%r14d, %r8d
	movb	$1, %al
	callq	printf
	leal	1(%r15), %eax
	addl	%r12d, %r12d
	cmpl	16(%rsp), %r15d                 # 4-byte Folded Reload
	movl	%eax, %r15d
	jne	.LBB0_9
.LBB0_18:                               # %._crit_edge77
	movl	$10, %edi
	callq	putchar@PLT
	movl	68(%rsp), %eax                  # 4-byte Reload
	testl	%eax, %eax
	je	.LBB0_19
# %bb.20:
	cmpl	$1, %eax
	jne	.LBB0_22
# %bb.21:
	movq	8(%rsp), %rdi
	callq	hipFree
	jmp	.LBB0_22
.LBB0_19:
	movq	8(%rsp), %rdi
	callq	free
.LBB0_22:
	movq	56(%rsp), %rdi
	callq	hipFree
	cmpl	$2, 20(%rsp)                    # 4-byte Folded Reload
	jne	.LBB0_24
# %bb.23:
	movq	72(%rsp), %rdi
	callq	hipFree
.LBB0_24:
	xorl	%eax, %eax
	addq	$88, %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	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str.6,@object                # @.str.6
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.6:
	.asciz	"%8s %8s %12s %8s %12s\n"
	.size	.L.str.6, 23

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Version"
	.size	.L.str.7, 8

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"log2N"
	.size	.L.str.8, 6

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Bytes"
	.size	.L.str.9, 6

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Runs"
	.size	.L.str.10, 5

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Time"
	.size	.L.str.11, 5

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"%8d %8d %12d %8d %12.6f\n"
	.size	.L.str.12, 25

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Usage: ./p1 <version> <log2N_min> <log2N_max> <time>"
	.size	.Lstr, 53

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Version 0: Copy non-pinned memory from host to device"
	.size	.Lstr.1, 54

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Version 1: Copy pinned memory from host to device"
	.size	.Lstr.2, 50

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Version 2: Copy non-pinned memory from host to device and back again"
	.size	.Lstr.3, 69

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"Version 3: Copy pinned memory from host to device and back again"
	.size	.Lstr.4, 65

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"Time in ms"
	.size	.Lstr.5, 11

	.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
