#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*/ DisplayUsage();
int ExtractTables(char *, char *, int);
int ListTables(char *);
int main(int argc, char *argv[]) {
  int Status;
  if (argc < 2) {
    DisplayUsage();
    return 0;
  }
  if (argv[1][0] == '-') {
    if (argc < 3) {
      DisplayUsage();
      return 0;
    }
    switch (argv[1][1]) {
    case 'a':
      return (ExtractTables(argv[2], NULL, 0));
    case 'l':
      return (ListTables(argv[2]));
    case 's':
      return (ExtractTables(argv[2], &argv[1][2], 1));
    default:
      DisplayUsage();
      return 0;
    }
  }
  Status = ExtractTables(argv[1], "DSDT", 1);
  if (Status) {
    return Status;
  }
  Status = ExtractTables(argv[1], "SSDT", 0);
  return (Status);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1163 <main+0x33>
mov    $0x0,%al
call   1050 <DisplayUsage@plt>
movl   $0x0,-0x4(%rbp)
jmp    128c <main+0x15c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    123c <main+0x10c>
cmpl   $0x3,-0x8(%rbp)
jge    1194 <main+0x64>
mov    $0x0,%al
call   1050 <DisplayUsage@plt>
movl   $0x0,-0x4(%rbp)
jmp    128c <main+0x15c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x61,%eax
je     11d3 <main+0xa3>
jmp    11b1 <main+0x81>
mov    -0x18(%rbp),%eax
sub    $0x6c,%eax
je     11ee <main+0xbe>
jmp    11c2 <main+0x92>
mov    -0x18(%rbp),%eax
sub    $0x73,%eax
je     1203 <main+0xd3>
jmp    1229 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <ExtractTables@plt>
mov    %eax,-0x4(%rbp)
jmp    128c <main+0x15c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <ListTables@plt>
mov    %eax,-0x4(%rbp)
jmp    128c <main+0x15c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
add    $0x2,%rsi
mov    $0x1,%edx
call   1040 <ExtractTables@plt>
mov    %eax,-0x4(%rbp)
jmp    128c <main+0x15c>
mov    $0x0,%al
call   1050 <DisplayUsage@plt>
movl   $0x0,-0x4(%rbp)
jmp    128c <main+0x15c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb5(%rip),%rsi
mov    $0x1,%edx
call   1040 <ExtractTables@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     126d <main+0x13d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    128c <main+0x15c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd89(%rip),%rsi
xor    %edx,%edx
call   1040 <ExtractTables@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    1149 <main+0x19>
mov    %rsi,%rbx
mov    0x8(%rsi),%rax
cmpb   $0x2d,(%rax)
jne    115b <main+0x2b>
cmp    $0x2,%edi
ja     1182 <main+0x52>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <DisplayUsage@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe9e(%rip),%rsi
mov    %rax,%rdi
mov    $0x1,%edx
call   1040 <ExtractTables@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1152 <main+0x22>
mov    0x8(%rbx),%rdi
lea    0xe85(%rip),%rsi
jmp    119b <main+0x6b>
movsbl 0x1(%rax),%ecx
cmp    $0x73,%ecx
je     119f <main+0x6f>
cmp    $0x6c,%ecx
je     11ba <main+0x8a>
cmp    $0x61,%ecx
jne    1149 <main+0x19>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
jmp    11af <main+0x7f>
mov    0x10(%rbx),%rdi
add    $0x2,%rax
mov    %rax,%rsi
mov    $0x1,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <ExtractTables@plt>
mov    0x10(%rbx),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ListTables@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"DSDT\00"
@.str.1 = [5 x i8] c"SSDT\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (...) @DisplayUsage()
store i32 0, i32* %3
br label %67
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 45
br i1 %18, label %19, label %52
19: ; preds = %11
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 3
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (...) @DisplayUsage()
store i32 0, i32* %3
br label %67
24: ; preds = %19
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
switch i32 %30, label %50 [
i32 97, label %31
i32 108, label %36
i32 115, label %41
]
31: ; preds = %24
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @ExtractTables(i8* %34, i8* null, i32 0)
store i32 %35, i32* %3
br label %67
36: ; preds = %24
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 @ListTables(i8* %39)
store i32 %40, i32* %3
br label %67
41: ; preds = %24
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = getelementptr inbounds i8, i8* %47, i64 2
%49 = call i32 @ExtractTables(i8* %44, i8* %48, i32 1)
store i32 %49, i32* %3
br label %67
50: ; preds = %24
%51 = call i32 (...) @DisplayUsage()
store i32 0, i32* %3
br label %67
52: ; preds = %11
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i32 @ExtractTables(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 1)
store i32 %56, i32* %6
%57 = load i32, i32* %6
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %52
%60 = load i32, i32* %6
store i32 %60, i32* %3
br label %67
61: ; preds = %52
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = call i32 @ExtractTables(i8* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 0)
store i32 %65, i32* %6
%66 = load i32, i32* %6
store i32 %66, i32* %3
br label %67
67: ; preds = %61, %59, %50, %41, %36, %31, %22, %9
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str = [5 x i8] c"DSDT\00"
@.str.1 = [5 x i8] c"SSDT\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @DisplayUsage()
br label %40
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 45
br i1 %10, label %11, label %34
11: ; preds = %6
%12 = icmp ult i32 %0, 3
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 (...) @DisplayUsage()
br label %40
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %8, i64 1
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
switch i32 %18, label %32 [
i32 97, label %19
i32 108, label %23
i32 115, label %27
]
19: ; preds = %15
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32 @ExtractTables(i8* %21, i8* null, i32 0)
br label %40
23: ; preds = %15
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 @ListTables(i8* %25)
br label %40
27: ; preds = %15
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = getelementptr inbounds i8, i8* %8, i64 2
%31 = tail call i32 @ExtractTables(i8* %29, i8* %30, i32 1)
br label %40
32: ; preds = %15
%33 = tail call i32 (...) @DisplayUsage()
br label %40
34: ; preds = %6
%35 = tail call i32 @ExtractTables(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 1)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i8*, i8** %7
%39 = tail call i32 @ExtractTables(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %40
40: ; preds = %34, %37, %32, %27, %23, %19, %13, %4
%41 = phi i32 [ 0, %4 ], [ 0, %13 ], [ 0, %32 ], [ %31, %27 ], [ %26, %23 ], [ %22, %19 ], [ %39, %37 ], [ %35, %34 ]
ret i32 %41
}