#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 uint8_t;

/* Variables and functions */
int update_byte(int, int, int);
uint8_t set_bit_rate(uint8_t config, uint8_t rate) {
  switch (rate) {
  case 12:
    config = update_byte(config, 2, 0);
    config = update_byte(config, 3, 0);
    break;
  case 14:
    config = update_byte(config, 2, 1);
    config = update_byte(config, 3, 0);
    break;
  case 16:
    config = update_byte(config, 2, 0);
    config = update_byte(config, 3, 1);
    break;
  case 18:
    config = update_byte(config, 2, 1);
    config = update_byte(config, 3, 1);
    break;
  default:
    break;
  }
  return (config);
}


x86 assembly (clang, -O0):
<set_bit_rate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xfffffff4,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     11f7 <set_bit_rate+0xe7>
mov    -0x10(%rbp),%rax
lea    0xec2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
xor    %edx,%edx
call   1030 <update_byte@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
xor    %edx,%edx
call   1030 <update_byte@plt>
mov    %eax,-0x4(%rbp)
jmp    11fc <set_bit_rate+0xec>
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <update_byte@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
xor    %edx,%edx
call   1030 <update_byte@plt>
mov    %eax,-0x4(%rbp)
jmp    11fc <set_bit_rate+0xec>
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
xor    %edx,%edx
call   1030 <update_byte@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1030 <update_byte@plt>
mov    %eax,-0x4(%rbp)
jmp    11fc <set_bit_rate+0xec>
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <update_byte@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1030 <update_byte@plt>
mov    %eax,-0x4(%rbp)
jmp    11fc <set_bit_rate+0xec>
jmp    11fc <set_bit_rate+0xec>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_bit_rate>:
add    $0xfffffff4,%esi
cmp    $0x6,%esi
ja     1122 <set_bit_rate+0x12>
mov    $0x55,%eax
bt     %esi,%eax
jb     1125 <set_bit_rate+0x15>
mov    %edi,%eax
ret
push   %rbx
movslq %esi,%rax
lea    0xed0(%rip),%rcx
mov    (%rcx,%rax,4),%edx
lea    0xee2(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
mov    $0x2,%esi
call   1030 <update_byte@plt>
mov    %eax,%edi
mov    $0x3,%esi
mov    %ebx,%edx
pop    %rbx
jmp    1030 <update_byte@plt>

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

LLVM IR (-O2):
@switch.table.set_bit_rate = [7 x i32] [i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 1]
@switch.table.set_bit_rate.1 = [7 x i32] [i32 0, i32 0, i32 0, i32 0, i32 1, i32 0, i32 1]
define i32 @set_bit_rate(i32 %0, i32 %1) {
%3 = add i32 %1, -12
%4 = icmp ult i32 %3, 7
br i1 %4, label %5, label %19
5: ; preds = %2
%6 = trunc i32 %3 to i8
%7 = lshr i8 85, %6
%8 = and i8 %7, 1
%9 = icmp eq i8 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %5
%11 = sext i32 %3 to i64
%12 = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.set_bit_rate, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = sext i32 %3 to i64
%15 = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.set_bit_rate.1, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = tail call i32 @update_byte(i32 %0, i32 2, i32 %13)
%18 = tail call i32 @update_byte(i32 %17, i32 3, i32 %16)
br label %19
19: ; preds = %5, %2, %10
%20 = phi i32 [ %0, %2 ], [ %18, %10 ], [ %0, %5 ]
ret i32 %20
}