#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 */
int /*<<< orphan*/ printf(char *, int);
void print_int(int i, uint32_t integer) {
  uint32_t tmp;
  if (i == 0) {
    return;
  } else if (i == 1) {
    tmp = 0;
    tmp = (integer & 0xFF);
    printf("%d\n", tmp);
    return;
  } else if (i == 2) {
    tmp = 0;
    tmp = (integer >> 8) & 0xFF;
    printf("%d\n", tmp);
    return;
  } else if (i == 3) {
    tmp = 0;
    tmp = (integer >> 16) & 0xFF;
    printf("%u\n", tmp);
    return;
  } else if (i == 4) {
    tmp = 0;
    tmp = (integer >> 24);
    printf("%u\n", tmp);
    return;
  }
  return;
}


x86 assembly (clang, -O0):
<print_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    112d <print_int+0x1d>
jmp    120a <print_int+0xfa>
cmpl   $0x1,-0x4(%rbp)
jne    115d <print_int+0x4d>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
jmp    120a <print_int+0xfa>
cmpl   $0x2,-0x4(%rbp)
jne    1190 <print_int+0x80>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
jmp    120a <print_int+0xfa>
cmpl   $0x3,-0x4(%rbp)
jne    11c3 <print_int+0xb3>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
jmp    120a <print_int+0xfa>
cmpl   $0x4,-0x4(%rbp)
jne    11f1 <print_int+0xe1>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x18,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
jmp    120a <print_int+0xfa>
jmp    11f6 <print_int+0xe6>
jmp    11fb <print_int+0xeb>
jmp    1200 <print_int+0xf0>
jmp    1205 <print_int+0xf5>
jmp    120a <print_int+0xfa>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_int>:
add    $0xffffffff,%edi
cmp    $0x3,%edi
ja     1139 <print_int+0x29>
mov    %esi,%eax
lea    0xedf(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
movzbl %al,%esi
lea    0xedc(%rip),%rdi
jmp    1030 <printf@plt>
ret
movzbl %ah,%esi
lea    0xecc(%rip),%rdi
jmp    1030 <printf@plt>
shr    $0x10,%eax
movzbl %al,%esi
lea    0xebe(%rip),%rdi
jmp    1030 <printf@plt>
sar    $0x18,%eax
lea    0xeaf(%rip),%rdi
mov    %eax,%esi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [4 x i8] c"%u\0A\00"
define void @print_int(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
br label %48
9: ; preds = %2
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %9
store i32 0, i32* %5
%13 = load i32, i32* %4
%14 = and i32 %13, 255
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %48
17: ; preds = %9
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %26
20: ; preds = %17
store i32 0, i32* %5
%21 = load i32, i32* %4
%22 = ashr i32 %21, 8
%23 = and i32 %22, 255
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
br label %48
26: ; preds = %17
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 3
br i1 %28, label %29, label %35
29: ; preds = %26
store i32 0, i32* %5
%30 = load i32, i32* %4
%31 = ashr i32 %30, 16
%32 = and i32 %31, 255
store i32 %32, i32* %5
%33 = load i32, i32* %5
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %33)
br label %48
35: ; preds = %26
%36 = load i32, i32* %3
%37 = icmp eq i32 %36, 4
br i1 %37, label %38, label %43
38: ; preds = %35
store i32 0, i32* %5
%39 = load i32, i32* %4
%40 = ashr i32 %39, 24
store i32 %40, i32* %5
%41 = load i32, i32* %5
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %41)
br label %48
43: ; preds = %35
br label %44
44: ; preds = %43
br label %45
45: ; preds = %44
br label %46
46: ; preds = %45
br label %47
47: ; preds = %46
br label %48
48: ; preds = %47, %38, %29, %20, %12, %8
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [4 x i8] c"%u\0A\00"
define void @print_int(i32 %0, i32 %1) {
switch i32 %0, label %17 [
i32 4, label %14
i32 1, label %3
i32 2, label %6
i32 3, label %10
]
3: ; preds = %2
%4 = and i32 %1, 255
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %17
6: ; preds = %2
%7 = lshr i32 %1, 8
%8 = and i32 %7, 255
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %17
10: ; preds = %2
%11 = lshr i32 %1, 16
%12 = and i32 %11, 255
%13 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %17
14: ; preds = %2
%15 = ashr i32 %1, 24
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %2, %14, %10, %6, %3
ret void
}