#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*/ EXIT_FAILURE;
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *, ...);
int gpio_main(int, char **);
int i2c_main(int, char **);
int spi_main(int, char **);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 2)
    errx(EXIT_FAILURE, "Must pass mode (e.g. gpio, i2c, spi)");
  if (strcmp(argv[1], "gpio") == 0)
    return gpio_main(argc, argv);
  else if (strcmp(argv[1], "i2c") == 0)
    return i2c_main(argc, argv);
  else if (strcmp(argv[1], "spi") == 0)
    return spi_main(argc, argv);
  else
    errx(EXIT_FAILURE, "Unknown mode '%s'", argv[1]);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1187 <main+0x37>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1030 <errx@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b9 <main+0x69>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <gpio_main@plt>
mov    %eax,-0x4(%rbp)
jmp    124d <main+0xfd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe62(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11eb <main+0x9b>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <i2c_main@plt>
mov    %eax,-0x4(%rbp)
jmp    124d <main+0xfd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe34(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    121d <main+0xcd>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <spi_main@plt>
mov    %eax,-0x4(%rbp)
jmp    124d <main+0xfd>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdfd(%rip),%rsi
mov    $0x0,%al
call   1030 <errx@plt>
jmp    1241 <main+0xf1>
jmp    1246 <main+0xf6>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x1,%edi
jg     1174 <main+0x24>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
xor    %eax,%eax
call   1030 <errx@plt>
mov    0x8(%rbx),%rdi
lea    0xea6(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11da <main+0x8a>
mov    0x8(%rbx),%rdi
lea    0xe96(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ea <main+0x9a>
mov    0x8(%rbx),%rdi
lea    0xe85(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11fa <main+0xaa>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe6b(%rip),%rsi
xor    %eax,%eax
call   1030 <errx@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <gpio_main@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <i2c_main@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <spi_main@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [37 x i8] c"Must pass mode (e.g. gpio, i2c, spi)\00"
@.str.1 = [5 x i8] c"gpio\00"
@.str.2 = [4 x i8] c"i2c\00"
@.str.3 = [4 x i8] c"spi\00"
@.str.4 = [18 x i8] c"Unknown mode '%s'\00"
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
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 (i32, i8*, ...) @errx(i32 %9, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %8, %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @gpio_main(i32 %18, i8** %19)
store i32 %20, i32* %3
br label %50
21: ; preds = %11
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = load i32, i32* %4
%29 = load i8**, i8*** %5
%30 = call i32 @i2c_main(i32 %28, i8** %29)
store i32 %30, i32* %3
br label %50
31: ; preds = %21
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %31
%38 = load i32, i32* %4
%39 = load i8**, i8*** %5
%40 = call i32 @spi_main(i32 %38, i8** %39)
store i32 %40, i32* %3
br label %50
41: ; preds = %31
%42 = load i32, i32* @EXIT_FAILURE
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 (i32, i8*, ...) @errx(i32 %42, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %41
br label %48
48: ; preds = %47
br label %49
49: ; preds = %48
store i32 1, i32* %3
br label %50
50: ; preds = %49, %37, %27, %17
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [37 x i8] c"Must pass mode (e.g. gpio, i2c, spi)\00"
@.str.1 = [5 x i8] c"gpio\00"
@.str.2 = [4 x i8] c"i2c\00"
@.str.3 = [4 x i8] c"spi\00"
@.str.4 = [18 x i8] c"Unknown mode '%s'\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @EXIT_FAILURE
%6 = tail call i32 (i32, i8*, ...) @errx(i32 %5, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @gpio_main(i32 %0, i8** %1)
br label %30
14: ; preds = %7
%15 = load i8*, i8** %8
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 @i2c_main(i32 %0, i8** %1)
br label %30
20: ; preds = %14
%21 = load i8*, i8** %8
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @spi_main(i32 %0, i8** %1)
br label %30
26: ; preds = %20
%27 = load i32, i32* @EXIT_FAILURE
%28 = load i8*, i8** %8
%29 = tail call i32 (i32, i8*, ...) @errx(i32 %27, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %26, %24, %18, %12
%31 = phi i32 [ %13, %12 ], [ %19, %18 ], [ %25, %24 ], [ 1, %26 ]
ret i32 %31
}