#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*/ gpio_cfg_output(int, int);
int /*<<< orphan*/ gpio_clear_output(int, int);
int /*<<< orphan*/ gpio_init();
int /*<<< orphan*/ gpio_set_output(int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  gpio_init();
  gpio_cfg_output((2 * 0x24), (19));
  gpio_cfg_output((2 * 0x24), (15));
  gpio_cfg_output((2 * 0x24), (14));
  gpio_set_output((2 * 0x24), (0x00000001L << 14));
  if (argc > 1 && argv[1][0] == '0') {
    gpio_clear_output((2 * 0x24), (0x00000001L << 15));
    gpio_set_output((2 * 0x24), (0x00000001L << 19));
    printf("LED OFF\n");
  } else if (argc > 1 && argv[1][0] == '1') {
    gpio_set_output((2 * 0x24), (0x00000001L << 15));
    gpio_clear_output((2 * 0x24), (0x00000001L << 19));
    printf("LED ON\n");
  } else {
    printf("Usage:\n   %s {0|1}\n    0: LED OFF\n    1: LED ON\n", argv[0]);
  }
  return 0;
}


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)
mov    $0x0,%al
call   1070 <gpio_init@plt>
mov    $0x48,%edi
mov    $0x13,%esi
call   1060 <gpio_cfg_output@plt>
mov    $0x48,%edi
mov    $0xf,%esi
call   1060 <gpio_cfg_output@plt>
mov    $0x48,%edi
mov    $0xe,%esi
call   1060 <gpio_cfg_output@plt>
mov    $0x48,%edi
mov    $0x4000,%esi
call   1030 <gpio_set_output@plt>
cmpl   $0x1,-0x8(%rbp)
jle    11f8 <main+0xa8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    11f8 <main+0xa8>
mov    $0x48,%edi
mov    $0x8000,%esi
call   1040 <gpio_clear_output@plt>
mov    $0x48,%edi
mov    $0x80000,%esi
call   1030 <gpio_set_output@plt>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1261 <main+0x111>
cmpl   $0x1,-0x8(%rbp)
jle    1247 <main+0xf7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
jne    1247 <main+0xf7>
mov    $0x48,%edi
mov    $0x8000,%esi
call   1030 <gpio_set_output@plt>
mov    $0x48,%edi
mov    $0x80000,%esi
call   1040 <gpio_clear_output@plt>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    125c <main+0x10c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1261 <main+0x111>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1080 <gpio_init@plt>
mov    $0x48,%edi
mov    $0x13,%esi
call   1070 <gpio_cfg_output@plt>
mov    $0x48,%edi
mov    $0xf,%esi
call   1070 <gpio_cfg_output@plt>
mov    $0x48,%edi
mov    $0xe,%esi
call   1070 <gpio_cfg_output@plt>
mov    $0x48,%edi
mov    $0x4000,%esi
call   1030 <gpio_set_output@plt>
cmp    $0x2,%ebp
jl     11e5 <main+0x85>
mov    0x8(%rbx),%rax
mov    (%rax),%al
cmp    $0x31,%al
je     11f8 <main+0x98>
cmp    $0x30,%al
jne    11e5 <main+0x85>
mov    $0x48,%edi
mov    $0x8000,%esi
call   1050 <gpio_clear_output@plt>
mov    $0x48,%edi
mov    $0x80000,%esi
call   1030 <gpio_set_output@plt>
lea    0xe55(%rip),%rdi
jmp    121d <main+0xbd>
mov    (%rbx),%rsi
lea    0xe11(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1222 <main+0xc2>
mov    $0x48,%edi
mov    $0x8000,%esi
call   1030 <gpio_set_output@plt>
mov    $0x48,%edi
mov    $0x80000,%esi
call   1050 <gpio_clear_output@plt>
lea    0xe14(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"LED OFF\0A\00"
@.str.1 = [8 x i8] c"LED ON\0A\00"
@.str.2 = [49 x i8] c"Usage:\0A %s {0|1}\0A 0: LED OFF\0A 1: LED ON\0A\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 = call i32 (...) @gpio_init()
%7 = call i32 @gpio_cfg_output(i32 72, i32 19)
%8 = call i32 @gpio_cfg_output(i32 72, i32 15)
%9 = call i32 @gpio_cfg_output(i32 72, i32 14)
%10 = call i32 @gpio_set_output(i32 72, i32 16384)
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %25
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 48
br i1 %20, label %21, label %25
21: ; preds = %13
%22 = call i32 @gpio_clear_output(i32 72, i32 32768)
%23 = call i32 @gpio_set_output(i32 72, i32 524288)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %46
25: ; preds = %13, %2
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 1
br i1 %27, label %28, label %40
28: ; preds = %25
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 49
br i1 %35, label %36, label %40
36: ; preds = %28
%37 = call i32 @gpio_set_output(i32 72, i32 32768)
%38 = call i32 @gpio_clear_output(i32 72, i32 524288)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %45
40: ; preds = %28, %25
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %40, %36
br label %46
46: ; preds = %45, %21
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [49 x i8] c"Usage:\0A %s {0|1}\0A 0: LED OFF\0A 1: LED ON\0A\00"
@str = [7 x i8] c"LED ON\00"
@str.3 = [8 x i8] c"LED OFF\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @gpio_init()
%4 = tail call i32 @gpio_cfg_output(i32 72, i32 19)
%5 = tail call i32 @gpio_cfg_output(i32 72, i32 15)
%6 = tail call i32 @gpio_cfg_output(i32 72, i32 14)
%7 = tail call i32 @gpio_set_output(i32 72, i32 16384)
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %21
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
switch i8 %12, label %21 [
i8 48, label %13
i8 49, label %17
]
13: ; preds = %9
%14 = tail call i32 @gpio_clear_output(i32 72, i32 32768)
%15 = tail call i32 @gpio_set_output(i32 72, i32 524288)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.3, i64 0, i64 0))
br label %24
17: ; preds = %9
%18 = tail call i32 @gpio_set_output(i32 72, i32 32768)
%19 = tail call i32 @gpio_clear_output(i32 72, i32 524288)
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %24
21: ; preds = %9, %2
%22 = load i8*, i8** %1
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %17, %21, %13
ret i32 0
}