#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
long atol(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  struct stat stat_buf;
  long runs;
  if (argc != 2 || (runs = atol(argv[1])) <= 0) {
    fprintf(stderr, "Usage: %s <number of runs>\n", argv[0]);
    exit(1);
  }
  while (--runs) {
    if (lstat("/", &stat_buf)) {
      fprintf(stderr, "OMGWTF - Failed lstat!?\n");
      exit(1);
    }
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jne    117b <main+0x3b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atol@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jg     11a3 <main+0x63>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11a8 <main+0x68>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11fe <main+0xbe>
lea    0xe57(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <lstat@plt>
cmp    $0x0,%rax
je     11f9 <main+0xb9>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe36(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11a8 <main+0x68>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
jne    11b3 <main+0x73>
mov    0x8(%r14),%rdi
call   1050 <atol@plt>
test   %rax,%rax
jle    11b3 <main+0x73>
mov    %rax,%rbx
lea    0xeb3(%rip),%r14
lea    0x8(%rsp),%r15
xchg   %ax,%ax
add    $0xffffffffffffffff,%rbx
je     11a7 <main+0x67>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <lstat@plt>
test   %rax,%rax
je     1170 <main+0x30>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe3a(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [28 x i8] c"Usage: %s <number of runs>\0A\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [25 x i8] c"OMGWTF - Failed lstat!?\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @atol(i8* %13)
store i64 %14, i64* %7
%15 = icmp sle i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %10, %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %10
br label %24
24: ; preds = %35, %23
%25 = load i64, i64* %7
%26 = add nsw i64 %25, -1
store i64 %26, i64* %7
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %36
28: ; preds = %24
%29 = call i64 @lstat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %struct.stat* %6)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %28
br label %24
36: ; preds = %24
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [28 x i8] c"Usage: %s <number of runs>\0A\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [25 x i8] c"OMGWTF - Failed lstat!?\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @atol(i8* %8)
%10 = icmp slt i64 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %6, %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %6, %20
%17 = phi i64 [ %18, %20 ], [ %9, %6 ]
%18 = add nsw i64 %17, -1
%19 = icmp eq i64 %18, 0
br i1 %19, label %27, label %20
20: ; preds = %16
%21 = call i64 @lstat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %struct.stat* %3)
%22 = icmp eq i64 %21, 0
br i1 %22, label %16, label %23
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %16
ret i32 0
}