#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 *);
int /*<<< orphan*/ system(char *);
void spawnchild(char *file) {
  char program_path[128] = "/opt/openvpn2.3.4/openvpn";
  char config_path[128] = "/opt/openvpn2.3.4/server.conf";
  char program[512];
  if (!strstr(file, "/opt/openvpn2.3.4/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);
  system(
      "sudo touch /config/openvpn/on && rm /config/openvpn/off >/dev/null 2&1");
  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.3.4/openvpn");
    execl(program, "openvpn", "--config", file, "--syslog", file, (char *)NULL);
  } else {
    printf("inside else\n");
    execl("/opt/openvpn2.3.4/", "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    0xe63(%rip),%rsi
mov    $0x80,%edx
call   1070 <memcpy@plt>
lea    -0x110(%rbp),%rdi
lea    0xecb(%rip),%rsi
mov    $0x80,%edx
call   1070 <memcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xf36(%rip),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%eax
jne    11f6 <spawnchild+0x76>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xf32(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1324 <spawnchild+0x1a4>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xf40(%rip),%rsi
call   1060 <fprintf@plt>
lea    -0x90(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0x110(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x0,%al
call   1090 <execl@plt>
lea    0xf3a(%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    0xf53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpb   $0x0,-0x90(%rbp)
je     12e1 <spawnchild+0x161>
lea    0xf4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x310(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xf47(%rip),%rsi
lea    0xf45(%rip),%rcx
call   1080 <sprintf@plt>
lea    -0x310(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x8(%rbp),%r9
lea    0xf3c(%rip),%rsi
lea    0xf3d(%rip),%rdx
lea    0xf3f(%rip),%r8
xor    %eax,%eax
movq   $0x0,(%rsp)
mov    $0x0,%al
call   1090 <execl@plt>
jmp    1324 <spawnchild+0x1a4>
lea    0xf2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rcx
mov    -0x8(%rbp),%r9
lea    0xf22(%rip),%rdi
lea    0xef4(%rip),%rsi
lea    0xef5(%rip),%rdx
lea    0xef7(%rip),%r8
xor    %eax,%eax
movq   $0x0,(%rsp)
mov    $0x0,%al
call   1090 <execl@plt>
add    $0x320,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spawnchild>:
push   %r14
push   %rbx
sub    $0x318,%rsp
mov    %rdi,%rbx
movaps 0xedc(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xebd(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xea1(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe85(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe69(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe4d(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe31(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe15(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xef9(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movaps 0xebb(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xe7d(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xe5e(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xe3f(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe20(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
lea    0xe91(%rip),%rsi
call   10a0 <strstr@plt>
mov    0x2d65(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     133f <spawnchild+0x1bf>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
lea    0x10(%rsp),%rdi
lea    0x90(%rsp),%rdx
mov    %rdi,%rsi
xor    %ecx,%ecx
xor    %eax,%eax
call   1090 <execl@plt>
lea    0xebc(%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    0xed7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpb   $0x0,0x10(%rsp)
je     1358 <spawnchild+0x1d8>
lea    0xf28(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rsi
lea    0xeca(%rip),%rcx
lea    0x110(%rsp),%r14
lea    0x10(%rsp),%rdx
mov    %r14,%rdi
call   1080 <sprintf@plt>
movq   $0x0,(%rsp)
lea    0xeb8(%rip),%rsi
lea    0xeb9(%rip),%rdx
lea    0xebb(%rip),%r8
mov    %r14,%rdi
jmp    1388 <spawnchild+0x208>
lea    0xdd8(%rip),%rsi
mov    %rbx,%rdx
add    $0x318,%rsp
pop    %rbx
pop    %r14
jmp    1070 <fprintf@plt>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,(%rsp)
lea    0xe8b(%rip),%rdi
lea    0xe6a(%rip),%rsi
lea    0xe6b(%rip),%rdx
lea    0xe6d(%rip),%r8
mov    %rbx,%rcx
mov    %rbx,%r9
xor    %eax,%eax
call   1090 <execl@plt>
add    $0x318,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.spawnchild.program_path = [128 x i8] c"/opt/openvpn2.3.4/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"
@__const.spawnchild.config_path = [128 x i8] c"/opt/openvpn2.3.4/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"
@.str = [30 x i8] c"/opt/openvpn2.3.4/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 = [71 x i8] c"sudo touch /config/openvpn/on && rm /config/openvpn/off >/dev/null 2&1\00"
@.str.4 = [22 x i8] c"befor program path%d\0A\00"
@.str.5 = [21 x i8] c"inside program_path\0A\00"
@.str.6 = [5 x i8] c"%s%s\00"
@.str.7 = [26 x i8] c"/opt/openvpn2.3.4/openvpn\00"
@.str.8 = [8 x i8] c"openvpn\00"
@.str.9 = [9 x i8] c"--config\00"
@.str.10 = [9 x i8] c"--syslog\00"
@.str.11 = [13 x i8] c"inside else\0A\00"
@.str.12 = [19 x i8] c"/opt/openvpn2.3.4/\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 ([30 x i8], [30 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 %48
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 @system(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, 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.4, 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 %43
34: ; preds = %15
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%37 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%38 = call i32 @sprintf(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %37, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%40 = load i8*, i8** %2
%41 = load i8*, i8** %2
%42 = call i32 (i8*, i8*, i8*, i8*, ...) @execl(i8* %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %40, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8* %41, i8* null)
br label %48
43: ; preds = %15
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
%45 = load i8*, i8** %2
%46 = load i8*, i8** %2
%47 = call i32 (i8*, i8*, i8*, i8*, ...) @execl(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %45, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8* %46, i8* null)
br label %48
48: ; preds = %11, %43, %34
ret void
}

LLVM IR (-O2):
@__const.spawnchild.program_path = [128 x i8] c"/opt/openvpn2.3.4/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"
@__const.spawnchild.config_path = [128 x i8] c"/opt/openvpn2.3.4/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"
@.str = [30 x i8] c"/opt/openvpn2.3.4/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 = [71 x i8] c"sudo touch /config/openvpn/on && rm /config/openvpn/off >/dev/null 2&1\00"
@.str.4 = [22 x i8] c"befor program path%d\0A\00"
@.str.6 = [5 x i8] c"%s%s\00"
@.str.7 = [26 x i8] c"/opt/openvpn2.3.4/openvpn\00"
@.str.8 = [8 x i8] c"openvpn\00"
@.str.9 = [9 x i8] c"--config\00"
@.str.10 = [9 x i8] c"--syslog\00"
@.str.12 = [19 x i8] c"/opt/openvpn2.3.4/\00"
@str = [12 x i8] c"inside else\00"
@str.13 = [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 ([30 x i8], [30 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 %32
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 @system(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @close(i32 0)
%18 = call i32 @close(i32 1)
%19 = call i32 @close(i32 2)
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = load i8, i8* %5
%24 = icmp eq i8 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %13
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.13, i64 0, i64 0))
%27 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%28 = call i32 (i8*, i8*, i8*, i8*, ...) @execl(i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8* %0, i8* null)
br label %32
29: ; preds = %13
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%31 = call i32 (i8*, i8*, i8*, i8*, ...) @execl(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8* %0, i8* null)
br label %32
32: ; preds = %25, %29, %11
ret void
}