#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ communicate_two_signals_with_server(char *, char *, int *,
                                                       char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ ping_server(int *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ show_status();
int /*<<< orphan*/ stderr;
void remove_process(const char *app_name) {
  int res;
  char buffer[40 * 1024];
  ping_server(&res);
  if (res != 0) {
    fprintf(stderr, "\x1b[32m"
                    "[KB_PM]"
                    "\x1b[0m"
                    ": Server is not online.\n"
                    "\x1b[3m"
                    " Use `kbpm service start` to start the KB_PM service\n"
                    "\x1b[0m");
    exit(EXIT_FAILURE);
  }
  communicate_two_signals_with_server("remove", (char *)app_name, &res, buffer);
  if (res != 0) {
    fprintf(stderr, "\x1b[32m"
                    "[KB_PM]"
                    "\x1b[0m"
                    ": Server error occur.\n");
    exit(EXIT_FAILURE);
  }
  printf("\x1b[32m"
         "[KB_PM]"
         "\x1b[0m"
         ": %s\n",
         buffer);
  show_status();
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<remove_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa010,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1080 <ping_server@plt>
cmpl   $0x0,-0xc(%rbp)
je     11a5 <remove_process+0x45>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rsi
lea    -0xa010(%rbp),%rcx
lea    0xeaf(%rip),%rdi
lea    -0xc(%rbp),%rdx
call   1050 <communicate_two_signals_with_server@plt>
cmpl   $0x0,-0xc(%rbp)
je     11ed <remove_process+0x8d>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    -0xa010(%rbp),%rsi
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <show_status@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<remove_process>:
push   %rbx
sub    $0xa010,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%rdi
call   1080 <ping_server@plt>
cmpl   $0x0,0xc(%rsp)
jne    11c2 <remove_process+0x62>
lea    0xee3(%rip),%rdi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %rbx,%rsi
call   1050 <communicate_two_signals_with_server@plt>
cmpl   $0x0,0xc(%rsp)
jne    11d4 <remove_process+0x74>
lea    0xef1(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <show_status@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
jmp    11e4 <remove_process+0x84>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [102 x i8] c"\1B[32m[KB_PM]\1B[0m: Server is not online.\0A\1B[3m Use `kbpm service start` to start the KB_PM service\0A\1B[0m\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"remove\00"
@.str.2 = [39 x i8] c"\1B[32m[KB_PM]\1B[0m: Server error occur.\0A\00"
@.str.3 = [22 x i8] c"\1B[32m[KB_PM]\1B[0m: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define void @remove_process(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [40960 x i8]
store i8* %0, i8** %2
%5 = call i32 @ping_server(i32* %3)
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %1
%14 = load i8*, i8** %2
%15 = getelementptr inbounds [40960 x i8], [40960 x i8]* %4, i64 0, i64 0
%16 = call i32 @communicate_two_signals_with_server(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %14, i32* %3, i8* %15)
%17 = load i32, i32* %3
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %13
%25 = getelementptr inbounds [40960 x i8], [40960 x i8]* %4, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %25)
%27 = call i32 (...) @show_status()
%28 = load i32, i32* @EXIT_SUCCESS
%29 = call i32 @exit(i32 %28)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [102 x i8] c"\1B[32m[KB_PM]\1B[0m: Server is not online.\0A\1B[3m Use `kbpm service start` to start the KB_PM service\0A\1B[0m\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"remove\00"
@.str.2 = [39 x i8] c"\1B[32m[KB_PM]\1B[0m: Server error occur.\0A\00"
@.str.3 = [22 x i8] c"\1B[32m[KB_PM]\1B[0m: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define void @remove_process(i8* %0) {
%2 = alloca i32
%3 = alloca [40960 x i8]
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [40960 x i8], [40960 x i8]* %3, i64 0, i64 0
%6 = call i32 @ping_server(i32* %2)
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %1
%15 = call i32 @communicate_two_signals_with_server(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32* %2, i8* %5)
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %14
%24 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%25 = call i32 (...) @show_status()
%26 = load i32, i32* @EXIT_SUCCESS
%27 = call i32 @exit(i32 %26)
unreachable
}