#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ execl(char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
void ExecCfg(char *arg) {
  char cfg[256];
  struct stat buf;
  strcpy(cfg, "./cfgDFCdrom");
  if (stat(cfg, &buf) != -1) {
    if (fork() == 0) {
      execl(cfg, "cfgDFCdrom", arg, NULL);
      exit(0);
    }
    return;
  }
  strcpy(cfg, "./cfg/DFCdrom");
  if (stat(cfg, &buf) != -1) {
    if (fork() == 0) {
      execl(cfg, "cfgDFCdrom", arg, NULL);
      exit(0);
    }
    return;
  }
  fprintf(stderr, "cfgDFCdrom file not found!\n");
}


x86 assembly (clang, -O0):
<ExecCfg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rdi
lea    -0x118(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
je     11d6 <ExecCfg+0x76>
mov    $0x0,%al
call   1080 <fork@plt>
cmp    $0x0,%rax
jne    11d1 <ExecCfg+0x71>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe41(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1070 <execl@plt>
xor    %edi,%edi
call   1060 <exit@plt>
jmp    1252 <ExecCfg+0xf2>
lea    -0x110(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rdi
lea    -0x118(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
je     123d <ExecCfg+0xdd>
mov    $0x0,%al
call   1080 <fork@plt>
cmp    $0x0,%rax
jne    1238 <ExecCfg+0xd8>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xdda(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1070 <execl@plt>
xor    %edi,%edi
call   1060 <exit@plt>
jmp    1252 <ExecCfg+0xf2>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ExecCfg>:
push   %r14
push   %rbx
sub    $0x118,%rsp
mov    %rdi,%r14
lea    0xe8c(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
jne    11b9 <ExecCfg+0x59>
lea    0xe73(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
je     11d0 <ExecCfg+0x70>
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
je     11e7 <ExecCfg+0x87>
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11c5 <ExecCfg+0x65>
lea    0xe14(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1070 <execl@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [13 x i8] c"./cfgDFCdrom\00"
@.str.1 = [11 x i8] c"cfgDFCdrom\00"
@.str.2 = [14 x i8] c"./cfg/DFCdrom\00"
@stderr = global i32 0
@.str.3 = [28 x i8] c"cfgDFCdrom file not found!\0A\00"
define void @ExecCfg(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca %struct.stat
store i8* %0, i8** %2
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = call i32 @stat(i8* %7, %struct.stat* %4)
%9 = icmp ne i32 %8, -1
br i1 %9, label %10, label %19
10: ; preds = %1
%11 = call i64 (...) @fork()
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%15 = load i8*, i8** %2
%16 = call i32 @execl(i8* %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32* null)
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %10
br label %37
19: ; preds = %1
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%23 = call i32 @stat(i8* %22, %struct.stat* %4)
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %34
25: ; preds = %19
%26 = call i64 (...) @fork()
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%30 = load i8*, i8** %2
%31 = call i32 @execl(i8* %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %30, i32* null)
%32 = call i32 @exit(i32 0)
unreachable
33: ; preds = %25
br label %37
34: ; preds = %19
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %34, %33, %18
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [13 x i8] c"./cfgDFCdrom\00"
@.str.1 = [11 x i8] c"cfgDFCdrom\00"
@.str.2 = [14 x i8] c"./cfg/DFCdrom\00"
@stderr = global i32 0
@.str.3 = [28 x i8] c"cfgDFCdrom file not found!\0A\00"
define void @ExecCfg(i8* %0) {
%2 = alloca [256 x i8]
%3 = alloca %struct.stat
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = bitcast %struct.stat* %3 to i8*
%6 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @stat(i8* %4, %struct.stat* %3)
%8 = icmp eq i32 %7, -1
br i1 %8, label %15, label %9
9: ; preds = %1
%10 = call i64 (...) @fork()
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = call i32 @execl(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32* null)
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %1
%16 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @stat(i8* %4, %struct.stat* %3)
%18 = icmp eq i32 %17, -1
br i1 %18, label %25, label %19
19: ; preds = %15
%20 = call i64 (...) @fork()
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = call i32 @execl(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32* null)
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %15
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %19, %9, %25
ret void
}