#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__ killer(int);
int readPidFile(char *);
int childKiller(void) {
  int chi_1 = readPidFile("/tmp/.pidlbr-1");
  int chi_2 = readPidFile("/tmp/.pidlbr-2");
  int ret_val = 0;
  if (killer(chi_1) == 0) {
    ret_val = ret_val + 2;
  } else {
    ret_val = ret_val - 2;
  }
  if (killer(chi_2) == 0) {
    ret_val = ret_val + 1;
  } else {
    ret_val = ret_val - 1;
  }
  return ret_val;
}


x86 assembly (clang, -O0):
<childKiller>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1040 <readPidFile@plt>
mov    %eax,-0x4(%rbp)
lea    0xed1(%rip),%rdi
call   1040 <readPidFile@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <killer@plt>
cmp    $0x0,%rax
jne    116d <childKiller+0x4d>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1176 <childKiller+0x56>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <killer@plt>
cmp    $0x0,%rax
jne    1196 <childKiller+0x76>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119f <childKiller+0x7f>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<childKiller>:
push   %rbp
push   %rbx
push   %rax
lea    0xed6(%rip),%rdi
call   1040 <readPidFile@plt>
mov    %eax,%ebx
lea    0xed7(%rip),%rdi
call   1040 <readPidFile@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <killer@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
mov    %ebp,%edi
call   1030 <killer@plt>
cmp    $0x1,%rax
sbb    %eax,%eax
or     $0xfffffffd,%eax
lea    (%rax,%rbx,4),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"/tmp/.pidlbr-1\00"
@.str.1 = [15 x i8] c"/tmp/.pidlbr-2\00"
define i32 @childKiller() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @readPidFile(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* %1
%5 = call i32 @readPidFile(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 %5, i32* %2
store i32 0, i32* %3
%6 = load i32, i32* %1
%7 = call i64 @killer(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 2
store i32 %11, i32* %3
br label %15
12: ; preds = %0
%13 = load i32, i32* %3
%14 = sub nsw i32 %13, 2
store i32 %14, i32* %3
br label %15
15: ; preds = %12, %9
%16 = load i32, i32* %2
%17 = call i64 @killer(i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %25
22: ; preds = %15
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 1
store i32 %24, i32* %3
br label %25
25: ; preds = %22, %19
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [15 x i8] c"/tmp/.pidlbr-1\00"
@.str.1 = [15 x i8] c"/tmp/.pidlbr-2\00"
define i32 @childKiller() {
%1 = tail call i32 @readPidFile(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @readPidFile(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i64 @killer(i32 %1)
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 2, i32 -2
%6 = tail call i64 @killer(i32 %2)
%7 = icmp eq i64 %6, 0
%8 = or i32 %5, 1
%9 = add nsw i32 %5, -1
%10 = select i1 %7, i32 %8, i32 %9
ret i32 %10
}