#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ cuda_test_memcpy_async(unsigned int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *);
int main(int argc, char *argv[]) {
  unsigned int size = 0x10000000;
  if (argc > 1)
    sscanf(argv[1], "%x", &size);
  if (cuda_test_memcpy_async(size) < 0)
    printf("Test failed\n");
  else
    printf("Test passed\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x10000000,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    116f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9a(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x14(%rbp),%edi
call   1040 <cuda_test_memcpy_async@plt>
cmp    $0x0,%rax
jge    1192 <main+0x62>
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
jmp    119e <main+0x6e>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    %edi,%eax
movl   $0x10000000,0x4(%rsp)
10
mov    $0x10000000,%edi
cmp    $0x2,%eax
jl     115e <main+0x2e>
mov    0x8(%rsi),%rdi
lea    0xeb0(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1050 <sscanf@plt>
mov    0x4(%rsp),%edi
call   1040 <cuda_test_memcpy_async@plt>
test   %rax,%rax
lea    0xea2(%rip),%rax
lea    0xe8f(%rip),%rdi
cmovs  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%x\00"
@.str.1 = [13 x i8] c"Test failed\0A\00"
@.str.2 = [13 x i8] c"Test passed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 268435456, i32* %6
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
br label %14
14: ; preds = %9, %2
%15 = load i32, i32* %6
%16 = call i64 @cuda_test_memcpy_async(i32 %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %22
20: ; preds = %14
%21 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%x\00"
@str = [12 x i8] c"Test passed\00"
@str.3 = [12 x i8] c"Test failed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 268435456, i32* %3
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
br label %11
11: ; preds = %6, %2
%12 = phi i32 [ %10, %6 ], [ 268435456, %2 ]
%13 = call i64 @cuda_test_memcpy_async(i32 %12)
%14 = icmp slt i64 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0)
%16 = call i32 @puts(i8* dereferenceable(1) %15)
ret i32 0
}