#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 errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int);
void print_fsq_err(char *fn_name, int rc) {
  switch (rc) {
  case 0:
    break;
  case -1:
    fprintf(stderr, "%s() failed (timeout)\n", fn_name);
    break;
  case -2:
    fprintf(stderr, "%s() failed (errno=%d: %s)\n", fn_name, errno,
            strerror(errno));
    break;
  case -3:
    fprintf(stderr, "%s() failed (internal err)\n", fn_name);
    break;
  case -4:
    fprintf(stderr, "%s() failed (user err)\n", fn_name);
    break;
  case -5:
    fprintf(stderr, "%s() failed (already in use)\n", fn_name);
    break;
  default:
    fprintf(stderr, "%s() failed error=%d\n", fn_name, rc);
    break;
  }
}


x86 assembly (clang, -O0):
<print_fsq_err>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     122b <print_fsq_err+0x10b>
mov    -0x18(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1249 <print_fsq_err+0x129>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1249 <print_fsq_err+0x129>
mov    0x2e5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e40(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
call   1040 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    %rax,%r8
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1249 <print_fsq_err+0x129>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1249 <print_fsq_err+0x129>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1249 <print_fsq_err+0x129>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1249 <print_fsq_err+0x129>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_fsq_err>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ecx
mov    %rdi,%rbx
lea    0x5(%rcx),%eax
cmp    $0x5,%eax
ja     1156 <print_fsq_err+0x36>
lea    0xec8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
lea    0xf2e(%rip),%rsi
jmp    11df <print_fsq_err+0xbf>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    0xf37(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fprintf@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xee3(%rip),%rsi
jmp    11df <print_fsq_err+0xbf>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xeb5(%rip),%rsi
jmp    11df <print_fsq_err+0xbf>
mov    0x2e41(%rip),%rax
mov    (%rax),%r14d
mov    0x2e2f(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1040 <strerror@plt>
lea    0xe76(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %ebp,%ecx
mov    %rax,%r8
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fprintf@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
lea    0xe39(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fprintf@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"%s() failed (timeout)\0A\00"
@.str.1 = [28 x i8] c"%s() failed (errno=%d: %s)\0A\00"
@errno = global i32 0
@.str.2 = [28 x i8] c"%s() failed (internal err)\0A\00"
@.str.3 = [24 x i8] c"%s() failed (user err)\0A\00"
@.str.4 = [30 x i8] c"%s() failed (already in use)\0A\00"
@.str.5 = [22 x i8] c"%s() failed error=%d\0A\00"
define void @print_fsq_err(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
switch i32 %5, label %30 [
i32 0, label %6
i32 -1, label %7
i32 -2, label %11
i32 -3, label %18
i32 -4, label %22
i32 -5, label %26
]
6: ; preds = %2
br label %35
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %3
%10 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %35
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %3
%14 = load i32, i32* @errno
%15 = load i32, i32* @errno
%16 = call i8* @strerror(i32 %15)
%17 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %13, i32 %14, i8* %16)
br label %35
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %3
%21 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %35
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %3
%25 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %35
26: ; preds = %2
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %3
%29 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %28)
br label %35
30: ; preds = %2
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %3
%33 = load i32, i32* %4
%34 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %32, i32 %33)
br label %35
35: ; preds = %30, %26, %22, %18, %11, %7, %6
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"%s() failed (timeout)\0A\00"
@.str.1 = [28 x i8] c"%s() failed (errno=%d: %s)\0A\00"
@errno = global i32 0
@.str.2 = [28 x i8] c"%s() failed (internal err)\0A\00"
@.str.3 = [24 x i8] c"%s() failed (user err)\0A\00"
@.str.4 = [30 x i8] c"%s() failed (already in use)\0A\00"
@.str.5 = [22 x i8] c"%s() failed error=%d\0A\00"
define void @print_fsq_err(i8* %0, i32 %1) {
switch i32 %1, label %20 [
i32 0, label %23
i32 -1, label %3
i32 -2, label %6
i32 -3, label %11
i32 -4, label %14
i32 -5, label %17
]
3: ; preds = %2
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %23
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = tail call i8* @strerror(i32 %8)
%10 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %8, i8* %9)
br label %23
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %23
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %23
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %23
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %0, i32 %1)
br label %23
23: ; preds = %20, %17, %14, %11, %6, %3, %2
ret void
}