#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 *, ...);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strstr(char *, char *);
void spawnchild(char *file) {
  char program_path[128] = "/opt/openvpn2.0/openvpn";
  char config_path[128] = "/opt/openvpn2.0/server.conf";
  char program[512];
  if (!strstr(file, "/opt/openvpn2.0/server.conf")) {
    fprintf(stderr, "skipping %s, not a VPN configuration file!\n", file);
    return;
  }
  fprintf(stderr, "Starting a child VPN process with %s\n", file);
  execl(program_path, program_path, config_path, (char *)NULL);
  close(0);
  close(1);
  close(2);
  printf("befor program path%d\n", program_path[0]);
  if (program_path[0]) {
    printf("inside program_path\n");
    sprintf(program, "%s%s", program_path, "/opt/openvpn2.0/openvpn");
    execl(program, "openvpn", "--config", file, "--syslog", file, (char *)NULL);
  } else {
    printf("inside else\n");
    execl("/opt/openvpn2.0/", "openvpn", "--config", file, "--syslog", file,
          (char *)NULL);
  }
}


x86 assembly (clang, -O0):
<spawnchild>:
push   %rbp
mov    %rsp,%rbp
sub    $0x320,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xe73(%rip),%rsi
mov    $0x80,%edx
call   1060 <memcpy@plt>
lea    -0x110(%rbp),%rdi
lea    0xedb(%rip),%rsi
mov    $0x80,%edx
call   1060 <memcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xf46(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%eax
jne    11e6 <spawnchild+0x76>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xf40(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1308 <spawnchild+0x198>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xf4e(%rip),%rsi
call   1050 <fprintf@plt>
lea    -0x90(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0x110(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x0,%al
call   1080 <execl@plt>
xor    %edi,%edi
call   1040 <close@plt>
mov    $0x1,%edi
call   1040 <close@plt>
mov    $0x2,%edi
call   1040 <close@plt>
movsbl -0x90(%rbp),%esi
lea    0xf26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpb   $0x0,-0x90(%rbp)
je     12c5 <spawnchild+0x155>
lea    0xf21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x310(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xf1a(%rip),%rsi
lea    0xf18(%rip),%rcx
call   1070 <sprintf@plt>
lea    -0x310(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x8(%rbp),%r9
lea    0xf0d(%rip),%rsi
lea    0xf0e(%rip),%rdx
lea    0xf10(%rip),%r8
xor    %eax,%eax
movq   $0x0,(%rsp)
mov    $0x0,%al
call   1080 <execl@plt>
jmp    1308 <spawnchild+0x198>
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rcx
mov    -0x8(%rbp),%r9
lea    0xef3(%rip),%rdi
lea    0xec5(%rip),%rsi
lea    0xec6(%rip),%rdx
lea    0xec8(%rip),%r8
xor    %eax,%eax
movq   $0x0,(%rsp)
mov    $0x0,%al
call   1080 <execl@plt>
add    $0x320,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spawnchild>:
push   %r14
push   %rbx
sub    $0x318,%rsp
mov    %rdi,%rbx
movaps 0xeec(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xecd(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe95(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe79(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe5d(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe41(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe25(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xf09(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movaps 0xeea(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movaps 0xecb(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xe8d(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xe6e(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xe4f(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe30(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
lea    0xea1(%rip),%rsi
call   1090 <strstr@plt>
mov    0x2d75(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     1323 <spawnchild+0x1b3>
lea    0xecc(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
lea    0x10(%rsp),%rdi
lea    0x90(%rsp),%rdx
mov    %rdi,%rsi
xor    %ecx,%ecx
xor    %eax,%eax
call   1080 <execl@plt>
xor    %edi,%edi
call   1050 <close@plt>
mov    $0x1,%edi
call   1050 <close@plt>
mov    $0x2,%edi
call   1050 <close@plt>
movsbl 0x10(%rsp),%esi
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpb   $0x0,0x10(%rsp)
je     133c <spawnchild+0x1cc>
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rsi
lea    0xe9d(%rip),%rcx
lea    0x110(%rsp),%r14
lea    0x10(%rsp),%rdx
mov    %r14,%rdi
call   1070 <sprintf@plt>
movq   $0x0,(%rsp)
lea    0xe89(%rip),%rsi
lea    0xe8a(%rip),%rdx
lea    0xe8c(%rip),%r8
mov    %r14,%rdi
jmp    136c <spawnchild+0x1fc>
lea    0xdf2(%rip),%rsi
mov    %rbx,%rdx
add    $0x318,%rsp
pop    %rbx
pop    %r14
jmp    1060 <fprintf@plt>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,(%rsp)
lea    0xe5c(%rip),%rdi
lea    0xe3b(%rip),%rsi
lea    0xe3c(%rip),%rdx
lea    0xe3e(%rip),%r8
mov    %rbx,%rcx
mov    %rbx,%r9
xor    %eax,%eax
call   1080 <execl@plt>
add    $0x318,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.spawnchild.program_path = [128 x i8] c"/opt/openvpn2.0/openvpn\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\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/openvpn2.0/server.conf\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\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 = [28 x i8] c"/opt/openvpn2.0/server.conf\00"
@stderr = global i32 0
@.str.1 = [44 x i8] c"skipping %s, not a VPN configuration file!\0A\00"
@.str.2 = [38 x i8] c"Starting a child VPN process with %s\0A\00"
@.str.3 = [22 x i8] c"befor program path%d\0A\00"
@.str.4 = [21 x i8] c"inside program_path\0A\00"
@.str.5 = [5 x i8] c"%s%s\00"
@.str.6 = [24 x i8] c"/opt/openvpn2.0/openvpn\00"
@.str.7 = [8 x i8] c"openvpn\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 = [17 x i8] c"/opt/openvpn2.0/\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 = bitcast [128 x i8]* %3 to i8*
%7 = bitcast [128 x i8]* %4 to i8*
%8 = load i8*, i8** %2
%9 = call i32 @strstr(i8* %8, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %2
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %47
15: ; preds = %1
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %2
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%22 = call i32 (i8*, i8*, i8*, i8*, ...) @execl(i8* %19, i8* %20, i8* %21, i8* null)
%23 = call i32 @close(i32 0)
%24 = call i32 @close(i32 1)
%25 = call i32 @close(i32 2)
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%31 = load i8, i8* %30
%32 = icmp ne i8 %31, 0
br i1 %32, label %33, label %42
33: ; preds = %15
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%35 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%37 = call i32 @sprintf(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %36, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%38 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%39 = load i8*, i8** %2
%40 = load i8*, i8** %2
%41 = call i32 (i8*, i8*, i8*, i8*, ...) @execl(i8* %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* %39, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %40, i8* null)
br label %47
42: ; preds = %15
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
%44 = load i8*, i8** %2
%45 = load i8*, i8** %2
%46 = call i32 (i8*, i8*, i8*, i8*, ...) @execl(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* %44, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %45, i8* null)
br label %47
47: ; preds = %11, %42, %33
ret void
}

LLVM IR (-O2):
@__const.spawnchild.program_path = [128 x i8] c"/opt/openvpn2.0/openvpn\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\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/openvpn2.0/server.conf\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\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 = [28 x i8] c"/opt/openvpn2.0/server.conf\00"
@stderr = global i32 0
@.str.1 = [44 x i8] c"skipping %s, not a VPN configuration file!\0A\00"
@.str.2 = [38 x i8] c"Starting a child VPN process with %s\0A\00"
@.str.3 = [22 x i8] c"befor program path%d\0A\00"
@.str.5 = [5 x i8] c"%s%s\00"
@.str.6 = [24 x i8] c"/opt/openvpn2.0/openvpn\00"
@.str.7 = [8 x i8] c"openvpn\00"
@.str.8 = [9 x i8] c"--config\00"
@.str.9 = [9 x i8] c"--syslog\00"
@.str.11 = [17 x i8] c"/opt/openvpn2.0/\00"
@str = [12 x i8] c"inside else\00"
@str.12 = [20 x i8] c"inside program_path\00"
define void @spawnchild(i8* %0) {
%2 = alloca [128 x i8]
%3 = alloca [128 x i8]
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = tail call i32 @strstr(i8* %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
%10 = load i32, i32* @stderr
br i1 %9, label %11, label %13
11: ; preds = %1
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %31
13: ; preds = %1
%14 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%15 = call i32 (i8*, i8*, i8*, i8*, ...) @execl(i8* %5, i8* %5, i8* %6, i8* null)
%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.3, i64 0, i64 0), i32 %20)
%22 = load i8, i8* %5
%23 = icmp eq i8 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %13
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.12, i64 0, i64 0))
%26 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%27 = call i32 (i8*, i8*, i8*, i8*, ...) @execl(i8* %7, i8* getelementptr inbounds ([8 x i8], [8 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 %31
28: ; preds = %13
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%30 = call i32 (i8*, i8*, i8*, i8*, ...) @execl(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 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 %31
31: ; preds = %24, %28, %11
ret void
}