#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ cf_disable_chain(unsigned int);
int /*<<< orphan*/ mark_disable_link(unsigned int);
int /*<<< orphan*/ reset_all_links(unsigned int);
unsigned check_return_code(unsigned chain_id, unsigned link_offset,
                           unsigned return_code) {
  unsigned return_value;
  switch (return_code) {
  case 0:
    return_value = 1;
    break;
  case 1:
    return_value = 0;
    break;
  case 2:
    return_value = 1;
    mark_disable_link(link_offset);
    break;
  case 3:
    return_value = 0;
    reset_all_links(chain_id);
    break;
  case 4:
    return_value = 0;
    cf_disable_chain(chain_id);
    break;
  default:
    assert(0);
  }
  return return_value;
}


x86 assembly (clang, -O0):
<check_return_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x4,%rax
ja     11ca <check_return_code+0x8a>
mov    -0x18(%rbp),%rax
lea    0xe93(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x10(%rbp)
jmp    11d1 <check_return_code+0x91>
movl   $0x0,-0x10(%rbp)
jmp    11d1 <check_return_code+0x91>
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <mark_disable_link@plt>
jmp    11d1 <check_return_code+0x91>
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <reset_all_links@plt>
jmp    11d1 <check_return_code+0x91>
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <cf_disable_chain@plt>
jmp    11d1 <check_return_code+0x91>
xor    %edi,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_return_code>:
push   %rbx
cmp    $0x4,%edx
ja     1166 <check_return_code+0x26>
mov    $0x1,%ebx
mov    %edx,%eax
lea    0xeac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %esi,%edi
call   1030 <mark_disable_link@plt>
jmp    117d <check_return_code+0x3d>
xor    %edi,%edi
call   1040 <assert@plt>
jmp    117d <check_return_code+0x3d>
call   1060 <reset_all_links@plt>
jmp    117b <check_return_code+0x3b>
call   1050 <cf_disable_chain@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @check_return_code(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
switch i32 %8, label %20 [
i32 0, label %9
i32 1, label %10
i32 2, label %11
i32 3, label %14
i32 4, label %17
]
9: ; preds = %3
store i32 1, i32* %7
br label %22
10: ; preds = %3
store i32 0, i32* %7
br label %22
11: ; preds = %3
store i32 1, i32* %7
%12 = load i32, i32* %5
%13 = call i32 @mark_disable_link(i32 %12)
br label %22
14: ; preds = %3
store i32 0, i32* %7
%15 = load i32, i32* %4
%16 = call i32 @reset_all_links(i32 %15)
br label %22
17: ; preds = %3
store i32 0, i32* %7
%18 = load i32, i32* %4
%19 = call i32 @cf_disable_chain(i32 %18)
br label %22
20: ; preds = %3
%21 = call i32 @assert(i32 0)
br label %22
22: ; preds = %20, %17, %14, %11, %10, %9
%23 = load i32, i32* %7
ret i32 %23
}

LLVM IR (-O2):
define i32 @check_return_code(i32 %0, i32 %1, i32 %2) {
switch i32 %2, label %11 [
i32 0, label %13
i32 1, label %4
i32 2, label %5
i32 3, label %7
i32 4, label %9
]
4: ; preds = %3
br label %13
5: ; preds = %3
%6 = tail call i32 @mark_disable_link(i32 %1)
br label %13
7: ; preds = %3
%8 = tail call i32 @reset_all_links(i32 %0)
br label %13
9: ; preds = %3
%10 = tail call i32 @cf_disable_chain(i32 %0)
br label %13
11: ; preds = %3
%12 = tail call i32 @assert(i32 0)
br label %13
13: ; preds = %3, %11, %9, %7, %5, %4
%14 = phi i32 [ undef, %11 ], [ 0, %9 ], [ 0, %7 ], [ 1, %5 ], [ 0, %4 ], [ 1, %3 ]
ret i32 %14
}