#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*/ close(int);
int /*<<< orphan*/ execl(char *, char *, char *, char *, char *, char *,
                         char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strstr(char *, char *);
int /*<<< orphan*/ system(char *);
void spawnchild(char *file) {
  printf("file is %s\n", file);
  char program_path[128] = "/opt/ssloffloader2.0/ssloffloader -f";
  char config_path[128] = "/opt/ssloffloader2.0/ssloffload.cfg";
  char program[512];
  if (!strstr(file, "/opt/cloudport5.4/app.coffee")) {
    fprintf(stderr, "skipping %s, not a VPN configuration file!\n", file);
    return;
  }
  fprintf(stderr, "Starting a child VPN process with %s\n", file);
  printf("preogram path%s\n", program_path);
  system("coffee /opt/cloudport5.4/app.coffee");
  close(0);
  close(1);
  close(2);
  printf("befor program path%d\n", program_path[0]);
  if (program_path[0]) {
    execl(program, "loadbalancer -f", "--config", file, "--syslog", file,
          (char *)NULL);
  } else {
    printf("inside else\n");
    execl("/opt/loadbalancer2.0/", "loadbalancer", "--config", file, "--syslog",
          file, (char *)NULL);
  }
}


x86 assembly (clang, -O0):
<spawnchild>:
push   %rbp
mov    %rsp,%rbp
sub    $0x320,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    0xf61(%rip),%rsi
mov    $0x80,%edx
call   1070 <memcpy@plt>
lea    -0x110(%rbp),%rdi
lea    0xfc9(%rip),%rsi
mov    $0x80,%edx
call   1070 <memcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xeaa(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%eax
jne    11f8 <spawnchild+0x88>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe1e(%rip),%rsi
call   1060 <fprintf@plt>
jmp    12e8 <spawnchild+0x178>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe2c(%rip),%rsi
call   1060 <fprintf@plt>
lea    -0x90(%rbp),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe42(%rip),%rdi
call   1030 <system@plt>
xor    %edi,%edi
call   1050 <close@plt>
mov    $0x1,%edi
call   1050 <close@plt>
mov    $0x2,%edi
call   1050 <close@plt>
movsbl -0x90(%rbp),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpb   $0x0,-0x90(%rbp)
je     12a7 <spawnchild+0x137>
lea    -0x310(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x8(%rbp),%r9
lea    0xe24(%rip),%rsi
lea    0xe2d(%rip),%rdx
lea    0xe2f(%rip),%r8
xor    %eax,%eax
movq   $0x0,(%rsp)
call   1080 <execl@plt>
jmp    12e8 <spawnchild+0x178>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rcx
mov    -0x8(%rbp),%r9
lea    0xe14(%rip),%rdi
lea    0xe23(%rip),%rsi
lea    0xde7(%rip),%rdx
lea    0xde9(%rip),%r8
xor    %eax,%eax
movq   $0x0,(%rsp)
call   1080 <execl@plt>
add    $0x320,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spawnchild>:
push   %rbx
sub    $0x290,%rsp
mov    %rdi,%rbx
lea    0xe7e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
movaps 0xfdd(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xfbe(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xfa2(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xf86(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xf6a(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xf4e(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xf32(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xf16(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xe80(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strstr@plt>
mov    0x2ddb(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     1299 <spawnchild+0x129>
lea    0xe22(%rip),%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
lea    0xe39(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe37(%rip),%rdi
call   1040 <system@plt>
xor    %edi,%edi
call   1060 <close@plt>
mov    $0x1,%edi
call   1060 <close@plt>
mov    $0x2,%edi
call   1060 <close@plt>
movsbl 0x10(%rsp),%esi
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpb   $0x0,0x10(%rsp)
je     12b0 <spawnchild+0x140>
movq   $0x0,(%rsp)
lea    0xe28(%rip),%rsi
lea    0xe31(%rip),%rdx
lea    0xe33(%rip),%r8
lea    0x90(%rsp),%rdi
jmp    12e0 <spawnchild+0x170>
lea    0xd6c(%rip),%rsi
mov    %rbx,%rdx
add    $0x290,%rsp
pop    %rbx
jmp    1070 <fprintf@plt>
lea    0xe37(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,(%rsp)
lea    0xe00(%rip),%rdi
lea    0xe0f(%rip),%rsi
lea    0xde0(%rip),%rdx
lea    0xde2(%rip),%r8
mov    %rbx,%rcx
mov    %rbx,%r9
call   1080 <execl@plt>
add    $0x290,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"file is %s\0A\00"
@__const.spawnchild.program_path = [128 x i8] c"/opt/ssloffloader2.0/ssloffloader -f\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.spawnchild.config_path = [128 x i8] c"/opt/ssloffloader2.0/ssloffload.cfg\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [29 x i8] c"/opt/cloudport5.4/app.coffee\00"
@stderr = global i32 0
@.str.2 = [44 x i8] c"skipping %s, not a VPN configuration file!\0A\00"
@.str.3 = [38 x i8] c"Starting a child VPN process with %s\0A\00"
@.str.4 = [17 x i8] c"preogram path%s\0A\00"
@.str.5 = [36 x i8] c"coffee /opt/cloudport5.4/app.coffee\00"
@.str.6 = [22 x i8] c"befor program path%d\0A\00"
@.str.7 = [16 x i8] c"loadbalancer -f\00"
@.str.8 = [9 x i8] c"--config\00"
@.str.9 = [9 x i8] c"--syslog\00"
@.str.10 = [13 x i8] c"inside else\0A\00"
@.str.11 = [22 x i8] c"/opt/loadbalancer2.0/\00"
@.str.12 = [13 x i8] c"loadbalancer\00"
define void @spawnchild(i8* %0) {
%2 = alloca i8*
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = alloca [512 x i8]
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = bitcast [128 x i8]* %3 to i8*
%9 = bitcast [128 x i8]* %4 to i8*
%10 = load i8*, i8** %2
%11 = call i32 @strstr(i8* %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %2
%16 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %44
17: ; preds = %1
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %2
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %21)
%23 = call i32 @system(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @close(i32 0)
%25 = call i32 @close(i32 1)
%26 = call i32 @close(i32 2)
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%32 = load i8, i8* %31
%33 = icmp ne i8 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %17
%35 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%36 = load i8*, i8** %2
%37 = load i8*, i8** %2
%38 = call i32 @execl(i8* %35, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* %36, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %37, i8* null)
br label %44
39: ; preds = %17
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%41 = load i8*, i8** %2
%42 = load i8*, i8** %2
%43 = call i32 @execl(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %42, i8* null)
br label %44
44: ; preds = %13, %39, %34
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"file is %s\0A\00"
@__const.spawnchild.program_path = [128 x i8] c"/opt/ssloffloader2.0/ssloffloader -f\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [29 x i8] c"/opt/cloudport5.4/app.coffee\00"
@stderr = global i32 0
@.str.2 = [44 x i8] c"skipping %s, not a VPN configuration file!\0A\00"
@.str.3 = [38 x i8] c"Starting a child VPN process with %s\0A\00"
@.str.4 = [17 x i8] c"preogram path%s\0A\00"
@.str.5 = [36 x i8] c"coffee /opt/cloudport5.4/app.coffee\00"
@.str.6 = [22 x i8] c"befor program path%d\0A\00"
@.str.7 = [16 x i8] c"loadbalancer -f\00"
@.str.8 = [9 x i8] c"--config\00"
@.str.9 = [9 x i8] c"--syslog\00"
@.str.11 = [22 x i8] c"/opt/loadbalancer2.0/\00"
@.str.12 = [13 x i8] c"loadbalancer\00"
@str = [12 x i8] c"inside else\00"
define void @spawnchild(i8* %0) {
%2 = alloca [128 x i8]
%3 = alloca [512 x i8]
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @strstr(i8* %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
%9 = load i32, i32* @stderr
br i1 %8, label %10, label %12
10: ; preds = %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %29
12: ; preds = %1
%13 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%15 = call i32 @system(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @close(i32 0)
%17 = call i32 @close(i32 1)
%18 = call i32 @close(i32 2)
%19 = load i8, i8* %5
%20 = sext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %20)
%22 = load i8, i8* %5
%23 = icmp eq i8 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %12
%25 = call i32 @execl(i8* %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %0, i8* null)
br label %29
26: ; preds = %12
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%28 = call i32 @execl(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %0, i8* null)
br label %29
29: ; preds = %24, %26, %10
ret void
}