#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*/ atoi(char *);
int /*<<< orphan*/ build(int /*<<< orphan*/, char *);
int /*<<< orphan*/ device_list();
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  switch (argc) {
  case 1:
    usage(argv[0]);
    device_list();
    break;
  case 2:
    build(0, argv[1]);
    break;
  case 3:
    build(atoi(argv[1]), argv[2]);
    break;
  default:
    usage(argv[0]);
    return 1;
  }
  return 0;
}


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)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     118c <main+0x4c>
jmp    116a <main+0x2a>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     11a4 <main+0x64>
jmp    117b <main+0x3b>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     11b8 <main+0x78>
jmp    11d9 <main+0x99>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <usage@plt>
mov    $0x0,%al
call   1060 <device_list@plt>
jmp    11f1 <main+0xb1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
xor    %edi,%edi
call   1030 <build@plt>
jmp    11f1 <main+0xb1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <build@plt>
jmp    11f1 <main+0xb1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f8 <main+0xb8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1166 <main+0x26>
cmp    $0x2,%edi
je     117e <main+0x3e>
cmp    $0x1,%edi
jne    118d <main+0x4d>
mov    (%rbx),%rdi
call   1040 <usage@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <device_list@plt>
jmp    119a <main+0x5a>
mov    0x8(%rbx),%rdi
call   1050 <atoi@plt>
mov    0x10(%rbx),%rsi
mov    %eax,%edi
call   1030 <build@plt>
xor    %ebx,%ebx
jmp    119a <main+0x5a>
mov    0x8(%rbx),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <build@plt>
jmp    119a <main+0x5a>
mov    (%rbx),%rdi
call   1040 <usage@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
switch i32 %6, label %27 [
i32 1, label %7
i32 2, label %13
i32 3, label %18
]
7: ; preds = %2
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i32 @usage(i8* %10)
%12 = call i32 (...) @device_list()
br label %32
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @build(i32 0, i8* %16)
br label %32
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @build(i32 %22, i8* %25)
br label %32
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 @usage(i8* %30)
store i32 1, i32* %3
br label %33
32: ; preds = %18, %13, %7
store i32 0, i32* %3
br label %33
33: ; preds = %32, %27
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %18 [
i32 1, label %3
i32 2, label %7
i32 3, label %11
]
3: ; preds = %2
%4 = load i8*, i8** %1
%5 = tail call i32 @usage(i8* %4)
%6 = tail call i32 (...) @device_list()
br label %21
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @build(i32 0, i8* %9)
br label %21
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @build(i32 %14, i8* %16)
br label %21
18: ; preds = %2
%19 = load i8*, i8** %1
%20 = tail call i32 @usage(i8* %19)
br label %21
21: ; preds = %3, %7, %11, %18
%22 = phi i32 [ 1, %18 ], [ 0, %11 ], [ 0, %7 ], [ 0, %3 ]
ret i32 %22
}