#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*/ close_interface();
int doCommand(char *, int *, int *, int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ open_interface();
int /*<<< orphan*/ printf(char *, ...);
char *process_commandline(int, char **);
int main(int argc, char **argv) {
  char *commandline;
  int errorcode, ret1, ret2, ret3;
  commandline = process_commandline(argc, argv);
  open_interface();
  errorcode = doCommand(commandline, &ret1, &ret2, &ret3);
  switch (errorcode) {
  case 10:
    printf("10 OK - no return value\n");
    break;
  case 11:
    printf("11 OK - one return value\nRET1: %i\n", ret1);
    break;
  case 12:
    printf("12 OK - two return values\nRET1: %i\nRET2: %i\n", ret1, ret2);
    break;
  case 13:
    printf("13 OK - three return values\nRET1: %i\nRET2: %i\nRET3: %i\n", ret1,
           ret2, ret3);
    break;
  case 40:
    printf("40 ERROR - command not recognized\n");
    break;
  case 41:
    printf("41 ERROR - argument 1 not recognized\n");
    break;
  case 42:
    printf("42 ERROR - argument 2 not recognized\n");
    break;
  case 43:
    printf("43 ERROR - argument 3 not recognized\n");
    break;
  case 44:
    printf("44 ERROR - argument 4 not recognized\n");
    break;
  case 45:
    printf("45 ERROR - argument 5 not recognized\n");
    break;
  case 46:
    printf("46 ERROR - camera replied with an error\n");
    break;
  case 47:
    printf("47 ERROR - camera replied with an unknown return value\n");
    break;
  default:
    printf("unknown error code: %i\n", errorcode);
  }
  close_interface();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <process_commandline@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
call   1040 <open_interface@plt>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1080 <doCommand@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x25,%eax
ja     12c4 <main+0x164>
mov    -0x30(%rbp),%rax
lea    0xe3b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d5 <main+0x175>
mov    -0x20(%rbp),%esi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d5 <main+0x175>
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d5 <main+0x175>
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d5 <main+0x175>
lea    0xf06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d5 <main+0x175>
lea    0xf16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d5 <main+0x175>
lea    0xf29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d5 <main+0x175>
lea    0xf3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d5 <main+0x175>
lea    0xf4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d5 <main+0x175>
lea    0xf62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d5 <main+0x175>
lea    0xf75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d5 <main+0x175>
lea    0xf8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d5 <main+0x175>
mov    -0x1c(%rbp),%esi
lea    0xfad(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <close_interface@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
call   1060 <process_commandline@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <open_interface@plt>
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
call   1090 <doCommand@plt>
lea    -0xa(%rax),%ecx
cmp    $0x25,%ecx
ja     1200 <main+0x90>
lea    0xe56(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0x10b8(%rip),%rdi
jmp    1258 <main+0xe8>
mov    0x4(%rsp),%esi
lea    0xece(%rip),%rdi
jmp    1209 <main+0x99>
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0xee0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    125d <main+0xed>
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xef1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    125d <main+0xed>
lea    0xf19(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    125d <main+0xed>
lea    0x1037(%rip),%rdi
jmp    1258 <main+0xe8>
lea    0x1009(%rip),%rdi
jmp    1258 <main+0xe8>
lea    0xfdb(%rip),%rdi
jmp    1258 <main+0xe8>
lea    0xfad(%rip),%rdi
jmp    1258 <main+0xe8>
lea    0xf7f(%rip),%rdi
jmp    1258 <main+0xe8>
lea    0xf51(%rip),%rdi
jmp    1258 <main+0xe8>
lea    0xf20(%rip),%rdi
jmp    1258 <main+0xe8>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <close_interface@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"10 OK - no return value\0A\00"
@.str.1 = [35 x i8] c"11 OK - one return value\0ARET1: %i\0A\00"
@.str.2 = [45 x i8] c"12 OK - two return values\0ARET1: %i\0ARET2: %i\0A\00"
@.str.3 = [56 x i8] c"13 OK - three return values\0ARET1: %i\0ARET2: %i\0ARET3: %i\0A\00"
@.str.4 = [35 x i8] c"40 ERROR - command not recognized\0A\00"
@.str.5 = [38 x i8] c"41 ERROR - argument 1 not recognized\0A\00"
@.str.6 = [38 x i8] c"42 ERROR - argument 2 not recognized\0A\00"
@.str.7 = [38 x i8] c"43 ERROR - argument 3 not recognized\0A\00"
@.str.8 = [38 x i8] c"44 ERROR - argument 4 not recognized\0A\00"
@.str.9 = [38 x i8] c"45 ERROR - argument 5 not recognized\0A\00"
@.str.10 = [41 x i8] c"46 ERROR - camera replied with an error\0A\00"
@.str.11 = [56 x i8] c"47 ERROR - camera replied with an unknown return value\0A\00"
@.str.12 = [24 x i8] c"unknown error code: %i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i8* @process_commandline(i32 %11, i8** %12)
store i8* %13, i8** %6
%14 = call i32 (...) @open_interface()
%15 = load i8*, i8** %6
%16 = call i32 @doCommand(i8* %15, i32* %8, i32* %9, i32* %10)
store i32 %16, i32* %7
%17 = load i32, i32* %7
switch i32 %17, label %48 [
i32 10, label %18
i32 11, label %20
i32 12, label %23
i32 13, label %27
i32 40, label %32
i32 41, label %34
i32 42, label %36
i32 43, label %38
i32 44, label %40
i32 45, label %42
i32 46, label %44
i32 47, label %46
]
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %51
20: ; preds = %2
%21 = load i32, i32* %8
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %51
23: ; preds = %2
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
br label %51
27: ; preds = %2
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = load i32, i32* %10
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %29, i32 %30)
br label %51
32: ; preds = %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
br label %51
34: ; preds = %2
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
br label %51
36: ; preds = %2
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
br label %51
38: ; preds = %2
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0))
br label %51
40: ; preds = %2
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
br label %51
42: ; preds = %2
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
br label %51
44: ; preds = %2
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0))
br label %51
46: ; preds = %2
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.11, i64 0, i64 0))
br label %51
48: ; preds = %2
%49 = load i32, i32* %7
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %48, %46, %44, %42, %40, %38, %36, %34, %32, %27, %23, %20, %18
%52 = call i32 (...) @close_interface()
%53 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.1 = [35 x i8] c"11 OK - one return value\0ARET1: %i\0A\00"
@.str.2 = [45 x i8] c"12 OK - two return values\0ARET1: %i\0ARET2: %i\0A\00"
@.str.3 = [56 x i8] c"13 OK - three return values\0ARET1: %i\0ARET2: %i\0ARET3: %i\0A\00"
@.str.12 = [24 x i8] c"unknown error code: %i\0A\00"
@str = [55 x i8] c"47 ERROR - camera replied with an unknown return value\00"
@str.13 = [40 x i8] c"46 ERROR - camera replied with an error\00"
@str.14 = [37 x i8] c"45 ERROR - argument 5 not recognized\00"
@str.15 = [37 x i8] c"44 ERROR - argument 4 not recognized\00"
@str.16 = [37 x i8] c"43 ERROR - argument 3 not recognized\00"
@str.17 = [37 x i8] c"42 ERROR - argument 2 not recognized\00"
@str.18 = [37 x i8] c"41 ERROR - argument 1 not recognized\00"
@str.19 = [34 x i8] c"40 ERROR - command not recognized\00"
@str.20 = [24 x i8] c"10 OK - no return value\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = tail call i8* @process_commandline(i32 %0, i8** %1)
%10 = tail call i32 (...) @open_interface()
%11 = call i32 @doCommand(i8* %9, i32* %3, i32* %4, i32* %5)
switch i32 %11, label %42 [
i32 10, label %12
i32 11, label %14
i32 12, label %17
i32 13, label %21
i32 40, label %26
i32 41, label %28
i32 42, label %30
i32 43, label %32
i32 44, label %34
i32 45, label %36
i32 46, label %38
i32 47, label %40
]
12: ; preds = %2
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.20, i64 0, i64 0))
br label %44
14: ; preds = %2
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %44
17: ; preds = %2
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
br label %44
21: ; preds = %2
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %23, i32 %24)
br label %44
26: ; preds = %2
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.19, i64 0, i64 0))
br label %44
28: ; preds = %2
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.18, i64 0, i64 0))
br label %44
30: ; preds = %2
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.17, i64 0, i64 0))
br label %44
32: ; preds = %2
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.16, i64 0, i64 0))
br label %44
34: ; preds = %2
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.15, i64 0, i64 0))
br label %44
36: ; preds = %2
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.14, i64 0, i64 0))
br label %44
38: ; preds = %2
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.13, i64 0, i64 0))
br label %44
40: ; preds = %2
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
br label %44
42: ; preds = %2
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i32 %11)
br label %44
44: ; preds = %42, %40, %38, %36, %34, %32, %30, %28, %26, %21, %17, %14, %12
%45 = call i32 (...) @close_interface()
%46 = call i32 @exit(i32 0)
unreachable
}