#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 higher_nums(int);
int ft_intlen(int num) {
  if (num >= 100000)
    return (higher_nums(num));
  else {
    if (num >= 1000) {
      if (num >= 10000)
        return (5);
      return (4);
    } else {
      if (num >= 100)
        return (3);
      if (num >= 10)
        return (2);
    }
    return (1);
  }
}


x86 assembly (clang, -O0):
<ft_intlen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x186a0,-0x8(%rbp)
jl     1138 <ft_intlen+0x28>
mov    -0x8(%rbp),%edi
call   1030 <higher_nums@plt>
mov    %eax,-0x4(%rbp)
jmp    11a2 <ft_intlen+0x92>
cmpl   $0x3e8,-0x8(%rbp)
jl     116a <ft_intlen+0x5a>
cmpl   $0x2710,-0x8(%rbp)
jl     115e <ft_intlen+0x4e>
movl   $0x5,-0x4(%rbp)
jmp    11a2 <ft_intlen+0x92>
movl   $0x4,-0x4(%rbp)
jmp    11a2 <ft_intlen+0x92>
cmpl   $0x64,-0x8(%rbp)
jl     1180 <ft_intlen+0x70>
movl   $0x3,-0x4(%rbp)
jmp    11a2 <ft_intlen+0x92>
cmpl   $0xa,-0x8(%rbp)
jl     1196 <ft_intlen+0x86>
movl   $0x2,-0x4(%rbp)
jmp    11a2 <ft_intlen+0x92>
jmp    119b <ft_intlen+0x8b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_intlen>:
cmp    $0x186a0,%edi
jl     111d <ft_intlen+0xd>
jmp    1030 <higher_nums@plt>
cmp    $0x3e8,%edi
jl     1134 <ft_intlen+0x24>
xor    %eax,%eax
cmp    $0x2710,%edi
setae  %al
or     $0x4,%eax
ret
mov    $0x3,%eax
cmp    $0x63,%edi
jg     1149 <ft_intlen+0x39>
xor    %eax,%eax
cmp    $0xa,%edi
setge  %al
add    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @ft_intlen(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sge i32 %4, 100000
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* %3
%8 = call i32 @higher_nums(i32 %7)
store i32 %8, i32* %2
br label %27
9: ; preds = %1
%10 = load i32, i32* %3
%11 = icmp sge i32 %10, 1000
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* %3
%14 = icmp sge i32 %13, 10000
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 5, i32* %2
br label %27
16: ; preds = %12
store i32 4, i32* %2
br label %27
17: ; preds = %9
%18 = load i32, i32* %3
%19 = icmp sge i32 %18, 100
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 3, i32* %2
br label %27
21: ; preds = %17
%22 = load i32, i32* %3
%23 = icmp sge i32 %22, 10
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 2, i32* %2
br label %27
25: ; preds = %21
br label %26
26: ; preds = %25
store i32 1, i32* %2
br label %27
27: ; preds = %26, %24, %20, %16, %15, %6
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
define i32 @ft_intlen(i32 %0) {
%2 = icmp sgt i32 %0, 99999
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @higher_nums(i32 %0)
br label %15
5: ; preds = %1
%6 = icmp sgt i32 %0, 999
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = icmp ugt i32 %0, 9999
%9 = select i1 %8, i32 5, i32 4
br label %15
10: ; preds = %5
%11 = icmp sgt i32 %0, 99
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = icmp sgt i32 %0, 9
%14 = select i1 %13, i32 2, i32 1
br label %15
15: ; preds = %12, %10, %7, %3
%16 = phi i32 [ %4, %3 ], [ %9, %7 ], [ 3, %10 ], [ %14, %12 ]
ret i32 %16
}