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

/* Variables and functions */
uint32_t get_int(int i, uint32_t integer) {
  uint32_t tmp;
  if (i == 0) {
    return 0;
  }
  if (i == 1) {
    tmp = 0;
    tmp = (integer & 0xFF);
    return tmp;
  }
  if (i == 2) {
    tmp = 0;
    tmp = (integer >> 8 & 0xFF);
    return tmp;
  }
  if (i == 3) {
    tmp = 0;
    tmp = (integer >> 16) & 0xFF;
    return tmp;
  }
  if (i == 4) {
    tmp = 0;
    tmp = (integer >> 24);
    return tmp;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_int>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1120 <get_int+0x20>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <get_int+0xc7>
cmpl   $0x1,-0x8(%rbp)
jne    1147 <get_int+0x47>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <get_int+0xc7>
cmpl   $0x2,-0x8(%rbp)
jne    1171 <get_int+0x71>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <get_int+0xc7>
cmpl   $0x3,-0x8(%rbp)
jne    119b <get_int+0x9b>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <get_int+0xc7>
cmpl   $0x4,-0x8(%rbp)
jne    11c0 <get_int+0xc0>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x18,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <get_int+0xc7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_int>:
add    $0xffffffff,%edi
cmp    $0x3,%edi
ja     111e <get_int+0x1e>
mov    %esi,%eax
lea    0xeef(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
movzbl %al,%eax
ret
xor    %eax,%eax
ret
movzbl %ah,%eax
ret
shr    $0x10,%eax
movzbl %al,%eax
ret
sar    $0x18,%eax
ret

LLVM IR (-O0):
define i32 @get_int(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 0, i32* %3
br label %41
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %17
13: ; preds = %10
store i32 0, i32* %6
%14 = load i32, i32* %5
%15 = and i32 %14, 255
store i32 %15, i32* %6
%16 = load i32, i32* %6
store i32 %16, i32* %3
br label %41
17: ; preds = %10
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %25
20: ; preds = %17
store i32 0, i32* %6
%21 = load i32, i32* %5
%22 = ashr i32 %21, 8
%23 = and i32 %22, 255
store i32 %23, i32* %6
%24 = load i32, i32* %6
store i32 %24, i32* %3
br label %41
25: ; preds = %17
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 3
br i1 %27, label %28, label %33
28: ; preds = %25
store i32 0, i32* %6
%29 = load i32, i32* %5
%30 = ashr i32 %29, 16
%31 = and i32 %30, 255
store i32 %31, i32* %6
%32 = load i32, i32* %6
store i32 %32, i32* %3
br label %41
33: ; preds = %25
%34 = load i32, i32* %4
%35 = icmp eq i32 %34, 4
br i1 %35, label %36, label %40
36: ; preds = %33
store i32 0, i32* %6
%37 = load i32, i32* %5
%38 = ashr i32 %37, 24
store i32 %38, i32* %6
%39 = load i32, i32* %6
store i32 %39, i32* %3
br label %41
40: ; preds = %33
store i32 0, i32* %3
br label %41
41: ; preds = %40, %36, %28, %20, %13, %9
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
define i32 @get_int(i32 %0, i32 %1) {
switch i32 %0, label %13 [
i32 4, label %11
i32 1, label %3
i32 2, label %5
i32 3, label %8
]
3: ; preds = %2
%4 = and i32 %1, 255
br label %13
5: ; preds = %2
%6 = lshr i32 %1, 8
%7 = and i32 %6, 255
br label %13
8: ; preds = %2
%9 = lshr i32 %1, 16
%10 = and i32 %9, 255
br label %13
11: ; preds = %2
%12 = ashr i32 %1, 24
br label %13
13: ; preds = %2, %11, %8, %5, %3
%14 = phi i32 [ %4, %3 ], [ %7, %5 ], [ %10, %8 ], [ %12, %11 ], [ 0, %2 ]
ret i32 %14
}