#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 pid_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, long);
scalar_t__ kill(int, int /*<<< orphan*/);
int readPidFile();
int /*<<< orphan*/ stderr;
int checkRunningPid(void) {
  pid_t pid;
  pid = readPidFile();
  if (pid < 2)
    return 0;
  if (kill(pid, 0) < 0)
    return 0;
  fprintf(stderr, "getslice_master is already running!  process id %ld\n",
          (long int)pid);
  return 1;
}


x86 assembly (clang, -O0):
<checkRunningPid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <readPidFile@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1158 <checkRunningPid+0x28>
movl   $0x0,-0x4(%rbp)
jmp    1198 <checkRunningPid+0x68>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1040 <kill@plt>
cmp    $0x0,%rax
jge    1178 <checkRunningPid+0x48>
movl   $0x0,-0x4(%rbp)
jmp    1198 <checkRunningPid+0x68>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
movslq -0x8(%rbp),%rdx
lea    0xe74(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkRunningPid>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <readPidFile@plt>
cmp    $0x2,%eax
jl     116f <checkRunningPid+0x3f>
mov    %eax,%ebp
xor    %ebx,%ebx
mov    %eax,%edi
xor    %esi,%esi
call   1040 <kill@plt>
test   %rax,%rax
js     116f <checkRunningPid+0x3f>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    %ebp,%edx
lea    0xe9b(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [53 x i8] c"getslice_master is already running! process id %ld\0A\00"
define i32 @checkRunningPid() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @readPidFile()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 2
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 0, i32* %1
br label %17
7: ; preds = %0
%8 = load i32, i32* %2
%9 = call i64 @kill(i32 %8, i32 0)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 0, i32* %1
br label %17
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i64 %15)
store i32 1, i32* %1
br label %17
17: ; preds = %12, %11, %6
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [53 x i8] c"getslice_master is already running! process id %ld\0A\00"
define i32 @checkRunningPid() {
%1 = tail call i32 (...) @readPidFile()
%2 = icmp slt i32 %1, 2
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = tail call i64 @kill(i32 %1, i32 0)
%5 = icmp slt i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = zext i32 %1 to i64
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i64 %8)
br label %10
10: ; preds = %3, %0, %6
%11 = phi i32 [ 1, %6 ], [ 0, %0 ], [ 0, %3 ]
ret i32 %11
}