#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 */
scalar_t__ doesFileExist(char const *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
void sleepIfFileExist(int seconds_to_sleep, const char *file_name) {
  if (doesFileExist(file_name)) {
    printf(
        "The file %s exists.  Waiting %d seconds for someone to attach ...\n",
        file_name, seconds_to_sleep);
    sleep(seconds_to_sleep);
    printf("Done waiting!\n");
  }
}


x86 assembly (clang, -O0):
<sleepIfFileExist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <doesFileExist@plt>
cmp    $0x0,%rax
je     117d <sleepIfFileExist+0x4d>
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%edx
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
call   1050 <sleep@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sleepIfFileExist>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1030 <doesFileExist@plt>
test   %rax,%rax
je     1181 <sleepIfFileExist+0x41>
lea    0xea4(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
call   1060 <sleep@plt>
lea    0xecd(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [67 x i8] c"The file %s exists. Waiting %d seconds for someone to attach ...\0A\00"
@.str.1 = [15 x i8] c"Done waiting!\0A\00"
define void @sleepIfFileExist(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = call i64 @doesFileExist(i8* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %10)
%12 = load i32, i32* %3
%13 = call i32 @sleep(i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %8, %2
ret void
}

LLVM IR (-O2):
@.str = [67 x i8] c"The file %s exists. Waiting %d seconds for someone to attach ...\0A\00"
@str = [14 x i8] c"Done waiting!\00"
define void @sleepIfFileExist(i32 %0, i8* %1) {
%3 = tail call i64 @doesFileExist(i8* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %0)
%7 = tail call i32 @sleep(i32 %0)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %5, %2
ret void
}