#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*/ ft_putnbr_base(int, char *);
int /*<<< orphan*/ ft_putstr(char *);
void hexa_line(int n) {
  if (n == 0)
    ft_putstr("0000000");
  else if (n == 16 || n < 256)
    ft_putstr("000000");
  else if (n == 256 || n < 4096)
    ft_putstr("00000");
  else if (n == 4096 || n < 65536)
    ft_putstr("0000");
  else if (n == 65536 || n < 1048576)
    ft_putstr("000");
  else if (n == 1048576 || n < 16777216)
    ft_putstr("00");
  else if (n == 16777216 || n < 268435456)
    ft_putstr("0");
  ft_putnbr_base(n, "0123456789abcdef");
}


x86 assembly (clang, -O0):
<hexa_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1146 <hexa_line+0x26>
lea    0xec4(%rip),%rdi
call   1040 <ft_putstr@plt>
jmp    125e <hexa_line+0x13e>
cmpl   $0x10,-0x4(%rbp)
je     115d <hexa_line+0x3d>
cmpl   $0x100,-0x4(%rbp)
jge    116e <hexa_line+0x4e>
lea    0xe9d(%rip),%rdi
call   1040 <ft_putstr@plt>
jmp    1259 <hexa_line+0x139>
cmpl   $0x100,-0x4(%rbp)
je     1188 <hexa_line+0x68>
cmpl   $0x1000,-0x4(%rbp)
jge    1199 <hexa_line+0x79>
lea    0xe73(%rip),%rdi
call   1040 <ft_putstr@plt>
jmp    1254 <hexa_line+0x134>
cmpl   $0x1000,-0x4(%rbp)
je     11b3 <hexa_line+0x93>
cmpl   $0x10000,-0x4(%rbp)
jge    11c4 <hexa_line+0xa4>
lea    0xe49(%rip),%rdi
call   1040 <ft_putstr@plt>
jmp    124f <hexa_line+0x12f>
cmpl   $0x10000,-0x4(%rbp)
je     11de <hexa_line+0xbe>
cmpl   $0x100000,-0x4(%rbp)
jge    11ef <hexa_line+0xcf>
lea    0xe1f(%rip),%rdi
call   1040 <ft_putstr@plt>
jmp    124a <hexa_line+0x12a>
cmpl   $0x100000,-0x4(%rbp)
je     1209 <hexa_line+0xe9>
cmpl   $0x1000000,-0x4(%rbp)
jge    121a <hexa_line+0xfa>
lea    0xdf5(%rip),%rdi
call   1040 <ft_putstr@plt>
jmp    1245 <hexa_line+0x125>
cmpl   $0x1000000,-0x4(%rbp)
je     1234 <hexa_line+0x114>
cmpl   $0x10000000,-0x4(%rbp)
jge    1240 <hexa_line+0x120>
lea    0xdcb(%rip),%rdi
call   1040 <ft_putstr@plt>
jmp    1245 <hexa_line+0x125>
jmp    124a <hexa_line+0x12a>
jmp    124f <hexa_line+0x12f>
jmp    1254 <hexa_line+0x134>
jmp    1259 <hexa_line+0x139>
jmp    125e <hexa_line+0x13e>
mov    -0x4(%rbp),%edi
lea    0xda0(%rip),%rsi
call   1030 <ft_putnbr_base@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexa_line>:
push   %rbx
mov    %edi,%ebx
test   %edi,%edi
je     1138 <hexa_line+0x18>
cmp    $0x100,%ebx
jge    1141 <hexa_line+0x21>
lea    0xecb(%rip),%rdi
jmp    1194 <hexa_line+0x74>
lea    0xec1(%rip),%rdi
jmp    1194 <hexa_line+0x74>
cmp    $0x1000,%ebx
jae    1152 <hexa_line+0x32>
lea    0xeb2(%rip),%rdi
jmp    1194 <hexa_line+0x74>
cmp    $0x10000,%ebx
jae    1163 <hexa_line+0x43>
lea    0xea2(%rip),%rdi
jmp    1194 <hexa_line+0x74>
cmp    $0x100000,%ebx
jae    1174 <hexa_line+0x54>
lea    0xe92(%rip),%rdi
jmp    1194 <hexa_line+0x74>
cmp    $0x1000000,%ebx
jae    1185 <hexa_line+0x65>
lea    0xe82(%rip),%rdi
jmp    1194 <hexa_line+0x74>
cmp    $0xfffffff,%ebx
ja     1199 <hexa_line+0x79>
lea    0xe72(%rip),%rdi
call   1040 <ft_putstr@plt>
lea    0xe68(%rip),%rsi
mov    %ebx,%edi
pop    %rbx
jmp    1030 <ft_putnbr_base@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"0000000\00"
@.str.1 = [7 x i8] c"000000\00"
@.str.2 = [6 x i8] c"00000\00"
@.str.3 = [5 x i8] c"0000\00"
@.str.4 = [4 x i8] c"000\00"
@.str.5 = [3 x i8] c"00\00"
@.str.6 = [2 x i8] c"0\00"
@.str.7 = [17 x i8] c"0123456789abcdef\00"
define void @hexa_line(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 @ft_putstr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %61
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 16
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 256
br i1 %12, label %13, label %15
13: ; preds = %10, %7
%14 = call i32 @ft_putstr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %60
15: ; preds = %10
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 256
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 4096
br i1 %20, label %21, label %23
21: ; preds = %18, %15
%22 = call i32 @ft_putstr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %59
23: ; preds = %18
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 4096
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32, i32* %2
%28 = icmp slt i32 %27, 65536
br i1 %28, label %29, label %31
29: ; preds = %26, %23
%30 = call i32 @ft_putstr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %58
31: ; preds = %26
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 65536
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i32, i32* %2
%36 = icmp slt i32 %35, 1048576
br i1 %36, label %37, label %39
37: ; preds = %34, %31
%38 = call i32 @ft_putstr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %57
39: ; preds = %34
%40 = load i32, i32* %2
%41 = icmp eq i32 %40, 1048576
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = load i32, i32* %2
%44 = icmp slt i32 %43, 16777216
br i1 %44, label %45, label %47
45: ; preds = %42, %39
%46 = call i32 @ft_putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %56
47: ; preds = %42
%48 = load i32, i32* %2
%49 = icmp eq i32 %48, 16777216
br i1 %49, label %53, label %50
50: ; preds = %47
%51 = load i32, i32* %2
%52 = icmp slt i32 %51, 268435456
br i1 %52, label %53, label %55
53: ; preds = %50, %47
%54 = call i32 @ft_putstr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %55
55: ; preds = %53, %50
br label %56
56: ; preds = %55, %45
br label %57
57: ; preds = %56, %37
br label %58
58: ; preds = %57, %29
br label %59
59: ; preds = %58, %21
br label %60
60: ; preds = %59, %13
br label %61
61: ; preds = %60, %5
%62 = load i32, i32* %2
%63 = call i32 @ft_putnbr_base(i32 %62, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"0000000\00"
@.str.1 = [7 x i8] c"000000\00"
@.str.2 = [6 x i8] c"00000\00"
@.str.3 = [5 x i8] c"0000\00"
@.str.4 = [4 x i8] c"000\00"
@.str.5 = [3 x i8] c"00\00"
@.str.6 = [2 x i8] c"0\00"
@.str.7 = [17 x i8] c"0123456789abcdef\00"
define void @hexa_line(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %15, label %3
3: ; preds = %1
%4 = icmp slt i32 %0, 256
br i1 %4, label %15, label %5
5: ; preds = %3
%6 = icmp ult i32 %0, 4096
br i1 %6, label %15, label %7
7: ; preds = %5
%8 = icmp ult i32 %0, 65536
br i1 %8, label %15, label %9
9: ; preds = %7
%10 = icmp ult i32 %0, 1048576
br i1 %10, label %15, label %11
11: ; preds = %9
%12 = icmp ult i32 %0, 16777216
br i1 %12, label %15, label %13
13: ; preds = %11
%14 = icmp ult i32 %0, 268435456
br i1 %14, label %15, label %18
15: ; preds = %13, %11, %9, %7, %5, %3, %1
%16 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %7 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %9 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %11 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), %13 ]
%17 = tail call i32 @ft_putstr(i8* %16)
br label %18
18: ; preds = %15, %13
%19 = tail call i32 @ft_putnbr_base(i32 %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
ret void
}