#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_with_server(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 start_all(void) {
  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_with_server("startall", &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):
<start_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa010,%rsp
lea    -0x4(%rbp),%rdi
call   1080 <ping_server@plt>
cmpl   $0x0,-0x4(%rbp)
je     11a1 <start_all+0x41>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    -0xa010(%rbp),%rdx
lea    0xeb7(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <communicate_with_server@plt>
cmpl   $0x0,-0x4(%rbp)
je     11e5 <start_all+0x85>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    -0xa010(%rbp),%rsi
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <show_status@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<start_all>:
sub    $0xa018,%rsp
lea    0xc(%rsp),%rdi
call   1080 <ping_server@plt>
cmpl   $0x0,0xc(%rsp)
jne    11bb <start_all+0x5b>
lea    0xee7(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1040 <communicate_with_server@plt>
cmpl   $0x0,0xc(%rsp)
jne    11cd <start_all+0x6d>
lea    0xefa(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <show_status@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
lea    0xe35(%rip),%rsi
jmp    11dd <start_all+0x7d>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xe92(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2def(%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 = [9 x i8] c"startall\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 @start_all() {
%1 = alloca i32
%2 = alloca [40960 x i8]
%3 = call i32 @ping_server(i32* %1)
%4 = load i32, i32* %1
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
%12 = getelementptr inbounds [40960 x i8], [40960 x i8]* %2, i64 0, i64 0
%13 = call i32 @communicate_with_server(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i8* %12)
%14 = load i32, i32* %1
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %11
%22 = getelementptr inbounds [40960 x i8], [40960 x i8]* %2, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = call i32 (...) @show_status()
%25 = load i32, i32* @EXIT_SUCCESS
%26 = call i32 @exit(i32 %25)
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 = [9 x i8] c"startall\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 @start_all() {
%1 = alloca i32
%2 = alloca [40960 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [40960 x i8], [40960 x i8]* %2, i64 0, i64 0
%5 = call i32 @ping_server(i32* %1)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %0
%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 = %0
%14 = call i32 @communicate_with_server(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i8* %4)
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %13
%23 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%24 = call i32 (...) @show_status()
%25 = load i32, i32* @EXIT_SUCCESS
%26 = call i32 @exit(i32 %25)
unreachable
}