#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 */
typedef int /*<<< orphan*/ message;

/* Variables and functions */
char const *rcode2str(int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
const char *tsig_error(int error_code) {
  static char message[1000];
  switch (error_code) {
  case 0:
    return "No Error";
    break;
  case 16:
    return "Bad Signature";
    break;
  case 17:
    return "Bad Key";
    break;
  case 18:
    return "Bad Time";
    break;
  default:
    if (error_code < 16)
      return rcode2str(error_code);
    snprintf(message, sizeof(message), "Unknown Error %d", error_code);
    break;
  }
  return message;
}


x86 assembly (clang, -O0):
<tsig_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x12,%rax
ja     1190 <tsig_error+0x70>
mov    -0x18(%rbp),%rax
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d1 <tsig_error+0xb1>
lea    0xeee(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d1 <tsig_error+0xb1>
lea    0xeec(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d1 <tsig_error+0xb1>
lea    0xee4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d1 <tsig_error+0xb1>
cmpl   $0x10,-0xc(%rbp)
jge    11ab <tsig_error+0x8b>
mov    -0xc(%rbp),%edi
call   1040 <rcode2str@plt>
mov    %rax,-0x8(%rbp)
jmp    11d1 <tsig_error+0xb1>
mov    -0xc(%rbp),%ecx
lea    0x2e8b(%rip),%rdi
mov    $0x3e8,%esi
lea    0xeb3(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2e73(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tsig_error>:
push   %rbx
mov    %edi,%ecx
cmp    $0x12,%edi
ja     114a <tsig_error+0x2a>
lea    0xf1d(%rip),%rbx
mov    %ecx,%eax
lea    0xec8(%rip),%rdx
movslq (%rdx,%rax,4),%rax
add    %rdx,%rax
jmp    *%rax
lea    0xf0d(%rip),%rbx
jmp    1184 <tsig_error+0x64>
cmp    $0xf,%ecx
jg     1169 <tsig_error+0x49>
mov    %ecx,%edi
pop    %rbx
jmp    1040 <rcode2str@plt>
lea    0xf05(%rip),%rbx
jmp    1184 <tsig_error+0x64>
lea    0xf04(%rip),%rbx
jmp    1184 <tsig_error+0x64>
lea    0x2ed0(%rip),%rbx
lea    0xefd(%rip),%rdx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@tsig_error.message = internal global [1000 x i8] zeroinitializer
@.str = [9 x i8] c"No Error\00"
@.str.1 = [14 x i8] c"Bad Signature\00"
@.str.2 = [8 x i8] c"Bad Key\00"
@.str.3 = [9 x i8] c"Bad Time\00"
@.str.4 = [17 x i8] c"Unknown Error %d\00"
define i8* @tsig_error(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %9 [
i32 0, label %5
i32 16, label %6
i32 17, label %7
i32 18, label %8
]
5: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %2
br label %19
6: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %19
7: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %19
8: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %19
9: ; preds = %1
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 16
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %3
%14 = call i8* @rcode2str(i32 %13)
store i8* %14, i8** %2
br label %19
15: ; preds = %9
%16 = load i32, i32* %3
%17 = call i32 @snprintf(i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @tsig_error.message, i64 0, i64 0), i32 1000, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %15
store i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @tsig_error.message, i64 0, i64 0), i8** %2
br label %19
19: ; preds = %18, %12, %8, %7, %6, %5
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
@tsig_error.message = internal global [1000 x i8] zeroinitializer
@.str = [9 x i8] c"No Error\00"
@.str.1 = [14 x i8] c"Bad Signature\00"
@.str.2 = [8 x i8] c"Bad Key\00"
@.str.3 = [9 x i8] c"Bad Time\00"
@.str.4 = [17 x i8] c"Unknown Error %d\00"
define i8* @tsig_error(i32 %0) {
switch i32 %0, label %5 [
i32 0, label %11
i32 16, label %2
i32 17, label %3
i32 18, label %4
]
2: ; preds = %1
br label %11
3: ; preds = %1
br label %11
4: ; preds = %1
br label %11
5: ; preds = %1
%6 = icmp slt i32 %0, 16
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i8* @rcode2str(i32 %0)
br label %11
9: ; preds = %5
%10 = tail call i32 @snprintf(i8* getelementptr inbounds ([1000 x i8], [1000 x i8]* @tsig_error.message, i64 0, i64 0), i32 1000, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %0)
br label %11
11: ; preds = %1, %9, %7, %4, %3, %2
%12 = phi i8* [ %8, %7 ], [ getelementptr inbounds ([1000 x i8], [1000 x i8]* @tsig_error.message, i64 0, i64 0), %9 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %12
}