#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 */
typedef int /*<<< orphan*/ u_int64_t;

/* Variables and functions */
int perf(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int simple();
int /*<<< orphan*/ sscanf(char *, char *, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  bool error = false;
  if (argc != 2) {
    printf("Usage:\n");
    printf(" %s loops\n", argv[0]);
    return 1;
  }
  u_int64_t loops;
  sscanf(argv[1], "%lu", &loops);
  printf("test loops=%lu\n", loops);
  error |= simple();
  error |= perf(loops);
  if (!error) {
    printf("Success\n");
  }
  return error ? 1 : 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   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1196 <main+0x56>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1205 <main+0xc5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6e(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x18(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <simple@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <perf@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11f2 <main+0xb2>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11af <main+0x5f>
mov    0x8(%rbx),%rdi
lea    0xea5(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1070 <sscanf@plt>
mov    0x4(%rsp),%esi
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <simple@plt>
mov    %eax,%ebp
mov    0x4(%rsp),%edi
call   1050 <perf@plt>
mov    %eax,%ebx
or     %ebp,%ebx
jne    11a6 <main+0x56>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
test   %ebx,%ebx
setne  %al
jmp    11d1 <main+0x81>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rsi
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Usage:\0A\00"
@.str.1 = [11 x i8] c" %s loops\0A\00"
@.str.2 = [4 x i8] c"%lu\00"
@.str.3 = [16 x i8] c"test loops=%lu\0A\00"
@.str.4 = [9 x i8] c"Success\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %39
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%21 = load i32, i32* %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = call i32 (...) @simple()
%24 = load i32, i32* %6
%25 = or i32 %24, %23
store i32 %25, i32* %6
%26 = load i32, i32* %7
%27 = call i32 @perf(i32 %26)
%28 = load i32, i32* %6
%29 = or i32 %28, %27
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = icmp ne i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %16
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %32, %16
%35 = load i32, i32* %6
%36 = icmp ne i32 %35, 0
%37 = zext i1 %36 to i64
%38 = select i1 %36, i32 1, i32 0
store i32 %38, i32* %3
br label %39
39: ; preds = %34, %10
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c" %s loops\0A\00"
@.str.2 = [4 x i8] c"%lu\00"
@.str.3 = [16 x i8] c"test loops=%lu\0A\00"
@str = [8 x i8] c"Success\00"
@str.5 = [7 x i8] c"Usage:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp eq i32 %0, 2
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0))
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %26
9: ; preds = %2
%10 = bitcast i32* %3 to i8*
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = call i32 (...) @simple()
%17 = load i32, i32* %3
%18 = call i32 @perf(i32 %17)
%19 = or i32 %18, %16
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %9
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %23
23: ; preds = %21, %9
%24 = xor i1 %20, true
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %23, %5
%27 = phi i32 [ 1, %5 ], [ %25, %23 ]
ret i32 %27
}