#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 */
scalar_t__ errno;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int need_to_stop() {
  char stopfilename[] = "stop.bin";
  FILE *stopfile;
  stopfile = fopen(stopfilename, "r");
  if (stopfile == 0) {
    errno = 0;
    return 0;
  } else {
    printf("found stop file. Exiting\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<need_to_stop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xd(%rbp)
mov    0xecf(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0xd(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1175 <need_to_stop+0x55>
mov    0x2e7e(%rip),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1188 <need_to_stop+0x68>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<need_to_stop>:
sub    $0x18,%rsp
movabs $0x6e69622e706f7473,%rax
62 69 6e
mov    %rax,0x8(%rsp)
movb   $0x0,0x10(%rsp)
lea    0xeca(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1040 <fopen@plt>
test   %rax,%rax
je     1164 <need_to_stop+0x44>
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x18,%rsp
ret
mov    0x2e75(%rip),%rax
movq   $0x0,(%rax)
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.need_to_stop.stopfilename = [9 x i8] c"stop.bin\00"
@.str = [2 x i8] c"r\00"
@errno = global i64 0
@.str.1 = [26 x i8] c"found stop file. Exiting\0A\00"
define i32 @need_to_stop() {
%1 = alloca i32
%2 = alloca [9 x i8]
%3 = alloca i32*
%4 = bitcast [9 x i8]* %2 to i8*
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %10
9: ; preds = %0
store i64 0, i64* @errno
store i32 0, i32* %1
br label %12
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %12
12: ; preds = %10, %9
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@__const.need_to_stop.stopfilename = [9 x i8] c"stop.bin\00"
@.str = [2 x i8] c"r\00"
@errno = global i64 0
@str = [25 x i8] c"found stop file. Exiting\00"
define i32 @need_to_stop() {
%1 = alloca [9 x i8]
%2 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%3 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %6
5: ; preds = %0
store i64 0, i64* @errno
br label %8
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %6, %5
%9 = phi i32 [ 0, %5 ], [ 1, %6 ]
ret i32 %9
}