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

/* Variables and functions */
int /*<<< orphan*/ errno;
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
char *strerror(int /*<<< orphan*/);
void kill_converting_process(char *pid) {
  char kill_cmd[16];
  char kill_result[128];
  FILE *pfp;
  memset(kill_result, 0, 128);
  memset(kill_cmd, 0, 16);
  snprintf(kill_cmd, 16, "kill -9 %s", pid);
  pfp = popen(kill_cmd, "r");
  if (!pfp) {
    printf("open cmd[%s] error: %s", kill_cmd, strerror(errno));
    return;
  }
  while (fgets(kill_result, sizeof(kill_result), pfp)) {
  }
  pclose(pfp);
}


x86 assembly (clang, -O0):
<kill_converting_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x10,%esi
lea    0xe4a(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x20(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
jne    1214 <kill_converting_process+0xa4>
lea    -0x20(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0xb0(%rbp),%rsi
mov    %rax,%rdx
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
jmp    124c <kill_converting_process+0xdc>
jmp    1219 <kill_converting_process+0xa9>
lea    -0xa0(%rbp),%rdi
mov    -0xa8(%rbp),%rdx
mov    $0x80,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1240 <kill_converting_process+0xd0>
jmp    1219 <kill_converting_process+0xa9>
mov    -0xa8(%rbp),%rdi
call   1040 <pclose@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kill_converting_process>:
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    %rdi,%r14
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    0xe59(%rip),%rdx
mov    %rbx,%rdi
mov    $0x10,%esi
mov    %r14,%rcx
call   1050 <snprintf@plt>
lea    0xe4d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <popen@plt>
test   %rax,%rax
je     11ff <kill_converting_process+0x8f>
mov    %rax,%rbx
lea    0x10(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    $0x80,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    11e0 <kill_converting_process+0x70>
mov    %rbx,%rdi
call   1040 <pclose@plt>
jmp    121f <kill_converting_process+0xaf>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xdf9(%rip),%rdi
mov    %rsp,%rsi
mov    %rax,%rdx
call   1030 <printf@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"kill -9 %s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"open cmd[%s] error: %s\00"
@errno = global i32 0
define void @kill_converting_process(i8* %0) {
%2 = alloca i8*
%3 = alloca [16 x i8]
%4 = alloca [128 x i8]
%5 = alloca i32*
store i8* %0, i8** %2
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 128)
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 16)
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%11 = load i8*, i8** %2
%12 = call i32 @snprintf(i8* %10, i32 16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%14 = call i32* @popen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %5
%15 = load i32*, i32** %5
%16 = icmp ne i32* %15, null
br i1 %16, label %22, label %17
17: ; preds = %1
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %20)
br label %32
22: ; preds = %1
br label %23
23: ; preds = %28, %22
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%25 = load i32*, i32** %5
%26 = call i64 @fgets(i8* %24, i32 128, i32* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
br label %23
29: ; preds = %23
%30 = load i32*, i32** %5
%31 = call i32 @pclose(i32* %30)
br label %32
32: ; preds = %29, %17
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"kill -9 %s\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"open cmd[%s] error: %s\00"
@errno = global i32 0
define void @kill_converting_process(i8* %0) {
%2 = alloca [16 x i8]
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 128)
%7 = call i32 @memset(i8* %4, i32 0, i32 16)
%8 = call i32 @snprintf(i8* %4, i32 16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = call i32* @popen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %13)
br label %20
15: ; preds = %1, %15
%16 = call i64 @fgets(i8* %5, i32 128, i32* %9)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %15
18: ; preds = %15
%19 = call i32 @pclose(i32* %9)
br label %20
20: ; preds = %18, %11
ret void
}