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

/* Variables and functions */
char flu_fstat(char *, char const *);
char *flu_readall(char *, char const *);
int /*<<< orphan*/ free(char *);
scalar_t__ kill(scalar_t__, int /*<<< orphan*/);
scalar_t__ strtoll(char *, int /*<<< orphan*/ *, int);
int executor_not_running(const char *exid) {
  if (flu_fstat("var/run/%s.pid", exid) == '\0')
    return 1;
  char *spid = flu_readall("var/run/%s.pid", exid);
  if (spid == NULL)
    return 1;
  pid_t pid = strtoll(spid, NULL, 10);
  free(spid);
  if (pid == 0)
    return 1;
  if (kill(pid, 0) != 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<executor_not_running>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe99(%rip),%rdi
call   1070 <flu_fstat@plt>
movsbl %al,%eax
cmp    $0x0,%eax
jne    1184 <executor_not_running+0x34>
movl   $0x1,-0x4(%rbp)
jmp    120d <executor_not_running+0xbd>
mov    -0x10(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1040 <flu_readall@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11af <executor_not_running+0x5f>
movl   $0x1,-0x4(%rbp)
jmp    120d <executor_not_running+0xbd>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoll@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x20(%rbp)
jne    11e5 <executor_not_running+0x95>
movl   $0x1,-0x4(%rbp)
jmp    120d <executor_not_running+0xbd>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1060 <kill@plt>
cmp    $0x0,%rax
je     1206 <executor_not_running+0xb6>
movl   $0x1,-0x4(%rbp)
jmp    120d <executor_not_running+0xbd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<executor_not_running>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
call   1070 <flu_fstat@plt>
mov    $0x1,%ebp
test   %al,%al
je     11b8 <executor_not_running+0x68>
lea    0xe8a(%rip),%rdi
mov    %rbx,%rsi
call   1040 <flu_readall@plt>
test   %rax,%rax
je     11b8 <executor_not_running+0x68>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoll@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r14,%r14
je     11b8 <executor_not_running+0x68>
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <kill@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"var/run/%s.pid\00"
define i32 @executor_not_running(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call signext i8 @flu_fstat(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %31
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i8* @flu_readall(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %12)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 1, i32* %2
br label %31
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = call i64 @strtoll(i8* %18, i32* null, i32 10)
store i64 %19, i64* %5
%20 = load i8*, i8** %4
%21 = call i32 @free(i8* %20)
%22 = load i64, i64* %5
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %17
store i32 1, i32* %2
br label %31
25: ; preds = %17
%26 = load i64, i64* %5
%27 = call i64 @kill(i64 %26, i32 0)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 1, i32* %2
br label %31
30: ; preds = %25
store i32 0, i32* %2
br label %31
31: ; preds = %30, %29, %24, %16, %10
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@.str = [15 x i8] c"var/run/%s.pid\00"
define i32 @executor_not_running(i8* %0) {
%2 = tail call signext i8 @flu_fstat(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = icmp eq i8 %2, 0
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = tail call i8* @flu_readall(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %15, label %7
7: ; preds = %4
%8 = tail call i64 @strtoll(i8* nocapture %5, i32* null, i32 10)
%9 = tail call i32 @free(i8* %5)
%10 = icmp eq i64 %8, 0
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = tail call i64 @kill(i64 %8, i32 0)
%13 = icmp ne i64 %12, 0
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %4, %11, %7, %1
%16 = phi i32 [ 1, %1 ], [ 1, %4 ], [ 1, %7 ], [ %14, %11 ]
ret i32 %16
}