#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*/ sprintf(char *, char *, int);
char *usbErrorMessage(int errCode) {
  static char buffer[80];
  switch (errCode) {
  case 1:
    return "Access to device denied";
  case 2:
    return "The specified device was not found";
  case 16:
    return "The device is used by another application";
  case 5:
    return "Communication error with device";
  default:
    sprintf(buffer, "Unknown USB error %d", errCode);
    return buffer;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<usbErrorMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xf,%eax
ja     1184 <usbErrorMessage+0x74>
mov    -0x18(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <usbErrorMessage+0x95>
lea    0xefd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <usbErrorMessage+0x95>
lea    0xf10(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <usbErrorMessage+0x95>
lea    0xf2a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <usbErrorMessage+0x95>
mov    -0xc(%rbp),%edx
lea    0x2eb2(%rip),%rdi
lea    0xf30(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2e9f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usbErrorMessage>:
push   %rbx
mov    %edi,%edx
lea    -0x1(%rdx),%eax
cmp    $0xf,%eax
ja     113b <usbErrorMessage+0x2b>
lea    0xf1e(%rip),%rbx
lea    0xed7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf1f(%rip),%rbx
jmp    1163 <usbErrorMessage+0x53>
lea    0x2efe(%rip),%rbx
lea    0xf7c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
jmp    1163 <usbErrorMessage+0x53>
lea    0xf4b(%rip),%rbx
jmp    1163 <usbErrorMessage+0x53>
lea    0xf18(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@usbErrorMessage.buffer = internal global [80 x i8] zeroinitializer
@.str = [24 x i8] c"Access to device denied\00"
@.str.1 = [35 x i8] c"The specified device was not found\00"
@.str.2 = [42 x i8] c"The device is used by another application\00"
@.str.3 = [32 x i8] c"Communication error with device\00"
@.str.4 = [21 x i8] c"Unknown USB error %d\00"
define i8* @usbErrorMessage(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %9 [
i32 1, label %5
i32 2, label %6
i32 16, label %7
i32 5, label %8
]
5: ; preds = %1
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8** %2
br label %12
6: ; preds = %1
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %12
7: ; preds = %1
store i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %12
8: ; preds = %1
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %12
9: ; preds = %1
%10 = load i32, i32* %3
%11 = call i32 @sprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @usbErrorMessage.buffer, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %10)
store i8* getelementptr inbounds ([80 x i8], [80 x i8]* @usbErrorMessage.buffer, i64 0, i64 0), i8** %2
br label %12
12: ; preds = %9, %8, %7, %6, %5
%13 = load i8*, i8** %2
ret i8* %13
}

LLVM IR (-O2):
@usbErrorMessage.buffer = internal global [80 x i8] zeroinitializer
@.str = [24 x i8] c"Access to device denied\00"
@.str.1 = [35 x i8] c"The specified device was not found\00"
@.str.2 = [42 x i8] c"The device is used by another application\00"
@.str.3 = [32 x i8] c"Communication error with device\00"
@.str.4 = [21 x i8] c"Unknown USB error %d\00"
define i8* @usbErrorMessage(i32 %0) {
switch i32 %0, label %5 [
i32 1, label %7
i32 2, label %2
i32 16, label %3
i32 5, label %4
]
2: ; preds = %1
br label %7
3: ; preds = %1
br label %7
4: ; preds = %1
br label %7
5: ; preds = %1
%6 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @usbErrorMessage.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %0)
br label %7
7: ; preds = %1, %5, %4, %3, %2
%8 = phi i8* [ getelementptr inbounds ([80 x i8], [80 x i8]* @usbErrorMessage.buffer, i64 0, i64 0), %5 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %8
}