#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*/ printf(char *, ...);
void check_error(int a) {
  printf("\n\n\n\n\n");
  switch (a) {
  case -1:
    printf("## verify error\n");
    break;
  case -2:
    printf("## flash timeout error\n");
    break;
  case -3:
    printf("## product id mismatch\n");
    break;
  case -4:
    printf("## device id mismatch\n");
    break;
  case -5:
    printf("## flash write protected\n");
    break;
  default:
    printf("## PROTOCOL ERROR check serial connection 0x%x (%d)\n", a, a);
    break;
  }
}


x86 assembly (clang, -O0):
<check_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xef2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x5,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     11b1 <check_error+0xa1>
mov    -0x10(%rbp),%rax
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c5 <check_error+0xb5>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c5 <check_error+0xb5>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c5 <check_error+0xb5>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c5 <check_error+0xb5>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c5 <check_error+0xb5>
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_error>:
push   %rbx
mov    %edi,%ebx
lea    0xf1f(%rip),%rdi
call   1030 <puts@plt>
lea    0x5(%rbx),%eax
cmp    $0x4,%eax
ja     1154 <check_error+0x34>
lea    0xec2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf00(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xeb9(%rip),%rdi
mov    %ebx,%esi
mov    %ebx,%edx
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>
lea    0xef9(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xf02(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xf0c(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xf16(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"\0A\0A\0A\0A\0A\00"
@.str.1 = [17 x i8] c"## verify error\0A\00"
@.str.2 = [24 x i8] c"## flash timeout error\0A\00"
@.str.3 = [24 x i8] c"## product id mismatch\0A\00"
@.str.4 = [23 x i8] c"## device id mismatch\0A\00"
@.str.5 = [26 x i8] c"## flash write protected\0A\00"
@.str.6 = [53 x i8] c"## PROTOCOL ERROR check serial connection 0x%x (%d)\0A\00"
define void @check_error(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
switch i32 %4, label %15 [
i32 -1, label %5
i32 -2, label %7
i32 -3, label %9
i32 -4, label %11
i32 -5, label %13
]
5: ; preds = %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %19
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %19
9: ; preds = %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %19
11: ; preds = %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %19
13: ; preds = %1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %19
15: ; preds = %1
%16 = load i32, i32* %2
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i32 %16, i32 %17)
br label %19
19: ; preds = %15, %13, %11, %9, %7, %5
ret void
}

LLVM IR (-O2):
@.str.6 = [53 x i8] c"## PROTOCOL ERROR check serial connection 0x%x (%d)\0A\00"
@str = [5 x i8] c"\0A\0A\0A\0A\00"
@str.7 = [25 x i8] c"## flash write protected\00"
@str.8 = [22 x i8] c"## device id mismatch\00"
@str.9 = [23 x i8] c"## product id mismatch\00"
@str.10 = [23 x i8] c"## flash timeout error\00"
@str.11 = [16 x i8] c"## verify error\00"
define void @check_error(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
switch i32 %0, label %13 [
i32 -1, label %3
i32 -2, label %5
i32 -3, label %7
i32 -4, label %9
i32 -5, label %11
]
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
br label %15
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.10, i64 0, i64 0))
br label %15
7: ; preds = %1
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.9, i64 0, i64 0))
br label %15
9: ; preds = %1
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
br label %15
11: ; preds = %1
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.7, i64 0, i64 0))
br label %15
13: ; preds = %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i32 %0, i32 %0)
br label %15
15: ; preds = %13, %11, %9, %7, %5, %3
ret void
}