#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char **argv) {
  FILE *fp = fopen(argv[1], "r");
  int num;
  fscanf(fp, "%d ", &num);
  if (num != 5) {
    int i;
    for (i = 0; i < 100; i++)
      usleep(1000);
  }
  fclose(fp);
  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
mov    0x8(%rax),%rdi
lea    0xe9b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe89(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <fscanf@plt>
cmpl   $0x5,-0x1c(%rbp)
je     11ba <main+0x7a>
movl   $0x0,-0x20(%rbp)
cmpl   $0x64,-0x20(%rbp)
jge    11b5 <main+0x75>
mov    $0x3e8,%edi
call   1060 <usleep@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1193 <main+0x53>
jmp    11ba <main+0x7a>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
lea    0xeb2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xea5(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
cmpl   $0x5,0x4(%rsp)
je     118f <main+0x4f>
mov    $0x64,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    $0x3e8,%edi
call   1060 <usleep@plt>
add    $0xffffffff,%ebp
jne    1180 <main+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%d \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
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %6
%13 = load i32*, i32** %6
%14 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%15 = load i32, i32* %7
%16 = icmp ne i32 %15, 5
br i1 %16, label %17, label %27
17: ; preds = %2
store i32 0, i32* %8
br label %18
18: ; preds = %23, %17
%19 = load i32, i32* %8
%20 = icmp slt i32 %19, 100
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = call i32 @usleep(i32 1000)
br label %23
23: ; preds = %21
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
br label %18
26: ; preds = %18
br label %27
27: ; preds = %26, %2
%28 = load i32*, i32** %6
%29 = call i32 @fclose(i32* %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = bitcast i32* %3 to i8*
%8 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 5
br i1 %10, label %16, label %11
11: ; preds = %2, %11
%12 = phi i32 [ %14, %11 ], [ 0, %2 ]
%13 = call i32 @usleep(i32 1000)
%14 = add nuw nsw i32 %12, 1
%15 = icmp eq i32 %14, 100
br i1 %15, label %16, label %11
16: ; preds = %11, %2
%17 = call i32 @fclose(i32* %6)
ret i32 0
}