#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*/ fbuf;
typedef int /*<<< orphan*/ cmd;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
int system(char *);
void boot_server(char *name, char *shell) {
  do {
    char fbuf[1024] = {0};
    snprintf(fbuf, sizeof(fbuf), "\033[32m[MSG]\033[0m  %s\n",
             "start %s server...");
    fprintf(stderr, fbuf, name);
  } while (0);
  char cmd[128] = {0};
  snprintf(cmd, sizeof(cmd), "bash %s", shell);
  if (system(cmd) == -1)
    do {
      char fbuf[1024] = {0};
      snprintf(fbuf, sizeof(fbuf), "\033[31m[ERR]\033[0m  %s\n",
               "start %s fail,shell:%s");
      fprintf(stderr, fbuf, name, shell);
      exit(EXIT_FAILURE);
    } while (0);
  do {
    char fbuf[1024] = {0};
    snprintf(fbuf, sizeof(fbuf), "\033[32m[MSG]\033[0m  %s\n", "boot <%s> ok");
    fprintf(stderr, fbuf, name);
  } while (0);
}


x86 assembly (clang, -O0):
<boot_server>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
lea    0xe77(%rip),%rdx
lea    0xe84(%rip),%rcx
call   1040 <snprintf@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    -0x490(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
lea    -0x490(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x80,%esi
lea    0xe4d(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x490(%rbp),%rdi
call   1030 <system@plt>
cmp    $0xffffffff,%eax
jne    1258 <boot_server+0x108>
jmp    11f9 <boot_server+0xa9>
lea    -0x890(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x890(%rbp),%rdi
mov    $0x400,%esi
lea    0xe10(%rip),%rdx
lea    0xe1d(%rip),%rcx
call   1040 <snprintf@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
lea    -0x890(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    125d <boot_server+0x10d>
lea    -0xc90(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0xc90(%rbp),%rdi
mov    $0x400,%esi
lea    0xd7d(%rip),%rdx
lea    0xdd0(%rip),%rcx
call   1040 <snprintf@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
lea    -0xc90(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
add    $0xc90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<boot_server>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x488,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x80(%rsp),%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe7e(%rip),%rdx
lea    0xe8b(%rip),%rcx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1040 <snprintf@plt>
mov    0x2e43(%rip),%r12
mov    (%r12),%edi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe48(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%rcx
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
lea    0x80(%rsp),%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
cmp    $0xffffffff,%eax
je     1251 <boot_server+0x101>
call   1050 <memset@plt>
lea    0xde3(%rip),%rdx
lea    0xe36(%rip),%rcx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1040 <snprintf@plt>
mov    (%r12),%edi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x488,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
call   1050 <memset@plt>
lea    0xdd2(%rip),%rdx
lea    0xddf(%rip),%rcx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1040 <snprintf@plt>
mov    (%r12),%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"\1B[32m[MSG]\1B[0m %s\0A\00"
@.str.1 = [19 x i8] c"start %s server...\00"
@stderr = global i32 0
@.str.2 = [8 x i8] c"bash %s\00"
@.str.3 = [20 x i8] c"\1B[31m[ERR]\1B[0m %s\0A\00"
@.str.4 = [23 x i8] c"start %s fail,shell:%s\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [13 x i8] c"boot <%s> ok\00"
define void @boot_server(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [1024 x i8]
%6 = alloca [128 x i8]
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %9
9: ; preds = %2
%10 = bitcast [1024 x i8]* %5 to i8*
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = call i32 @snprintf(i8* %11, i32 1024, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%15 = load i8*, i8** %3
%16 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* %14, i8* %15)
br label %17
17: ; preds = %9
%18 = bitcast [128 x i8]* %6 to i8*
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%20 = load i8*, i8** %4
%21 = call i32 @snprintf(i8* %19, i32 128, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%23 = call i32 @system(i8* %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %38
25: ; preds = %17
br label %26
26: ; preds = %25
%27 = bitcast [1024 x i8]* %7 to i8*
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%29 = call i32 @snprintf(i8* %28, i32 1024, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%30 = load i32, i32* @stderr
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%32 = load i8*, i8** %3
%33 = load i8*, i8** %4
%34 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %30, i8* %31, i8* %32, i8* %33)
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; No predecessors!
br label %38
38: ; preds = %37, %17
br label %39
39: ; preds = %38
%40 = bitcast [1024 x i8]* %8 to i8*
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%42 = call i32 @snprintf(i8* %41, i32 1024, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%43 = load i32, i32* @stderr
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%45 = load i8*, i8** %3
%46 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %43, i8* %44, i8* %45)
br label %47
47: ; preds = %39
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"\1B[32m[MSG]\1B[0m %s\0A\00"
@.str.1 = [19 x i8] c"start %s server...\00"
@stderr = global i32 0
@.str.2 = [8 x i8] c"bash %s\00"
@.str.3 = [20 x i8] c"\1B[31m[ERR]\1B[0m %s\0A\00"
@.str.4 = [23 x i8] c"start %s fail,shell:%s\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [13 x i8] c"boot <%s> ok\00"
define void @boot_server(i8* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = alloca [128 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 1024, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %9, i8* %7, i8* %0)
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%12 = call i32 @snprintf(i8* %11, i32 128, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%13 = call i32 @system(i8* %11)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%17 = call i32 @snprintf(i8* %16, i32 1024, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %18, i8* %16, i8* %0, i8* %1)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%24 = call i32 @snprintf(i8* %23, i32 1024, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* %23, i8* %0)
ret void
}