#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*/ SIGKILL;
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int kill(long, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, long, int);
int /*<<< orphan*/ sscanf(char *, char *, long *);
int /*<<< orphan*/ system(char *);
int killProcess(const char *pathpid) {
  long pid_process;
  char line[80];
  int error;
  FILE *fp = fopen(pathpid, "r");
  while (fgets(line, 80, fp) != NULL) {
    sscanf(line, "%ld", &pid_process);
    if (pid_process > 0) {
      error = kill(pid_process, SIGKILL);
      printf("Proceso : %ld estado: %d \n", pid_process, error);
    }
    system("/usr/bin/killall sync-svn.sh");
    system("/usr/bin/killall inotifywait");
  }
  return 0;
}


x86 assembly (clang, -O0):
<killProcess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x70(%rbp),%rdx
mov    $0x50,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1200 <killProcess+0xa0>
lea    -0x60(%rbp),%rdi
lea    0xe5b(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1070 <sscanf@plt>
cmpq   $0x0,-0x10(%rbp)
jle    11e3 <killProcess+0x83>
mov    -0x10(%rbp),%rdi
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x64(%rbp),%edx
lea    0xe28(%rip),%rdi
call   1040 <printf@plt>
lea    0xe37(%rip),%rdi
call   1030 <system@plt>
lea    0xe48(%rip),%rdi
call   1030 <system@plt>
jmp    1180 <killProcess+0x20>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<killProcess>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe8b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
lea    0x10(%rsp),%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1220 <killProcess+0xc0>
lea    0xe63(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r12
lea    0xe71(%rip),%rbp
lea    0xe87(%rip),%r13
jmp    11e5 <killProcess+0x85>
nopl   0x0(%rax)
mov    %rbp,%rdi
call   1030 <system@plt>
mov    %r13,%rdi
call   1030 <system@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1220 <killProcess+0xc0>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1070 <sscanf@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
jle    11c0 <killProcess+0x60>
mov    0x2ddc(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
mov    0x8(%rsp),%rsi
lea    0xdef(%rip),%rdi
mov    %eax,%edx
call   1040 <printf@plt>
jmp    11c0 <killProcess+0x60>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%ld\00"
@SIGKILL = global i32 0
@.str.2 = [27 x i8] c"Proceso : %ld estado: %d \0A\00"
@.str.3 = [29 x i8] c"/usr/bin/killall sync-svn.sh\00"
@.str.4 = [29 x i8] c"/usr/bin/killall inotifywait\00"
define i32 @killProcess(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca [80 x i8]
%5 = alloca i32
%6 = alloca i32*
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %6
br label %9
9: ; preds = %26, %1
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%11 = load i32*, i32** %6
%12 = call i32* @fgets(i8* %10, i32 80, i32* %11)
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %29
14: ; preds = %9
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%17 = load i64, i64* %3
%18 = icmp sgt i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %14
%20 = load i64, i64* %3
%21 = load i32, i32* @SIGKILL
%22 = call i32 @kill(i64 %20, i32 %21)
store i32 %22, i32* %5
%23 = load i64, i64* %3
%24 = load i32, i32* %5
%25 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i64 %23, i32 %24)
br label %26
26: ; preds = %19, %14
%27 = call i32 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %9
29: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%ld\00"
@SIGKILL = global i32 0
@.str.2 = [27 x i8] c"Proceso : %ld estado: %d \0A\00"
@.str.3 = [29 x i8] c"/usr/bin/killall sync-svn.sh\00"
@.str.4 = [29 x i8] c"/usr/bin/killall inotifywait\00"
define i32 @killProcess(i8* nocapture %0) {
%2 = alloca i64
%3 = alloca [80 x i8]
%4 = bitcast i64* %2 to i8*
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = call i32* @fgets(i8* %5, i32 80, i32* %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %23, label %9
9: ; preds = %1, %18
%10 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%11 = load i64, i64* %2
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = load i32, i32* @SIGKILL
%15 = call i32 @kill(i64 %11, i32 %14)
%16 = load i64, i64* %2
%17 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i64 %16, i32 %15)
br label %18
18: ; preds = %13, %9
%19 = call i32 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32* @fgets(i8* %5, i32 80, i32* %6)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %9
23: ; preds = %18, %1
ret i32 0
}