#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 EBUSY;
int ENOMEM;
int ETIMEDOUT;
int mapThreadErrorCode(int rc) {
  if (rc == 0)
    return 0;
  if (rc == ETIMEDOUT)
    return -4;
  if (rc == ENOMEM)
    return -2;
  if (rc == EBUSY)
    return -3;
  return -1;
}


x86 assembly (clang, -O0):
<mapThreadErrorCode>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    111d <mapThreadErrorCode+0x1d>
movl   $0x0,-0x4(%rbp)
jmp    117e <mapThreadErrorCode+0x7e>
mov    -0x8(%rbp),%eax
mov    0x2eb1(%rip),%rcx
cmp    (%rcx),%eax
jne    113b <mapThreadErrorCode+0x3b>
movl   $0xfffffffc,-0x4(%rbp)
jmp    117e <mapThreadErrorCode+0x7e>
mov    -0x8(%rbp),%eax
mov    0x2e9b(%rip),%rcx
cmp    (%rcx),%eax
jne    1159 <mapThreadErrorCode+0x59>
movl   $0xfffffffe,-0x4(%rbp)
jmp    117e <mapThreadErrorCode+0x7e>
mov    -0x8(%rbp),%eax
mov    0x2e6d(%rip),%rcx
cmp    (%rcx),%eax
jne    1177 <mapThreadErrorCode+0x77>
movl   $0xfffffffd,-0x4(%rbp)
jmp    117e <mapThreadErrorCode+0x7e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mapThreadErrorCode>:
test   %edi,%edi
je     1138 <mapThreadErrorCode+0x38>
mov    0x2ecd(%rip),%rcx
mov    $0xfffffffc,%eax
cmp    %edi,(%rcx)
je     1137 <mapThreadErrorCode+0x37>
mov    0x2ec5(%rip),%rcx
mov    $0xfffffffe,%eax
cmp    %edi,(%rcx)
je     1137 <mapThreadErrorCode+0x37>
mov    0x2ea5(%rip),%rcx
xor    %eax,%eax
cmp    %edi,(%rcx)
setne  %al
add    %eax,%eax
or     $0xfffffffd,%eax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@ETIMEDOUT = global i32 0
@ENOMEM = global i32 0
@EBUSY = global i32 0
define i32 @mapThreadErrorCode(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 0, i32* %2
br label %23
7: ; preds = %1
%8 = load i32, i32* %3
%9 = load i32, i32* @ETIMEDOUT
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 -4, i32* %2
br label %23
12: ; preds = %7
%13 = load i32, i32* %3
%14 = load i32, i32* @ENOMEM
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 -2, i32* %2
br label %23
17: ; preds = %12
%18 = load i32, i32* %3
%19 = load i32, i32* @EBUSY
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 -3, i32* %2
br label %23
22: ; preds = %17
store i32 -1, i32* %2
br label %23
23: ; preds = %22, %21, %16, %11, %6
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@ETIMEDOUT = global i32 0
@ENOMEM = global i32 0
@EBUSY = global i32 0
define i32 @mapThreadErrorCode(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = load i32, i32* @ETIMEDOUT
%5 = icmp eq i32 %4, %0
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = load i32, i32* @ENOMEM
%8 = icmp eq i32 %7, %0
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = load i32, i32* @EBUSY
%11 = icmp eq i32 %10, %0
%12 = select i1 %11, i32 -3, i32 -1
br label %13
13: ; preds = %9, %6, %3, %1
%14 = phi i32 [ 0, %1 ], [ -4, %3 ], [ -2, %6 ], [ %12, %9 ]
ret i32 %14
}