#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 EXIT_SUCCESS;
int /*<<< orphan*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int show_error(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
scalar_t__ system(char *);
int extract_dsdt(char destination[], int disassemble) {
  char cmd[300];
  char root[] = "/tmp/helper";
  sprintf(cmd, "mkdir %s", root);
  system(cmd);
  sprintf(cmd, "mkdir %s", destination);
  system(cmd);
  printf("Downloading essential files...\n");
  sprintf(cmd, "%s/patchmatic.zip", root);
  if (access(cmd, F_OK) != 0) {
    sprintf(cmd,
            "curl -sL "
            "https://bitbucket.org/RehabMan/os-x-maciasl-patchmatic/downloads/"
            "RehabMan-patchmatic-2015-0107.zip > %s/patchmatic.zip",
            root);
    system(cmd);
  }
  sprintf(cmd, "unzip %s/patchmatic.zip -d %s", root, destination);
  system(cmd);
  if (disassemble) {
    sprintf(cmd, "%s/iasl.zip", root);
    system(cmd);
    if (access(cmd, F_OK) != 0) {
      sprintf(
          cmd,
          "curl -sL https://bitbucket.org/RehabMan/acpica/downloads/iasl.zip > "
          "%s/iasl.zip",
          root);
      system(cmd);
    }
    sprintf(cmd, "unzip %s/iasl.zip -d %s", root, destination);
    system(cmd);
  }
  printf("Done.\nExtracting DSDT/SSDTs...\n");
  sprintf(cmd, "cd %s && ./patchmatic -extract && rm patchmatic", destination);
  if (system(cmd) != 0) {
    sprintf(cmd, "rm -r %s", destination);
    system(cmd);
    return show_error("Extraction failed!");
  }
  printf("Done.\n");
  if (disassemble) {
    printf("Disassembling files...\n");
    sprintf(cmd,
            "echo -e \"External(_SB_.PCI0.PEG0.PEGP.SGPO, MethodObj, "
            "2)\nExternal(_SB_.PCI0.LPCB.H_EC.ECWT, MethodObj, "
            "2)\nExternal(_SB_.PCI0.LPCB.H_EC.ECRD, MethodObj, "
            "1)\nExternal(_GPE.MMTB, MethodObj, 0)\" > %s/refs.txt",
            destination);
    system(cmd);
    sprintf(
        cmd,
        "cd %s && ./iasl -da -dl -fe refs.txt *.aml && rm iasl refs.txt *.aml",
        destination);
    if (system(cmd) != 0)
      return show_error(
          "Disassemble failed! Mark the pervious line for possible errors.");
    printf("Done.\n");
  }
  printf("DSDT/SSDTs Location: %s\n", destination);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<extract_dsdt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x14c(%rbp)
mov    0xe92(%rip),%eax
mov    %eax,-0x144(%rbp)
lea    -0x140(%rbp),%rdi
lea    -0x14c(%rbp),%rdx
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1030 <system@plt>
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1030 <system@plt>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x140(%rbp),%rdi
lea    -0x14c(%rbp),%rdx
lea    0xeb7(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
mov    0x2dcf(%rip),%rax
mov    (%rax),%esi
call   1060 <access@plt>
cmp    $0x0,%rax
je     123a <extract_dsdt+0xea>
lea    -0x140(%rbp),%rdi
lea    -0x14c(%rbp),%rdx
lea    0xe0e(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1030 <system@plt>
lea    -0x140(%rbp),%rdi
lea    -0x14c(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1030 <system@plt>
cmpl   $0x0,-0x14(%rbp)
je     130b <extract_dsdt+0x1bb>
lea    -0x140(%rbp),%rdi
lea    -0x14c(%rbp),%rdx
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1030 <system@plt>
lea    -0x140(%rbp),%rdi
mov    0x2d2a(%rip),%rax
mov    (%rax),%esi
call   1060 <access@plt>
cmp    $0x0,%rax
je     12df <extract_dsdt+0x18f>
lea    -0x140(%rbp),%rdi
lea    -0x14c(%rbp),%rdx
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1030 <system@plt>
lea    -0x140(%rbp),%rdi
lea    -0x14c(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe2b(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1030 <system@plt>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe30(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     1381 <extract_dsdt+0x231>
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1030 <system@plt>
lea    0xe20(%rip),%rdi
call   1050 <show_error@plt>
mov    %eax,-0x4(%rbp)
jmp    143b <extract_dsdt+0x2eb>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
je     141d <extract_dsdt+0x2cd>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1030 <system@plt>
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeb5(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     140f <extract_dsdt+0x2bf>
lea    0xed6(%rip),%rdi
call   1050 <show_error@plt>
mov    %eax,-0x4(%rbp)
jmp    143b <extract_dsdt+0x2eb>
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2baa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_dsdt>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x140,%rsp
mov    %esi,%r14d
mov    %rdi,%r15
movabs $0x6c65682f706d742f,%rax
68 65 6c
mov    %rax,(%rsp)
movl   $0x726570,0x8(%rsp)
lea    0xe7a(%rip),%rbx
lea    0x10(%rsp),%rbp
mov    %rsp,%r12
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <system@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <system@plt>
lea    0x1101(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rsi
mov    %rbp,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    0x2ddf(%rip),%r12
mov    (%r12),%esi
mov    %rbp,%rdi
call   1070 <access@plt>
test   %rax,%rax
je     1223 <extract_dsdt+0xc3>
lea    0xe0c(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xe6b(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r15,%rcx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %r14d,%r14d
je     12c3 <extract_dsdt+0x163>
lea    0xea4(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1070 <access@plt>
test   %rax,%rax
je     129f <extract_dsdt+0x13f>
lea    0xe2e(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xe5d(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r15,%rcx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0x1027(%rip),%rdi
call   1030 <puts@plt>
lea    0xe45(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %rax,%rax
je     1327 <extract_dsdt+0x1c7>
lea    0xe4f(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xe37(%rip),%rdi
call   1060 <show_error@plt>
jmp    13ba <extract_dsdt+0x25a>
lea    0xff9(%rip),%rdi
call   1030 <puts@plt>
test   %r14d,%r14d
je     13a0 <extract_dsdt+0x240>
lea    0xfd1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1c(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xec8(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %rax,%rax
je     1394 <extract_dsdt+0x234>
lea    0xeec(%rip),%rdi
call   1060 <show_error@plt>
jmp    13ba <extract_dsdt+0x25a>
lea    0xf8c(%rip),%rdi
call   1030 <puts@plt>
lea    0xf12(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c28(%rip),%rax
mov    (%rax),%eax
add    $0x140,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.extract_dsdt.root = [12 x i8] c"/tmp/helper\00"
@.str = [9 x i8] c"mkdir %s\00"
@.str.1 = [32 x i8] c"Downloading essential files...\0A\00"
@.str.2 = [18 x i8] c"%s/patchmatic.zip\00"
@F_OK = global i32 0
@.str.3 = [128 x i8] c"curl -sL https://bitbucket.org/RehabMan/os-x-maciasl-patchmatic/downloads/RehabMan-patchmatic-2015-0107.zip > %s/patchmatic.zip\00"
@.str.4 = [30 x i8] c"unzip %s/patchmatic.zip -d %s\00"
@.str.5 = [12 x i8] c"%s/iasl.zip\00"
@.str.6 = [80 x i8] c"curl -sL https://bitbucket.org/RehabMan/acpica/downloads/iasl.zip > %s/iasl.zip\00"
@.str.7 = [24 x i8] c"unzip %s/iasl.zip -d %s\00"
@.str.8 = [32 x i8] c"Done.\0AExtracting DSDT/SSDTs...\0A\00"
@.str.9 = [48 x i8] c"cd %s && ./patchmatic -extract && rm patchmatic\00"
@.str.10 = [9 x i8] c"rm -r %s\00"
@.str.11 = [19 x i8] c"Extraction failed!\00"
@.str.12 = [7 x i8] c"Done.\0A\00"
@.str.13 = [24 x i8] c"Disassembling files...\0A\00"
@.str.14 = [205 x i8] c"echo -e \22External(_SB_.PCI0.PEG0.PEGP.SGPO, MethodObj, 2)\0AExternal(_SB_.PCI0.LPCB.H_EC.ECWT, MethodObj, 2)\0AExternal(_SB_.PCI0.LPCB.H_EC.ECRD, MethodObj, 1)\0AExternal(_GPE.MMTB, MethodObj, 0)\22 > %s/refs.txt\00"
@.str.15 = [69 x i8] c"cd %s && ./iasl -da -dl -fe refs.txt *.aml && rm iasl refs.txt *.aml\00"
@.str.16 = [64 x i8] c"Disassemble failed! Mark the pervious line for possible errors.\00"
@.str.17 = [25 x i8] c"DSDT/SSDTs Location: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @extract_dsdt(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [300 x i8]
%7 = alloca [12 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = bitcast [12 x i8]* %7 to i8*
%9 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%11 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%13 = call i64 @system(i8* %12)
%14 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%15 = load i8*, i8** %4
%16 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%18 = call i64 @system(i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%20 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%22 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%24 = load i32, i32* @F_OK
%25 = call i64 @access(i8* %23, i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %2
%28 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%29 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%30 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %28, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%32 = call i64 @system(i8* %31)
br label %33
33: ; preds = %27, %2
%34 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%35 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%36 = load i8*, i8** %4
%37 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %34, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %35, i8* %36)
%38 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%39 = call i64 @system(i8* %38)
%40 = load i32, i32* %5
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %65
42: ; preds = %33
%43 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%44 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%45 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %43, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%47 = call i64 @system(i8* %46)
%48 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%49 = load i32, i32* @F_OK
%50 = call i64 @access(i8* %48, i32 %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %42
%53 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%54 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%55 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %53, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.6, i64 0, i64 0), i8* %54)
%56 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%57 = call i64 @system(i8* %56)
br label %58
58: ; preds = %52, %42
%59 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%60 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%61 = load i8*, i8** %4
%62 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %59, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %60, i8* %61)
%63 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%64 = call i64 @system(i8* %63)
br label %65
65: ; preds = %58, %33
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%67 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%68 = load i8*, i8** %4
%69 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %67, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0), i8* %68)
%70 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%71 = call i64 @system(i8* %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %80
73: ; preds = %65
%74 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%75 = load i8*, i8** %4
%76 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %74, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8* %75)
%77 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%78 = call i64 @system(i8* %77)
%79 = call i32 @show_error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
store i32 %79, i32* %3
br label %105
80: ; preds = %65
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%82 = load i32, i32* %5
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %101
84: ; preds = %80
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0))
%86 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%87 = load i8*, i8** %4
%88 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %86, i8* getelementptr inbounds ([205 x i8], [205 x i8]* @.str.14, i64 0, i64 0), i8* %87)
%89 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%90 = call i64 @system(i8* %89)
%91 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%92 = load i8*, i8** %4
%93 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %91, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.15, i64 0, i64 0), i8* %92)
%94 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%95 = call i64 @system(i8* %94)
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %99
97: ; preds = %84
%98 = call i32 @show_error(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.16, i64 0, i64 0))
store i32 %98, i32* %3
br label %105
99: ; preds = %84
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
br label %101
101: ; preds = %99, %80
%102 = load i8*, i8** %4
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i8* %102)
%104 = load i32, i32* @EXIT_SUCCESS
store i32 %104, i32* %3
br label %105
105: ; preds = %101, %97, %73
%106 = load i32, i32* %3
ret i32 %106
}

LLVM IR (-O2):
@__const.extract_dsdt.root = [12 x i8] c"/tmp/helper\00"
@.str = [9 x i8] c"mkdir %s\00"
@.str.2 = [18 x i8] c"%s/patchmatic.zip\00"
@F_OK = global i32 0
@.str.3 = [128 x i8] c"curl -sL https://bitbucket.org/RehabMan/os-x-maciasl-patchmatic/downloads/RehabMan-patchmatic-2015-0107.zip > %s/patchmatic.zip\00"
@.str.4 = [30 x i8] c"unzip %s/patchmatic.zip -d %s\00"
@.str.5 = [12 x i8] c"%s/iasl.zip\00"
@.str.6 = [80 x i8] c"curl -sL https://bitbucket.org/RehabMan/acpica/downloads/iasl.zip > %s/iasl.zip\00"
@.str.7 = [24 x i8] c"unzip %s/iasl.zip -d %s\00"
@.str.9 = [48 x i8] c"cd %s && ./patchmatic -extract && rm patchmatic\00"
@.str.10 = [9 x i8] c"rm -r %s\00"
@.str.11 = [19 x i8] c"Extraction failed!\00"
@.str.14 = [205 x i8] c"echo -e \22External(_SB_.PCI0.PEG0.PEGP.SGPO, MethodObj, 2)\0AExternal(_SB_.PCI0.LPCB.H_EC.ECWT, MethodObj, 2)\0AExternal(_SB_.PCI0.LPCB.H_EC.ECRD, MethodObj, 1)\0AExternal(_GPE.MMTB, MethodObj, 0)\22 > %s/refs.txt\00"
@.str.15 = [69 x i8] c"cd %s && ./iasl -da -dl -fe refs.txt *.aml && rm iasl refs.txt *.aml\00"
@.str.16 = [64 x i8] c"Disassemble failed! Mark the pervious line for possible errors.\00"
@.str.17 = [25 x i8] c"DSDT/SSDTs Location: %s\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [31 x i8] c"Downloading essential files...\00"
@str.18 = [31 x i8] c"Done.\0AExtracting DSDT/SSDTs...\00"
@str.20 = [23 x i8] c"Disassembling files...\00"
@str.21 = [6 x i8] c"Done.\00"
define i32 @extract_dsdt(i8* %0, i32 %1) {
%3 = alloca [300 x i8]
%4 = alloca [12 x i8]
%5 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%7 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i64 @system(i8* %5)
%9 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0)
%10 = call i64 @system(i8* %5)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%12 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%13 = load i32, i32* @F_OK
%14 = call i64 @access(i8* %5, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %2
%17 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%18 = call i64 @system(i8* %5)
br label %19
19: ; preds = %16, %2
%20 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %6, i8* %0)
%21 = call i64 @system(i8* %5)
%22 = icmp eq i32 %1, 0
br i1 %22, label %35, label %23
23: ; preds = %19
%24 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %6)
%25 = call i64 @system(i8* %5)
%26 = load i32, i32* @F_OK
%27 = call i64 @access(i8* %5, i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %23
%30 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%31 = call i64 @system(i8* %5)
br label %32
32: ; preds = %29, %23
%33 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %6, i8* %0)
%34 = call i64 @system(i8* %5)
br label %35
35: ; preds = %32, %19
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0))
%37 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0), i8* %0)
%38 = call i64 @system(i8* %5)
%39 = icmp eq i64 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %35
%41 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8* %0)
%42 = call i64 @system(i8* %5)
%43 = call i32 @show_error(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
br label %60
44: ; preds = %35
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.21, i64 0, i64 0))
br i1 %22, label %57, label %46
46: ; preds = %44
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.20, i64 0, i64 0))
%48 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([205 x i8], [205 x i8]* @.str.14, i64 0, i64 0), i8* %0)
%49 = call i64 @system(i8* %5)
%50 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.15, i64 0, i64 0), i8* %0)
%51 = call i64 @system(i8* %5)
%52 = icmp eq i64 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %46
%54 = call i32 @show_error(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.16, i64 0, i64 0))
br label %60
55: ; preds = %46
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.21, i64 0, i64 0))
br label %57
57: ; preds = %55, %44
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i8* %0)
%59 = load i32, i32* @EXIT_SUCCESS
br label %60
60: ; preds = %57, %53, %40
%61 = phi i32 [ %43, %40 ], [ %54, %53 ], [ %59, %57 ]
ret i32 %61
}