#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/ssloffloader2.0/ssloffload.cfg")) {
    fprintf(stderr, "skipping %s, not a VPN configuration file!\n", file);
    return;
  }
  system("/opt/ssloffloader2.0/ssloffloader -f "
         "/opt/ssloffloader2.0/ssloffload.cfg -d");
  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    0xf71(%rip),%rsi
mov    $0x80,%edx
call   1070 <memcpy@plt>
lea    -0x110(%rbp),%rdi
lea    0xfd9(%rip),%rsi
mov    $0x80,%edx
call   1070 <memcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xe40(%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    0xe42(%rip),%rsi
call   1060 <fprintf@plt>
jmp    12ba <spawnchild+0x14a>
lea    0xe5d(%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    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpb   $0x0,-0x90(%rbp)
je     1279 <spawnchild+0x109>
lea    -0x310(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x8(%rbp),%r9
lea    0xe67(%rip),%rsi
lea    0xe70(%rip),%rdx
lea    0xe72(%rip),%r8
xor    %eax,%eax
movq   $0x0,(%rsp)
call   1080 <execl@plt>
jmp    12ba <spawnchild+0x14a>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rcx
mov    -0x8(%rbp),%r9
lea    0xe57(%rip),%rdi
lea    0xe66(%rip),%rsi
lea    0xe2a(%rip),%rdx
lea    0xe2c(%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    $0x210,%rsp
mov    %rdi,%rbx
lea    0xe8e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %eax,%eax
je     11ff <spawnchild+0x9f>
lea    0xec6(%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>
lea    0xeeb(%rip),%rdi
mov    $0x2f,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movq   $0x0,(%rsp)
lea    0xee6(%rip),%rsi
lea    0xeef(%rip),%rdx
lea    0xef1(%rip),%r8
lea    0x10(%rsp),%rdi
mov    %rbx,%rcx
mov    %rbx,%r9
call   1070 <execl@plt>
add    $0x210,%rsp
pop    %rbx
ret
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xe21(%rip),%rsi
mov    %rbx,%rdx
add    $0x210,%rsp
pop    %rbx
jmp    1060 <fprintf@plt>

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 = [36 x i8] c"/opt/ssloffloader2.0/ssloffload.cfg\00"
@stderr = global i32 0
@.str.2 = [44 x i8] c"skipping %s, not a VPN configuration file!\0A\00"
@.str.3 = [76 x i8] c"/opt/ssloffloader2.0/ssloffloader -f /opt/ssloffloader2.0/ssloffload.cfg -d\00"
@.str.4 = [22 x i8] c"befor program path%d\0A\00"
@.str.5 = [16 x i8] c"loadbalancer -f\00"
@.str.6 = [9 x i8] c"--config\00"
@.str.7 = [9 x i8] c"--syslog\00"
@.str.8 = [13 x i8] c"inside else\0A\00"
@.str.9 = [22 x i8] c"/opt/loadbalancer2.0/\00"
@.str.10 = [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 ([36 x i8], [36 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 %39
17: ; preds = %1
%18 = call i32 @system(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @close(i32 0)
%20 = call i32 @close(i32 1)
%21 = call i32 @close(i32 2)
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%27 = load i8, i8* %26
%28 = icmp ne i8 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %17
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%31 = load i8*, i8** %2
%32 = load i8*, i8** %2
%33 = call i32 @execl(i8* %30, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %32, i8* null)
br label %39
34: ; preds = %17
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%36 = load i8*, i8** %2
%37 = load i8*, i8** %2
%38 = call i32 @execl(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %36, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %37, i8* null)
br label %39
39: ; preds = %13, %34, %29
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"file is %s\0A\00"
@.str.1 = [36 x i8] c"/opt/ssloffloader2.0/ssloffload.cfg\00"
@stderr = global i32 0
@.str.2 = [44 x i8] c"skipping %s, not a VPN configuration file!\0A\00"
@.str.3 = [76 x i8] c"/opt/ssloffloader2.0/ssloffloader -f /opt/ssloffloader2.0/ssloffload.cfg -d\00"
@.str.4 = [22 x i8] c"befor program path%d\0A\00"
@.str.5 = [16 x i8] c"loadbalancer -f\00"
@.str.6 = [9 x i8] c"--config\00"
@.str.7 = [9 x i8] c"--syslog\00"
define void @spawnchild(i8* %0) {
%2 = alloca [512 x i8]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @strstr(i8* %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %17
10: ; preds = %1
%11 = tail call i32 @system(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i32 @close(i32 0)
%13 = tail call i32 @close(i32 1)
%14 = tail call i32 @close(i32 2)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 47)
%16 = call i32 @execl(i8* %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %0, i8* null)
br label %17
17: ; preds = %10, %7
ret void
}