#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(int /*<<< orphan*/);
int /*<<< orphan*/ read_wifi_mode();
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ write_wifimode_to_boot(char *);
int main(int argc, char **argv) {
  int ret = 0;
  if (argc < 2 || !strcmp(argv[1], "-h")) {
    usage();
    exit(0);
  }
  if (!strcmp(argv[1], "read")) {
    read_wifi_mode();
  } else if (!strcmp(argv[1], "2g") || !strcmp(argv[1], "5g")) {
    write_wifimode_to_boot(argv[1]);
  } else {
    usage();
  }
  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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1194 <main+0x44>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11a2 <main+0x52>
mov    $0x0,%al
call   1060 <usage@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe52(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11cb <main+0x7b>
mov    $0x0,%al
call   1050 <read_wifi_mode@plt>
jmp    1223 <main+0xd3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1205 <main+0xb5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe14(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1217 <main+0xc7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <write_wifimode_to_boot@plt>
jmp    121e <main+0xce>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    1223 <main+0xd3>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jl     11c4 <main+0x74>
mov    0x8(%rsi),%rbx
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11c4 <main+0x74>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11b9 <main+0x69>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11af <main+0x5f>
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11af <main+0x5f>
xor    %eax,%eax
call   1060 <usage@plt>
jmp    11c0 <main+0x70>
mov    %rbx,%rdi
call   1030 <write_wifimode_to_boot@plt>
jmp    11c0 <main+0x70>
xor    %eax,%eax
call   1050 <read_wifi_mode@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1060 <usage@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [5 x i8] c"read\00"
@.str.2 = [3 x i8] c"2g\00"
@.str.3 = [3 x i8] c"5g\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
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %9, %2
%16 = call i32 (...) @usage()
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %9
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp ne i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %18
%25 = call i32 (...) @read_wifi_mode()
br label %46
26: ; preds = %18
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %26
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %43, label %38
38: ; preds = %32, %26
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 @write_wifimode_to_boot(i8* %41)
br label %45
43: ; preds = %32
%44 = call i32 (...) @usage()
br label %45
45: ; preds = %43, %38
br label %46
46: ; preds = %45, %24
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [5 x i8] c"read\00"
@.str.2 = [3 x i8] c"2g\00"
@.str.3 = [3 x i8] c"5g\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %4, %2
%10 = tail call i32 (...) @usage()
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %4
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 (...) @read_wifi_mode()
br label %27
17: ; preds = %12
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20, %17
%24 = tail call i32 @write_wifimode_to_boot(i8* %6)
br label %27
25: ; preds = %20
%26 = tail call i32 (...) @usage()
br label %27
27: ; preds = %23, %25, %15
ret i32 0
}