#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 EINVAL;
int /*<<< orphan*/ atoi(char *);
int cldrv_errors();
int cldrv_states();
int leddrv_clr(int /*<<< orphan*/);
int leddrv_init();
int leddrv_set(int /*<<< orphan*/);
scalar_t__ strcmp(char const *, char *);
int main(int argc, char *argv[]) {
  const char *action = argv[1];
  if (action) {
    if (0 == strcmp(action, "init")) {
      return leddrv_init();
    } else if (0 == strcmp(action, "set")) {
      return leddrv_set(atoi(argv[2]));
    } else if (0 == strcmp(action, "clr")) {
      return leddrv_clr(atoi(argv[2]));
    } else if (0 == strcmp(action, "serialize_states")) {
      return cldrv_states();
    } else if (0 == strcmp(action, "serialize_errors")) {
      return cldrv_errors();
    }
  }
  return -EINVAL;
}


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    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     12b1 <main+0x141>
mov    -0x18(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11ca <main+0x5a>
mov    $0x0,%al
call   1040 <leddrv_init@plt>
mov    %eax,-0x4(%rbp)
jmp    12bf <main+0x14f>
mov    -0x18(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1204 <main+0x94>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1030 <leddrv_set@plt>
mov    %eax,-0x4(%rbp)
jmp    12bf <main+0x14f>
mov    -0x18(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    123e <main+0xce>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1060 <leddrv_clr@plt>
mov    %eax,-0x4(%rbp)
jmp    12bf <main+0x14f>
mov    -0x18(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    126b <main+0xfb>
mov    $0x0,%al
call   1050 <cldrv_states@plt>
mov    %eax,-0x4(%rbp)
jmp    12bf <main+0x14f>
mov    -0x18(%rbp),%rdi
lea    0xda8(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1298 <main+0x128>
mov    $0x0,%al
call   1090 <cldrv_errors@plt>
mov    %eax,-0x4(%rbp)
jmp    12bf <main+0x14f>
jmp    129d <main+0x12d>
jmp    12a2 <main+0x132>
jmp    12a7 <main+0x137>
jmp    12ac <main+0x13c>
jmp    12b1 <main+0x141>
xor    %eax,%eax
mov    0x2d26(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rbx
test   %rbx,%rbx
je     11e4 <main+0x74>
mov    %rsi,%r14
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11f7 <main+0x87>
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1205 <main+0x95>
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     121c <main+0xac>
lea    0xe4a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1233 <main+0xc3>
lea    0xe47(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1241 <main+0xd1>
mov    0x2df5(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <leddrv_init@plt>
mov    0x10(%r14),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <leddrv_set@plt>
mov    0x10(%r14),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <leddrv_clr@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <cldrv_states@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1090 <cldrv_errors@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"init\00"
@.str.1 = [4 x i8] c"set\00"
@.str.2 = [4 x i8] c"clr\00"
@.str.3 = [17 x i8] c"serialize_states\00"
@.str.4 = [17 x i8] c"serialize_errors\00"
@EINVAL = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %55
12: ; preds = %2
%13 = load i8*, i8** %6
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 0, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 (...) @leddrv_init()
store i32 %17, i32* %3
br label %58
18: ; preds = %12
%19 = load i8*, i8** %6
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 0, %20
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
%27 = call i32 @leddrv_set(i32 %26)
store i32 %27, i32* %3
br label %58
28: ; preds = %18
%29 = load i8*, i8** %6
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp eq i64 0, %30
br i1 %31, label %32, label %38
32: ; preds = %28
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
%37 = call i32 @leddrv_clr(i32 %36)
store i32 %37, i32* %3
br label %58
38: ; preds = %28
%39 = load i8*, i8** %6
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp eq i64 0, %40
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (...) @cldrv_states()
store i32 %43, i32* %3
br label %58
44: ; preds = %38
%45 = load i8*, i8** %6
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp eq i64 0, %46
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 (...) @cldrv_errors()
store i32 %49, i32* %3
br label %58
50: ; preds = %44
br label %51
51: ; preds = %50
br label %52
52: ; preds = %51
br label %53
53: ; preds = %52
br label %54
54: ; preds = %53
br label %55
55: ; preds = %54, %2
%56 = load i32, i32* @EINVAL
%57 = sub nsw i32 0, %56
store i32 %57, i32* %3
br label %58
58: ; preds = %55, %48, %42, %32, %22, %16
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@.str = [5 x i8] c"init\00"
@.str.1 = [4 x i8] c"set\00"
@.str.2 = [4 x i8] c"clr\00"
@.str.3 = [17 x i8] c"serialize_states\00"
@.str.4 = [17 x i8] c"serialize_errors\00"
@EINVAL = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %37, label %6
6: ; preds = %2
%7 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 (...) @leddrv_init()
br label %40
11: ; preds = %6
%12 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = tail call i32 @leddrv_set(i32 %17)
br label %40
19: ; preds = %11
%20 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call i32 @atoi(i8* %24)
%26 = tail call i32 @leddrv_clr(i32 %25)
br label %40
27: ; preds = %19
%28 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 (...) @cldrv_states()
br label %40
32: ; preds = %27
%33 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = tail call i32 (...) @cldrv_errors()
br label %40
37: ; preds = %32, %2
%38 = load i32, i32* @EINVAL
%39 = sub nsw i32 0, %38
br label %40
40: ; preds = %37, %35, %30, %22, %14, %9
%41 = phi i32 [ %10, %9 ], [ %18, %14 ], [ %26, %22 ], [ %31, %30 ], [ %36, %35 ], [ %39, %37 ]
ret i32 %41
}