#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int pciList();
int /*<<< orphan*/ println(char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc > 1) {
    char *command = argv[1];
    if (!strcmp(command, "list"))
      return pciList();
    else if (strcmp(command, "--help") == 0) {
      println("pcitool, v%i.%i", 0, 1);
      println("This program allows users to list data about PCI devices in the "
              "system.");
      println("");
      println("The following commands are available:");
      println("");
      println("\tlist\t\tlists basic information for all PCI devices");
      println("");
    } else
      fprintf(stderr, "unknown command: %s\n", command);
  } else {
    fprintf(stderr, "usage:\n\t%s <command>\n", argv[0]);
    fprintf(stderr, "Type \"%s --help\" for a list of commands.\n", argv[0]);
    fprintf(stderr, "\n");
  }
}


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   $0x1,-0x8(%rbp)
jle    1242 <main+0x102>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1195 <main+0x55>
mov    $0x0,%al
call   1060 <pciList@plt>
mov    %eax,-0x4(%rbp)
jmp    1295 <main+0x155>
mov    -0x18(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    121d <main+0xdd>
lea    0xe56(%rip),%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <println@plt>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <println@plt>
lea    0xf38(%rip),%rdi
mov    $0x0,%al
call   1030 <println@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <println@plt>
lea    0xf1c(%rip),%rdi
mov    $0x0,%al
call   1030 <println@plt>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <println@plt>
lea    0xf00(%rip),%rdi
mov    $0x0,%al
call   1030 <println@plt>
jmp    1238 <main+0xf8>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    123d <main+0xfd>
jmp    1295 <main+0x155>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     1197 <main+0x57>
mov    0x8(%rbx),%rbx
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d9 <main+0x99>
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e7 <main+0xa7>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xf35(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    124b <main+0x10b>
mov    0x2e42(%rip),%r14
mov    (%r14),%edi
mov    (%rbx),%rdx
lea    0xf27(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r14),%edi
mov    (%rbx),%rdx
lea    0xf29(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xf40(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    124b <main+0x10b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <pciList@plt>
lea    0xe1e(%rip),%rdi
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <println@plt>
lea    0xe19(%rip),%rdi
xor    %eax,%eax
call   1030 <println@plt>
lea    0xf00(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <println@plt>
lea    0xe42(%rip),%rdi
xor    %eax,%eax
call   1030 <println@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <println@plt>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1030 <println@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <println@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"list\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [16 x i8] c"pcitool, v%i.%i\00"
@.str.3 = [72 x i8] c"This program allows users to list data about PCI devices in the system.\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [38 x i8] c"The following commands are available:\00"
@.str.6 = [51 x i8] c"\09list\09\09lists basic information for all PCI devices\00"
@stderr = global i32 0
@.str.7 = [21 x i8] c"unknown command: %s\0A\00"
@.str.8 = [22 x i8] c"usage:\0A\09%s <command>\0A\00"
@.str.9 = [42 x i8] c"Type \22%s --help\22 for a list of commands.\0A\00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %36
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %9
%17 = call i32 (...) @pciList()
store i32 %17, i32* %3
br label %49
18: ; preds = %9
%19 = load i8*, i8** %6
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %18
%23 = call i32 (i8*, ...) @println(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1)
%24 = call i32 (i8*, ...) @println(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 (i8*, ...) @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 (i8*, ...) @println(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%27 = call i32 (i8*, ...) @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 (i8*, ...) @println(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0))
%29 = call i32 (i8*, ...) @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
br label %34
30: ; preds = %18
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %6
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %30, %22
br label %35
35: ; preds = %34
br label %49
36: ; preds = %2
%37 = load i32, i32* @stderr
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %40)
%42 = load i32, i32* @stderr
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 0
%45 = load i8*, i8** %44
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i8* %45)
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %49
49: ; preds = %16, %36, %35
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str = [5 x i8] c"list\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [16 x i8] c"pcitool, v%i.%i\00"
@.str.3 = [72 x i8] c"This program allows users to list data about PCI devices in the system.\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [38 x i8] c"The following commands are available:\00"
@.str.6 = [51 x i8] c"\09list\09\09lists basic information for all PCI devices\00"
@stderr = global i32 0
@.str.7 = [21 x i8] c"unknown command: %s\0A\00"
@.str.8 = [22 x i8] c"usage:\0A\09%s <command>\0A\00"
@.str.9 = [42 x i8] c"Type \22%s --help\22 for a list of commands.\0A\00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %25
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 (...) @pciList()
br label %34
11: ; preds = %4
%12 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = tail call i32 (i8*, ...) @println(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1)
%16 = tail call i32 (i8*, ...) @println(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%18 = tail call i32 (i8*, ...) @println(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%20 = tail call i32 (i8*, ...) @println(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0))
%21 = tail call i32 (i8*, ...) @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
br label %34
22: ; preds = %11
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %6)
br label %34
25: ; preds = %2
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %1
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %27)
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %1
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %34
34: ; preds = %9, %14, %22, %25
%35 = phi i32 [ 0, %25 ], [ %10, %9 ], [ 0, %14 ], [ 0, %22 ]
ret i32 %35
}