#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ process_brightness_values(int);
int /*<<< orphan*/ process_trigger_values(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  printf("This Application controls the USER LED3\n");
  if (argc != 3) {
    printf("usage: %s <control_option> <value>\n", argv[0]);
    printf("valid control_options : brightness, trigger\n");
    printf("valid 'brightness' values : 0,1\n");
    printf(
        "valid 'trigger' values : heartbeat,timer,none,oneshot,default-on\n");
  } else {
    if (strcmp(argv[1], "trigger") == 0) {
      process_trigger_values(argv[2]);
    } else if (strcmp(argv[1], "brightness") == 0) {
      int value = atoi(argv[2]);
      process_brightness_values(value);
    } else {
      printf("Invalid control option\n");
      printf("valid control_options : brightness, trigger\n");
    }
  }
  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)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
je     11c2 <main+0x72>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1253 <main+0x103>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xf0c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11f2 <main+0xa2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <process_trigger_values@plt>
jmp    124e <main+0xfe>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xee4(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    122d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <process_brightness_values@plt>
jmp    1249 <main+0xf9>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124e <main+0xfe>
jmp    1253 <main+0x103>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xec0(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x3,%ebp
jne    11b8 <main+0x58>
mov    0x8(%rbx),%rdi
lea    0xf0e(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11ef <main+0x8f>
mov    0x8(%rbx),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11fa <main+0x9a>
lea    0xead(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb8(%rip),%rdi
jmp    11e8 <main+0x88>
mov    (%rbx),%rsi
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9e(%rip),%rdi
call   1040 <puts@plt>
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
lea    0xed2(%rip),%rdi
call   1040 <puts@plt>
jmp    120a <main+0xaa>
mov    0x10(%rbx),%rdi
call   1060 <process_trigger_values@plt>
jmp    120a <main+0xaa>
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1030 <process_brightness_values@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"This Application controls the USER LED3\0A\00"
@.str.1 = [36 x i8] c"usage: %s <control_option> <value>\0A\00"
@.str.2 = [45 x i8] c"valid control_options : brightness, trigger\0A\00"
@.str.3 = [33 x i8] c"valid 'brightness' values : 0,1\0A\00"
@.str.4 = [66 x i8] c"valid 'trigger' values : heartbeat,timer,none,oneshot,default-on\0A\00"
@.str.5 = [8 x i8] c"trigger\00"
@.str.6 = [11 x i8] c"brightness\00"
@.str.7 = [24 x i8] c"Invalid control option\0A\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
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.4, i64 0, i64 0))
br label %47
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @process_trigger_values(i8* %27)
br label %46
29: ; preds = %18
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %42
35: ; preds = %29
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @atoi(i8* %38)
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = call i32 @process_brightness_values(i32 %40)
br label %45
42: ; preds = %29
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %42, %35
br label %46
46: ; preds = %45, %24
br label %47
47: ; preds = %46, %10
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [36 x i8] c"usage: %s <control_option> <value>\0A\00"
@.str.5 = [8 x i8] c"trigger\00"
@.str.6 = [11 x i8] c"brightness\00"
@str = [40 x i8] c"This Application controls the USER LED3\00"
@str.8 = [23 x i8] c"Invalid control option\00"
@str.10 = [44 x i8] c"valid control_options : brightness, trigger\00"
@str.11 = [32 x i8] c"valid 'brightness' values : 0,1\00"
@str.12 = [65 x i8] c"valid 'trigger' values : heartbeat,timer,none,oneshot,default-on\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%4 = icmp eq i32 %0, 3
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.10, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.11, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.12, i64 0, i64 0))
br label %32
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32 @process_trigger_values(i8* %18)
br label %32
20: ; preds = %11
%21 = load i8*, i8** %12
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = tail call i32 @atoi(i8* %26)
%28 = tail call i32 @process_brightness_values(i32 %27)
br label %32
29: ; preds = %20
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.10, i64 0, i64 0))
br label %32
32: ; preds = %16, %29, %24, %5
ret i32 0
}