#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 */
char *getenv(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ system(char *);
void ExecCfg(char *arg) {
  char cfg[256];
  struct stat buf;
  strcpy(cfg, "./cfgDFXVideo");
  if (stat(cfg, &buf) != -1) {
    strcat(cfg, " ");
    strcat(cfg, arg);
    system(cfg);
    return;
  }
  strcpy(cfg, "./cfg/cfgDFXVideo");
  if (stat(cfg, &buf) != -1) {
    strcat(cfg, " ");
    strcat(cfg, arg);
    system(cfg);
    return;
  }
  sprintf(cfg, "%s/.pcsx/plugins/cfg/cfgDFXVideo", getenv("HOME"));
  if (stat(cfg, &buf) != -1) {
    strcat(cfg, " ");
    strcat(cfg, arg);
    system(cfg);
    return;
  }
  printf("ERROR: cfgDFXVideo 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    0xe73(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x110(%rbp),%rdi
lea    -0x118(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0xffffffff,%eax
je     11e2 <ExecCfg+0x72>
lea    -0x110(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x110(%rbp),%rdi
call   1050 <system@plt>
jmp    12d1 <ExecCfg+0x161>
lea    -0x110(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x110(%rbp),%rdi
lea    -0x118(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0xffffffff,%eax
je     1245 <ExecCfg+0xd5>
lea    -0x110(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x110(%rbp),%rdi
call   1050 <system@plt>
jmp    12d1 <ExecCfg+0x161>
lea    -0x110(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    0xde9(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x120(%rbp),%rdi
mov    %rax,%rdx
lea    0xdb2(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x118(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0xffffffff,%eax
je     12c5 <ExecCfg+0x155>
lea    -0x110(%rbp),%rdi
lea    0xd6f(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x110(%rbp),%rdi
call   1050 <system@plt>
jmp    12d1 <ExecCfg+0x161>
lea    0xd7c(%rip),%rdi
call   1060 <printf@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ExecCfg>:
push   %r14
push   %rbx
sub    $0x118,%rsp
mov    %rdi,%r14
lea    0xe7c(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <stat@plt>
cmp    $0xffffffff,%eax
jne    11fe <ExecCfg+0x8e>
lea    0xe66(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <stat@plt>
cmp    $0xffffffff,%eax
jne    11fe <ExecCfg+0x8e>
lea    0xe73(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe46(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %rax,%rdx
call   1090 <sprintf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <stat@plt>
cmp    $0xffffffff,%eax
je     1230 <ExecCfg+0xc0>
lea    0xe09(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe11(%rip),%rdi
call   1050 <puts@plt>
jmp    1225 <ExecCfg+0xb5>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [14 x i8] c"./cfgDFXVideo\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [18 x i8] c"./cfg/cfgDFXVideo\00"
@.str.3 = [33 x i8] c"%s/.pcsx/plugins/cfg/cfgDFXVideo\00"
@.str.4 = [5 x i8] c"HOME\00"
@.str.5 = [36 x i8] c"ERROR: cfgDFXVideo 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 ([14 x i8], [14 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 %18
10: ; preds = %1
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = call i32 @strcat(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%14 = load i8*, i8** %2
%15 = call i32 @strcat(i8* %13, i8* %14)
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%17 = call i32 @system(i8* %16)
br label %49
18: ; preds = %1
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%22 = call i32 @stat(i8* %21, %struct.stat* %4)
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %32
24: ; preds = %18
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%28 = load i8*, i8** %2
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%31 = call i32 @system(i8* %30)
br label %49
32: ; preds = %18
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%34 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%35 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%37 = call i32 @stat(i8* %36, %struct.stat* %4)
%38 = icmp ne i32 %37, -1
br i1 %38, label %39, label %47
39: ; preds = %32
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%41 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%43 = load i8*, i8** %2
%44 = call i32 @strcat(i8* %42, i8* %43)
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%46 = call i32 @system(i8* %45)
br label %49
47: ; preds = %32
%48 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %47, %39, %24, %10
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [14 x i8] c"./cfgDFXVideo\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [18 x i8] c"./cfg/cfgDFXVideo\00"
@.str.3 = [33 x i8] c"%s/.pcsx/plugins/cfg/cfgDFXVideo\00"
@.str.4 = [5 x i8] c"HOME\00"
@str = [35 x i8] c"ERROR: cfgDFXVideo file not found!\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 ([14 x i8], [14 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 %13, label %9
9: ; preds = %1
%10 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @strcat(i8* %4, i8* %0)
%12 = call i32 @system(i8* %4)
br label %32
13: ; preds = %1
%14 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @stat(i8* %4, %struct.stat* %3)
%16 = icmp eq i32 %15, -1
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @strcat(i8* %4, i8* %0)
%20 = call i32 @system(i8* %4)
br label %32
21: ; preds = %13
%22 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = call i32 @stat(i8* %4, %struct.stat* %3)
%25 = icmp eq i32 %24, -1
br i1 %25, label %30, label %26
26: ; preds = %21
%27 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @strcat(i8* %4, i8* %0)
%29 = call i32 @system(i8* %4)
br label %32
30: ; preds = %21
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %30, %26, %17, %9
ret void
}