#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*/ SIGQUIT;
int kill(int, int /*<<< orphan*/);
int load_pid_file(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
bool pipe_kill(void) {
  pid_t manage;
  manage = load_pid_file("manage.pid");
  if (manage != -1) {
    if (kill(manage, SIGQUIT) == -1) {
      perror("Could not shut down computation");
      return false;
    }
  } else {
    printf("Managing process not running\n");
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<pipe_kill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1050 <load_pid_file@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     1198 <pipe_kill+0x58>
mov    -0x8(%rbp),%edi
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
call   1040 <kill@plt>
cmp    $0xffffffff,%eax
jne    1193 <pipe_kill+0x53>
lea    0xe89(%rip),%rdi
call   1060 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <pipe_kill+0x77>
jmp    11b0 <pipe_kill+0x70>
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <pipe_kill+0x77>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pipe_kill>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1050 <load_pid_file@plt>
cmp    $0xffffffff,%eax
je     1170 <pipe_kill+0x30>
mov    0x2e8f(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1040 <kill@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0xffffffff,%ecx
je     1180 <pipe_kill+0x40>
pop    %rcx
ret
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe84(%rip),%rdi
call   1060 <perror@plt>
jmp    117c <pipe_kill+0x3c>

LLVM IR (-O0):
@.str = [11 x i8] c"manage.pid\00"
@SIGQUIT = global i32 0
@.str.1 = [32 x i8] c"Could not shut down computation\00"
@.str.2 = [30 x i8] c"Managing process not running\0A\00"
define i32 @pipe_kill() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @load_pid_file(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, -1
br i1 %5, label %6, label %14
6: ; preds = %0
%7 = load i32, i32* %2
%8 = load i32, i32* @SIGQUIT
%9 = call i32 @kill(i32 %7, i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %17
13: ; preds = %6
br label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %17
16: ; preds = %13
store i32 1, i32* %1
br label %17
17: ; preds = %16, %14, %11
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [11 x i8] c"manage.pid\00"
@SIGQUIT = global i32 0
@.str.1 = [32 x i8] c"Could not shut down computation\00"
@str = [29 x i8] c"Managing process not running\00"
define i32 @pipe_kill() {
%1 = tail call i32 @load_pid_file(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, -1
br i1 %2, label %9, label %3
3: ; preds = %0
%4 = load i32, i32* @SIGQUIT
%5 = tail call i32 @kill(i32 %1, i32 %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %11
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %3, %9, %7
%12 = phi i32 [ 0, %7 ], [ 0, %9 ], [ 1, %3 ]
ret i32 %12
}