#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 3:
    return "The specified device was not found";
  case 2:
    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    $0x10,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     1151 <usbErrorMessage+0x41>
jmp    112f <usbErrorMessage+0x1f>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     1171 <usbErrorMessage+0x61>
jmp    1140 <usbErrorMessage+0x30>
mov    -0x10(%rbp),%eax
sub    $0x3,%eax
je     1161 <usbErrorMessage+0x51>
jmp    1181 <usbErrorMessage+0x71>
lea    0xea8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a2 <usbErrorMessage+0x92>
lea    0xeb0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a2 <usbErrorMessage+0x92>
lea    0xec3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a2 <usbErrorMessage+0x92>
mov    -0xc(%rbp),%edx
lea    0x2eb5(%rip),%rdi
lea    0xec9(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2ea2(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usbErrorMessage>:
push   %rbx
mov    %edi,%edx
lea    -0x1(%rdx),%eax
cmp    $0x3,%eax
jae    112d <usbErrorMessage+0x1d>
cltq
lea    0xf4c(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1143 <usbErrorMessage+0x33>
lea    0x2f0c(%rip),%rbx
lea    0xf20(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
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 = [32 x i8] c"Communication error with device\00"
@.str.3 = [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 %8 [
i32 1, label %5
i32 3, label %6
i32 2, label %7
]
5: ; preds = %1
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8** %2
br label %11
6: ; preds = %1
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %11
7: ; preds = %1
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %11
8: ; preds = %1
%9 = load i32, i32* %3
%10 = 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.3, i64 0, i64 0), i32 %9)
store i8* getelementptr inbounds ([80 x i8], [80 x i8]* @usbErrorMessage.buffer, i64 0, i64 0), i8** %2
br label %11
11: ; preds = %8, %7, %6, %5
%12 = load i8*, i8** %2
ret i8* %12
}

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 = [32 x i8] c"Communication error with device\00"
@.str.3 = [21 x i8] c"Unknown USB error %d\00"
@reltable.usbErrorMessage = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.usbErrorMessage to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([32 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.usbErrorMessage to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.usbErrorMessage to i64)) to i32)]
define i8* @usbErrorMessage(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 3
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = 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.3, i64 0, i64 0), i32 %0)
br label %10
6: ; preds = %1
%7 = sext i32 %2 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.usbErrorMessage to i8*), i64 %8)
br label %10
10: ; preds = %6, %4
%11 = phi i8* [ getelementptr inbounds ([80 x i8], [80 x i8]* @usbErrorMessage.buffer, i64 0, i64 0), %4 ], [ %9, %6 ]
ret i8* %11
}