#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 atoi(char *);
int /*<<< orphan*/ debugMsg(char *);
char *readFile(char *);
int readPidFile(char *pid_file) {
  debugMsg("readPidFile() ...");
  int ret_val;
  debugMsg("readPidFile() ... readFile ...");
  char *pid_chr = readFile(pid_file);
  debugMsg("readPidFile() ... readFile ... ok ...");
  if (pid_chr != NULL) {
    debugMsg("readPidFile() ... pid ok ...");
    ret_val = atoi(pid_chr);
  } else {
    debugMsg("readPidFile() ... pid 0 ...");
    ret_val = 0;
  }
  debugMsg("readPidFile() ... ok ...");
  return ret_val;
}


x86 assembly (clang, -O0):
<readPidFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <debugMsg@plt>
lea    0xec3(%rip),%rdi
call   1030 <debugMsg@plt>
mov    -0x8(%rbp),%rdi
call   1050 <readFile@plt>
mov    %rax,-0x18(%rbp)
lea    0xec9(%rip),%rdi
call   1030 <debugMsg@plt>
cmpq   $0x0,-0x18(%rbp)
je     1195 <readPidFile+0x65>
lea    0xed8(%rip),%rdi
call   1030 <debugMsg@plt>
mov    -0x18(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0xc(%rbp)
jmp    11a8 <readPidFile+0x78>
lea    0xed8(%rip),%rdi
call   1030 <debugMsg@plt>
movl   $0x0,-0xc(%rbp)
lea    0xee1(%rip),%rdi
call   1030 <debugMsg@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readPidFile>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
call   1030 <debugMsg@plt>
lea    0xecb(%rip),%rdi
call   1030 <debugMsg@plt>
mov    %rbx,%rdi
call   1050 <readFile@plt>
mov    %rax,%rbx
lea    0xed3(%rip),%rdi
call   1030 <debugMsg@plt>
test   %rbx,%rbx
je     1180 <readPidFile+0x50>
lea    0xee8(%rip),%rdi
call   1030 <debugMsg@plt>
mov    %rbx,%rdi
call   1040 <atoi@plt>
mov    %eax,%ebx
jmp    118e <readPidFile+0x5e>
lea    0xeed(%rip),%rdi
call   1030 <debugMsg@plt>
xor    %ebx,%ebx
lea    0xefb(%rip),%rdi
call   1030 <debugMsg@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"readPidFile() ...\00"
@.str.1 = [31 x i8] c"readPidFile() ... readFile ...\00"
@.str.2 = [38 x i8] c"readPidFile() ... readFile ... ok ...\00"
@.str.3 = [29 x i8] c"readPidFile() ... pid ok ...\00"
@.str.4 = [28 x i8] c"readPidFile() ... pid 0 ...\00"
@.str.5 = [25 x i8] c"readPidFile() ... ok ...\00"
define i32 @readPidFile(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = call i32 @debugMsg(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @debugMsg(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%7 = load i8*, i8** %2
%8 = call i8* @readFile(i8* %7)
store i8* %8, i8** %4
%9 = call i32 @debugMsg(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = call i32 @debugMsg(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%14 = load i8*, i8** %4
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %3
br label %18
16: ; preds = %1
%17 = call i32 @debugMsg(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %18
18: ; preds = %16, %12
%19 = call i32 @debugMsg(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [18 x i8] c"readPidFile() ...\00"
@.str.1 = [31 x i8] c"readPidFile() ... readFile ...\00"
@.str.2 = [38 x i8] c"readPidFile() ... readFile ... ok ...\00"
@.str.3 = [29 x i8] c"readPidFile() ... pid ok ...\00"
@.str.4 = [28 x i8] c"readPidFile() ... pid 0 ...\00"
@.str.5 = [25 x i8] c"readPidFile() ... ok ...\00"
define i32 @readPidFile(i8* %0) {
%2 = tail call i32 @debugMsg(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @debugMsg(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i8* @readFile(i8* %0)
%5 = tail call i32 @debugMsg(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i8* %4, null
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = tail call i32 @debugMsg(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @atoi(i8* %4)
br label %12
10: ; preds = %1
%11 = tail call i32 @debugMsg(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = phi i32 [ %9, %7 ], [ 0, %10 ]
%14 = tail call i32 @debugMsg(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
ret i32 %13
}