#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 *str_err(int status) {
  switch (status) {
  case 1:
    return "File transfer was stopped";
  case 4:
    return "File skipped";
  case 5:
    return "CRC failed - file not transferred correctly";
  case 6:
    return "Error while reading file";
  case 7:
    return "Error while writing file - disk read-only or full?";
  case 8:
    return "Error deleting file - check if it's not read-only";
  case 9:
    return "Error creating directory";
  default: {
    static char tmptxt[16];
    sprintf(tmptxt, "Error #%d", status);
    return tmptxt;
  }
  }
}


x86 assembly (clang, -O0):
<str_err>:
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    $0x8,%eax
ja     11b4 <str_err+0xa4>
mov    -0x18(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d5 <str_err+0xc5>
lea    0xee3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d5 <str_err+0xc5>
lea    0xee0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d5 <str_err+0xc5>
lea    0xefc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d5 <str_err+0xc5>
lea    0xf05(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d5 <str_err+0xc5>
lea    0xf28(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d5 <str_err+0xc5>
lea    0xf4a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d5 <str_err+0xc5>
mov    -0xc(%rbp),%edx
lea    0x2e82(%rip),%rdi
lea    0xf49(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2e6f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_err>:
push   %rbx
mov    %edi,%edx
lea    -0x1(%rdx),%eax
cmp    $0x9,%eax
jae    1125 <str_err+0x15>
mov    $0x1f9,%ecx
bt     %eax,%ecx
jb     113d <str_err+0x2d>
lea    0x2f14(%rip),%rbx
lea    0xfb7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
jmp    114d <str_err+0x3d>
cltq
lea    0xfae(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"File transfer was stopped\00"
@.str.1 = [13 x i8] c"File skipped\00"
@.str.2 = [44 x i8] c"CRC failed - file not transferred correctly\00"
@.str.3 = [25 x i8] c"Error while reading file\00"
@.str.4 = [51 x i8] c"Error while writing file - disk read-only or full?\00"
@.str.5 = [50 x i8] c"Error deleting file - check if it's not read-only\00"
@.str.6 = [25 x i8] c"Error creating directory\00"
@str_err.tmptxt = internal global [16 x i8] zeroinitializer
@.str.7 = [10 x i8] c"Error #%d\00"
define i8* @str_err(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %12 [
i32 1, label %5
i32 4, label %6
i32 5, label %7
i32 6, label %8
i32 7, label %9
i32 8, label %10
i32 9, label %11
]
5: ; preds = %1
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8** %2
br label %15
6: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %15
7: ; preds = %1
store i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %15
8: ; preds = %1
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %15
9: ; preds = %1
store i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %15
10: ; preds = %1
store i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %15
11: ; preds = %1
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %15
12: ; preds = %1
%13 = load i32, i32* %3
%14 = call i32 @sprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str_err.tmptxt, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %13)
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str_err.tmptxt, i64 0, i64 0), i8** %2
br label %15
15: ; preds = %12, %11, %10, %9, %8, %7, %6, %5
%16 = load i8*, i8** %2
ret i8* %16
}

LLVM IR (-O2):
@.str = [26 x i8] c"File transfer was stopped\00"
@.str.1 = [13 x i8] c"File skipped\00"
@.str.2 = [44 x i8] c"CRC failed - file not transferred correctly\00"
@.str.3 = [25 x i8] c"Error while reading file\00"
@.str.4 = [51 x i8] c"Error while writing file - disk read-only or full?\00"
@.str.5 = [50 x i8] c"Error deleting file - check if it's not read-only\00"
@.str.6 = [25 x i8] c"Error creating directory\00"
@str_err.tmptxt = internal global [16 x i8] zeroinitializer
@.str.7 = [10 x i8] c"Error #%d\00"
@reltable.str_err = [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str to i64), i64 ptrtoint ([9 x i32]* @reltable.str_err to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str to i64), i64 ptrtoint ([9 x i32]* @reltable.str_err to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str to i64), i64 ptrtoint ([9 x i32]* @reltable.str_err to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.1 to i64), i64 ptrtoint ([9 x i32]* @reltable.str_err to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([44 x i8]* @.str.2 to i64), i64 ptrtoint ([9 x i32]* @reltable.str_err to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.3 to i64), i64 ptrtoint ([9 x i32]* @reltable.str_err to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([51 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.str_err to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([50 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.str_err to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.str_err to i64)) to i32)]
define i8* @str_err(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 9
br i1 %3, label %6, label %4
4: ; preds = %6, %1
%5 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str_err.tmptxt, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %0)
br label %15
6: ; preds = %1
%7 = trunc i32 %2 to i16
%8 = lshr i16 505, %7
%9 = and i16 %8, 1
%10 = icmp eq i16 %9, 0
br i1 %10, label %4, label %11
11: ; preds = %6
%12 = sext i32 %2 to i64
%13 = shl i64 %12, 2
%14 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.str_err to i8*), i64 %13)
br label %15
15: ; preds = %11, %4
%16 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @str_err.tmptxt, i64 0, i64 0), %4 ], [ %14, %11 ]
ret i8* %16
}