#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 */
void *atoi(char *);
scalar_t__ cuda_test_loop_repeated(unsigned int, int, int, char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  unsigned int n = 3;
  int sec = 10;
  int id = 0;
  if (argc > 1)
    n = atoi(argv[1]);
  if (argc > 2)
    sec = atoi(argv[2]);
  if (argc > 3)
    id = atoi(argv[3]);
  if (cuda_test_loop_repeated(n, sec, id, ".") < 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   $0x3,-0x14(%rbp)
movl   $0xa,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1175 <main+0x45>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    118f <main+0x5f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    11a9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe47(%rip),%rcx
call   1050 <cuda_test_loop_repeated@plt>
cmp    $0x0,%rax
jge    11d9 <main+0xa9>
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
jmp    11e5 <main+0xb5>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r14d,%r14d
mov    $0x3,%r12d
mov    $0xa,%r15d
cmp    $0x2,%edi
jl     117f <main+0x4f>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %rax,%r12
cmp    $0x2,%ebp
je     117f <main+0x4f>
mov    0x10(%rbx),%rdi
call   1040 <atoi@plt>
mov    %rax,%r15
cmp    $0x4,%ebp
jb     117f <main+0x4f>
mov    0x18(%rbx),%rdi
call   1040 <atoi@plt>
mov    %rax,%r14
lea    0xe7a(%rip),%rcx
mov    %r12d,%edi
mov    %r15d,%esi
mov    %r14d,%edx
call   1050 <cuda_test_loop_repeated@plt>
test   %rax,%rax
lea    0xe70(%rip),%rax
lea    0xe5d(%rip),%rdi
cmovs  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\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
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %6
store i32 10, i32* %7
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i8* @atoi(i8* %14)
%16 = ptrtoint i8* %15 to i32
store i32 %16, i32* %6
br label %17
17: ; preds = %11, %2
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 2
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i8* @atoi(i8* %23)
%25 = ptrtoint i8* %24 to i32
store i32 %25, i32* %7
br label %26
26: ; preds = %20, %17
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, 3
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
%33 = call i8* @atoi(i8* %32)
%34 = ptrtoint i8* %33 to i32
store i32 %34, i32* %8
br label %35
35: ; preds = %29, %26
%36 = load i32, i32* %6
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = call i64 @cuda_test_loop_repeated(i32 %36, i32 %37, i32 %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %45
43: ; preds = %35
%44 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %43, %41
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c".\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 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %24
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i8* @atoi(i8* %6)
%8 = ptrtoint i8* %7 to i64
%9 = trunc i64 %8 to i32
%10 = icmp eq i32 %0, 2
br i1 %10, label %24, label %11
11: ; preds = %4
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i8* @atoi(i8* %13)
%15 = ptrtoint i8* %14 to i64
%16 = trunc i64 %15 to i32
%17 = icmp ugt i32 %0, 3
br i1 %17, label %18, label %24
18: ; preds = %11
%19 = getelementptr inbounds i8*, i8** %1, i64 3
%20 = load i8*, i8** %19
%21 = tail call i8* @atoi(i8* %20)
%22 = ptrtoint i8* %21 to i64
%23 = trunc i64 %22 to i32
br label %24
24: ; preds = %2, %4, %18, %11
%25 = phi i32 [ %16, %18 ], [ %16, %11 ], [ 10, %4 ], [ 10, %2 ]
%26 = phi i32 [ %9, %18 ], [ %9, %11 ], [ %9, %4 ], [ 3, %2 ]
%27 = phi i32 [ %23, %18 ], [ 0, %11 ], [ 0, %4 ], [ 0, %2 ]
%28 = tail call i64 @cuda_test_loop_repeated(i32 %26, i32 %25, i32 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%29 = icmp slt i64 %28, 0
%30 = select i1 %29, 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)
%31 = tail call i32 @puts(i8* dereferenceable(1) %30)
ret i32 0
}