#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 */
int /*<<< orphan*/ R_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ getenv(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
void test_pause() {
  static char trickFile[1024] = "";
  static char pid[10] = "";
  if (trickFile[0] == '\0') {
    strcpy(trickFile, getenv("TRICK_FILE"));
  }
  while (access(trickFile, R_OK) == 0) {
    fprintf(stdout, "sleeping\n");
    fflush(stdout);
    sleep(1);
  }
}


x86 assembly (clang, -O0):
<test_pause>:
push   %rbp
mov    %rsp,%rbp
movsbl 0x2ef5(%rip),%eax
cmp    $0x0,%eax
jne    118e <test_pause+0x2e>
lea    0xe85(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%esi
lea    0x2ed7(%rip),%rdi
call   1040 <strcpy@plt>
jmp    1193 <test_pause+0x33>
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
lea    0x2ebd(%rip),%rdi
call   1070 <access@plt>
cmp    $0x0,%rax
jne    11e4 <test_pause+0x84>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
jmp    1193 <test_pause+0x33>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_pause>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmpb   $0x0,0x2ef1(%rip)
jne    118b <test_pause+0x2b>
lea    0xe88(%rip),%rdi
call   1030 <getenv@plt>
lea    0x2edc(%rip),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
mov    0x2e46(%rip),%r15
mov    (%r15),%esi
lea    0x2ec4(%rip),%rdi
call   1070 <access@plt>
test   %rax,%rax
jne    11eb <test_pause+0x8b>
mov    0x2e33(%rip),%rbx
lea    0xe57(%rip),%r14
lea    0x2ea5(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%edi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
call   1060 <fflush@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    (%r15),%esi
mov    %r12,%rdi
call   1070 <access@plt>
test   %rax,%rax
je     11c0 <test_pause+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@test_pause.trickFile = internal global [1024 x i8] zeroinitializer
@test_pause.pid = internal global [10 x i8] zeroinitializer
@.str = [11 x i8] c"TRICK_FILE\00"
@R_OK = global i32 0
@stdout = global i32 0
@.str.1 = [10 x i8] c"sleeping\0A\00"
define void @test_pause() {
%1 = load i8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @test_pause.trickFile, i64 0, i64 0)
%2 = sext i8 %1 to i32
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = call i32 @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @strcpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @test_pause.trickFile, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %4, %0
br label %8
8: ; preds = %12, %7
%9 = load i32, i32* @R_OK
%10 = call i64 @access(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @test_pause.trickFile, i64 0, i64 0), i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %8
%13 = load i32, i32* @stdout
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @stdout
%16 = call i32 @fflush(i32 %15)
%17 = call i32 @sleep(i32 1)
br label %8
18: ; preds = %8
ret void
}

LLVM IR (-O2):
@test_pause.trickFile = internal global [1024 x i8] zeroinitializer
@.str = [11 x i8] c"TRICK_FILE\00"
@R_OK = global i32 0
@stdout = global i32 0
@.str.1 = [10 x i8] c"sleeping\0A\00"
define void @test_pause() {
%1 = load i8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @test_pause.trickFile, i64 0, i64 0)
%2 = icmp eq i8 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strcpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @test_pause.trickFile, i64 0, i64 0), i32 %4)
br label %6
6: ; preds = %3, %0
%7 = load i32, i32* @R_OK
%8 = tail call i64 @access(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @test_pause.trickFile, i64 0, i64 0), i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %6, %10
%11 = load i32, i32* @stdout
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stdout
%14 = tail call i32 @fflush(i32 %13)
%15 = tail call i32 @sleep(i32 1)
%16 = load i32, i32* @R_OK
%17 = tail call i64 @access(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @test_pause.trickFile, i64 0, i64 0), i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %10, label %19
19: ; preds = %10, %6
ret void
}