#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*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ loop(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ *open_file(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *fp;
  int delay;
  if (!argv[1]) {
    fprintf(stderr, "%s [file] (delay in ms)\n", argv[0]);
    exit(2);
  }
  if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
    printf("%s [file] (delay in ms\n", argv[0]);
    exit(0);
  }
  if (argv[2]) {
    delay = atoi(argv[2]) * 1000;
  } else {
    delay = 1000000;
  }
  printf("[DEBUG]: received %s as path parameter\n", argv[1]);
  printf("[DEBUG]: delay is %s\n", argv[2]);
  srand(time(NULL));
  fp = open_file(argv[1]);
  loop(fp, delay);
  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)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    11db <main+0x4b>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe34(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2f(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1217 <main+0x87>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe14(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1231 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdfe(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     125b <main+0xcb>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
imul   $0x3e8,%eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    1262 <main+0xd2>
movl   $0xf4240,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdca(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdde(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <open_file@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <loop@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     1244 <main+0xb4>
lea    0xe6f(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     122e <main+0x9e>
mov    0x8(%rbx),%rdi
lea    0xe5d(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     122e <main+0x9e>
mov    0x10(%rbx),%rdi
test   %rdi,%rdi
je     11df <main+0x4f>
call   10a0 <atoi@plt>
imul   $0x3e8,%eax,%ebp
jmp    11e4 <main+0x54>
mov    $0xf4240,%ebp
mov    0x8(%rbx),%rsi
lea    0xe4c(%rip),%rdi
call   1050 <printf@plt>
mov    0x10(%rbx),%rsi
lea    0xe64(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    0x8(%rbx),%rdi
call   1040 <open_file@plt>
mov    %rax,%rdi
mov    %ebp,%esi
call   1030 <loop@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xdeb(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xda9(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"%s [file] (delay in ms)\0A\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [7 x i8] c"--help\00"
@.str.3 = [24 x i8] c"%s [file] (delay in ms\0A\00"
@.str.4 = [40 x i8] c"[DEBUG]: received %s as path parameter\0A\00"
@.str.5 = [22 x i8] c"[DEBUG]: delay is %s\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
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %19, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 2)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %19
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %25, %19
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %25
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %48
42: ; preds = %37
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call i32 @atoi(i8* %45)
%47 = mul nsw i32 %46, 1000
store i32 %47, i32* %7
br label %49
48: ; preds = %37
store i32 1000000, i32* %7
br label %49
49: ; preds = %48, %42
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %52)
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 2
%56 = load i8*, i8** %55
%57 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %56)
%58 = call i32 @time(i32* null)
%59 = call i32 @srand(i32 %58)
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 1
%62 = load i8*, i8** %61
%63 = call i32* @open_file(i8* %62)
store i32* %63, i32** %6
%64 = load i32*, i32** %6
%65 = load i32, i32* %7
%66 = call i32 @loop(i32* %64, i32 %65)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"%s [file] (delay in ms)\0A\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [7 x i8] c"--help\00"
@.str.3 = [24 x i8] c"%s [file] (delay in ms\0A\00"
@.str.4 = [40 x i8] c"[DEBUG]: received %s as path parameter\0A\00"
@.str.5 = [22 x i8] c"[DEBUG]: delay is %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 2)
unreachable
11: ; preds = %2
%12 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = load i8*, i8** %3
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14, %11
%19 = load i8*, i8** %1
%20 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = tail call i32 @exit(i32 0)
unreachable
22: ; preds = %14
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = icmp eq i8* %24, null
br i1 %25, label %29, label %26
26: ; preds = %22
%27 = tail call i32 @atoi(i8* %24)
%28 = mul nsw i32 %27, 1000
br label %29
29: ; preds = %22, %26
%30 = phi i32 [ %28, %26 ], [ 1000000, %22 ]
%31 = load i8*, i8** %3
%32 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %23
%34 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %33)
%35 = tail call i32 @time(i32* null)
%36 = tail call i32 @srand(i32 %35)
%37 = load i8*, i8** %3
%38 = tail call i32* @open_file(i8* %37)
%39 = tail call i32 @loop(i32* %38, i32 %30)
ret i32 0
}