#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int get_roach_num();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int need_to_restart() {
  char restartfilename[] = "restartPulseServer.bin";
  FILE *restartfile;
  restartfile = fopen(restartfilename, "r");
  if (restartfile == 0) {
    if (0 == 1) {
      printf("No restart file found\n");
      fflush(stdout);
    }
    errno = 0;
    return 0;
  } else {
    printf("Received Restart signal\n");
    fprintf(stderr, "\nRecieved Restart signal %d", get_roach_num());
    fflush(stdout);
    return 1;
  }
}


x86 assembly (clang, -O0):
<need_to_restart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xea1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe9e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe9c(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xe96(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    0xe8e(%rip),%al
mov    %al,-0xa(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c4 <need_to_restart+0x74>
mov    0x2e27(%rip),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1209 <need_to_restart+0xb9>
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1060 <get_roach_num@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%edx
lea    0xe43(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<need_to_restart>:
push   %rbx
sub    $0x20,%rsp
movaps 0xea4(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x6e69622e726576,%rax
mov    %rax,0xf(%rsp)
lea    0xea1(%rip),%rsi
mov    %rsp,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c4 <need_to_restart+0x74>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1060 <get_roach_num@plt>
lea    0xe73(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1040 <fprintf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x1,%eax
jmp    11d4 <need_to_restart+0x84>
mov    0x2e0d(%rip),%rax
movq   $0x0,(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.need_to_restart.restartfilename = [23 x i8] c"restartPulseServer.bin\00"
@.str = [2 x i8] c"r\00"
@errno = global i64 0
@.str.1 = [25 x i8] c"Received Restart signal\0A\00"
@stderr = global i32 0
@.str.2 = [28 x i8] c"\0ARecieved Restart signal %d\00"
@stdout = global i32 0
define i32 @need_to_restart() {
%1 = alloca i32
%2 = alloca [23 x i8]
%3 = alloca i32*
%4 = bitcast [23 x i8]* %2 to i8*
%5 = getelementptr inbounds [23 x i8], [23 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 %17
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @stderr
%13 = call i32 (...) @get_roach_num()
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @stdout
%16 = call i32 @fflush(i32 %15)
store i32 1, i32* %1
br label %17
17: ; preds = %10, %9
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@__const.need_to_restart.restartfilename = [23 x i8] c"restartPulseServer.bin\00"
@.str = [2 x i8] c"r\00"
@errno = global i64 0
@stderr = global i32 0
@.str.2 = [28 x i8] c"\0ARecieved Restart signal %d\00"
@stdout = global i32 0
@str = [24 x i8] c"Received Restart signal\00"
define i32 @need_to_restart() {
%1 = alloca [23 x i8]
%2 = getelementptr inbounds [23 x i8], [23 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 %13
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%8 = load i32, i32* @stderr
%9 = tail call i32 (...) @get_roach_num()
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @stdout
%12 = tail call i32 @fflush(i32 %11)
br label %13
13: ; preds = %6, %5
%14 = phi i32 [ 0, %5 ], [ 1, %6 ]
ret i32 %14
}