#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ gpm_report(int, char *, int, char *, ...);
int kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ unlink(char *);
void check_kill(void) {
  int old_pid;
  FILE *fp = fopen("/var/run/"
                   "gpm.pid",
                   "r");
  if (fp == NULL)
    gpm_report(158,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/ipwndev/DSLinux-Mirror/refs/"
               "heads/master/lib/gpm/src/gpn.c",
               6, "Could not open %s.",
               "/var/run/"
               "gpm.pid");
  if (fscanf(fp, "%d", &old_pid) != 1)
    gpm_report(162,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/ipwndev/DSLinux-Mirror/refs/"
               "heads/master/lib/gpm/src/gpn.c",
               6, "Problem reading from %s",
               "/var/run/"
               "gpm.pid");
  fclose(fp);
  gpm_report(165,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/ipwndev/DSLinux-Mirror/refs/heads/"
             "master/lib/gpm/src/gpn.c",
             2, "Trying to kill gpm running at pid %d", old_pid);
  if (kill(old_pid, 0) == -1) {
    gpm_report(169,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/ipwndev/DSLinux-Mirror/refs/"
               "heads/master/lib/gpm/src/gpn.c",
               3, "Removing stale pid file %s",
               "/var/run/"
               "gpm.pid");
    unlink("/var/run/"
           "gpm.pid");
  }
  if (kill(old_pid, SIGTERM) == -1)
    gpm_report(174,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/ipwndev/DSLinux-Mirror/refs/"
               "heads/master/lib/gpm/src/gpn.c",
               6, "Couldn't kill gpm(%d)!", old_pid);
  gpm_report(176,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/ipwndev/DSLinux-Mirror/refs/heads/"
             "master/lib/gpm/src/gpn.c",
             3, "Killed gpm(%d).", old_pid);
  exit(0);
}


x86 assembly (clang, -O0):
<check_kill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe81(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c0 <check_kill+0x50>
mov    $0x9e,%edi
lea    0xe6d(%rip),%rsi
mov    $0x6,%edx
lea    0xef6(%rip),%rcx
lea    0xe47(%rip),%r8
mov    $0x0,%al
call   1090 <gpm_report@plt>
mov    -0x10(%rbp),%rdi
lea    0xf2a(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1050 <fscanf@plt>
cmp    $0x1,%eax
je     1203 <check_kill+0x93>
mov    $0xa2,%edi
lea    0xe2a(%rip),%rsi
mov    $0x6,%edx
lea    0xec6(%rip),%rcx
lea    0xe04(%rip),%r8
mov    $0x0,%al
call   1090 <gpm_report@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%r8d
mov    $0xa5,%edi
lea    0xdf7(%rip),%rsi
mov    $0x2,%edx
lea    0xeab(%rip),%rcx
mov    $0x0,%al
call   1090 <gpm_report@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1060 <kill@plt>
cmp    $0xffffffff,%eax
jne    1274 <check_kill+0x104>
mov    $0xa9,%edi
lea    0xdc5(%rip),%rsi
mov    $0x3,%edx
lea    0xe9e(%rip),%rcx
lea    0xd9f(%rip),%r8
mov    $0x0,%al
call   1090 <gpm_report@plt>
lea    0xd91(%rip),%rdi
call   1030 <unlink@plt>
mov    -0x4(%rbp),%edi
mov    0x2d6a(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
cmp    $0xffffffff,%eax
jne    12b1 <check_kill+0x141>
mov    -0x4(%rbp),%r8d
mov    $0xae,%edi
lea    0xd75(%rip),%rsi
mov    $0x6,%edx
lea    0xe69(%rip),%rcx
mov    $0x0,%al
call   1090 <gpm_report@plt>
mov    -0x4(%rbp),%r8d
mov    $0xb0,%edi
lea    0xd52(%rip),%rsi
mov    $0x3,%edx
lea    0xe5d(%rip),%rcx
mov    $0x0,%al
call   1090 <gpm_report@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<check_kill>:
push   %rbx
sub    $0x10,%rsp
lea    0xe84(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11b6 <check_kill+0x46>
lea    0xe7c(%rip),%rsi
lea    0xf0a(%rip),%rcx
lea    0xe5b(%rip),%r8
mov    $0x9e,%edi
mov    $0x6,%edx
xor    %eax,%eax
call   1090 <gpm_report@plt>
lea    0xf38(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <fscanf@plt>
cmp    $0x1,%eax
je     11f5 <check_kill+0x85>
lea    0xe3d(%rip),%rsi
lea    0xede(%rip),%rcx
lea    0xe1c(%rip),%r8
mov    $0xa2,%edi
mov    $0x6,%edx
xor    %eax,%eax
call   1090 <gpm_report@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0xc(%rsp),%r8d
lea    0xe0a(%rip),%rsi
lea    0xec3(%rip),%rcx
mov    $0xa5,%edi
mov    $0x2,%edx
xor    %eax,%eax
call   1090 <gpm_report@plt>
mov    0xc(%rsp),%edi
xor    %esi,%esi
call   1060 <kill@plt>
cmp    $0xffffffff,%eax
jne    1262 <check_kill+0xf2>
lea    0xddb(%rip),%rsi
lea    0xeb9(%rip),%rcx
lea    0xdba(%rip),%rbx
mov    $0xa9,%edi
mov    $0x3,%edx
mov    %rbx,%r8
xor    %eax,%eax
call   1090 <gpm_report@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    0xc(%rsp),%edi
mov    0x2d7b(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
cmp    $0xffffffff,%eax
jne    129d <check_kill+0x12d>
mov    0xc(%rsp),%r8d
lea    0xd8e(%rip),%rsi
lea    0xe87(%rip),%rcx
mov    $0xae,%edi
mov    $0x6,%edx
xor    %eax,%eax
call   1090 <gpm_report@plt>
mov    0xc(%rsp),%r8d
lea    0xd6a(%rip),%rsi
lea    0xe7a(%rip),%rcx
mov    $0xb0,%edi
mov    $0x3,%edx
xor    %eax,%eax
call   1090 <gpm_report@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"/var/run/gpm.pid\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ipwndev/DSLinux-Mirror/refs/heads/master/lib/gpm/src/gpn.c\00"
@.str.3 = [19 x i8] c"Could not open %s.\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [24 x i8] c"Problem reading from %s\00"
@.str.6 = [37 x i8] c"Trying to kill gpm running at pid %d\00"
@.str.7 = [27 x i8] c"Removing stale pid file %s\00"
@SIGTERM = global i32 0
@.str.8 = [23 x i8] c"Couldn't kill gpm(%d)!\00"
@.str.9 = [16 x i8] c"Killed gpm(%d).\00"
define void @check_kill() {
%1 = alloca i32
%2 = alloca i32*
%3 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 (i32, i8*, i32, i8*, ...) @gpm_report(i32 158, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 6, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
%9 = load i32*, i32** %2
%10 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 (i32, i8*, i32, i8*, ...) @gpm_report(i32 162, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %8
%15 = load i32*, i32** %2
%16 = call i32 @fclose(i32* %15)
%17 = load i32, i32* %1
%18 = call i32 (i32, i8*, i32, i8*, ...) @gpm_report(i32 165, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %1
%20 = call i32 @kill(i32 %19, i32 0)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %14
%23 = call i32 (i32, i8*, i32, i8*, ...) @gpm_report(i32 169, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @unlink(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %22, %14
%26 = load i32, i32* %1
%27 = load i32, i32* @SIGTERM
%28 = call i32 @kill(i32 %26, i32 %27)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load i32, i32* %1
%32 = call i32 (i32, i8*, i32, i8*, ...) @gpm_report(i32 174, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %25
%34 = load i32, i32* %1
%35 = call i32 (i32, i8*, i32, i8*, ...) @gpm_report(i32 176, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %34)
%36 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [17 x i8] c"/var/run/gpm.pid\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ipwndev/DSLinux-Mirror/refs/heads/master/lib/gpm/src/gpn.c\00"
@.str.3 = [19 x i8] c"Could not open %s.\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [24 x i8] c"Problem reading from %s\00"
@.str.6 = [37 x i8] c"Trying to kill gpm running at pid %d\00"
@.str.7 = [27 x i8] c"Removing stale pid file %s\00"
@SIGTERM = global i32 0
@.str.8 = [23 x i8] c"Couldn't kill gpm(%d)!\00"
@.str.9 = [16 x i8] c"Killed gpm(%d).\00"
define void @check_kill() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 (i32, i8*, i32, i8*, ...) @gpm_report(i32 158, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 6, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%9 = icmp eq i32 %8, 1
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = call i32 (i32, i8*, i32, i8*, ...) @gpm_report(i32 162, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = call i32 @fclose(i32* %3)
%14 = load i32, i32* %1
%15 = call i32 (i32, i8*, i32, i8*, ...) @gpm_report(i32 165, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %1
%17 = call i32 @kill(i32 %16, i32 0)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = call i32 (i32, i8*, i32, i8*, ...) @gpm_report(i32 169, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @unlink(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %19, %12
%23 = load i32, i32* %1
%24 = load i32, i32* @SIGTERM
%25 = call i32 @kill(i32 %23, i32 %24)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i32, i32* %1
%29 = call i32 (i32, i8*, i32, i8*, ...) @gpm_report(i32 174, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %22
%31 = load i32, i32* %1
%32 = call i32 (i32, i8*, i32, i8*, ...) @gpm_report(i32 176, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %31)
%33 = call i32 @exit(i32 0)
unreachable
}