#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 */
unsigned int ft_pop_sign(int, int *);
int ft_count_digits(int n) {
  int i;
  unsigned int cur;
  int sign;
  i = 0;
  cur = ft_pop_sign(n, &sign);
  if (n == 0)
    return (1);
  while (cur >= 1) {
    cur /= 10;
    i++;
  }
  return (i);
}


x86 assembly (clang, -O0):
<ft_count_digits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x14(%rbp),%rsi
call   1030 <ft_pop_sign@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1147 <ft_count_digits+0x37>
movl   $0x1,-0x4(%rbp)
jmp    1179 <ft_count_digits+0x69>
jmp    114c <ft_count_digits+0x3c>
cmpl   $0x1,-0x10(%rbp)
jb     1173 <ft_count_digits+0x63>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114c <ft_count_digits+0x3c>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_count_digits>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xc(%rsp),%rsi
call   1030 <ft_pop_sign@plt>
test   %ebx,%ebx
je     1156 <ft_count_digits+0x46>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
je     115b <ft_count_digits+0x4b>
mov    $0xcccccccd,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,%esi
imul   %rdx,%rsi
shr    $0x23,%rsi
add    $0x1,%eax
cmp    $0x9,%ecx
mov    %esi,%ecx
ja     1140 <ft_count_digits+0x30>
jmp    115b <ft_count_digits+0x4b>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ft_count_digits(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
%7 = load i32, i32* %3
%8 = call i32 @ft_pop_sign(i32 %7, i32* %6)
store i32 %8, i32* %5
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 1, i32* %2
br label %23
12: ; preds = %1
br label %13
13: ; preds = %16, %12
%14 = load i32, i32* %5
%15 = icmp uge i32 %14, 1
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i32, i32* %5
%18 = udiv i32 %17, 10
store i32 %18, i32* %5
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %13
21: ; preds = %13
%22 = load i32, i32* %4
store i32 %22, i32* %2
br label %23
23: ; preds = %21, %11
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
define i32 @ft_count_digits(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @ft_pop_sign(i32 %0, i32* %2)
%5 = icmp eq i32 %0, 0
br i1 %5, label %14, label %6
6: ; preds = %1
%7 = icmp eq i32 %4, 0
br i1 %7, label %14, label %8
8: ; preds = %6, %8
%9 = phi i32 [ %11, %8 ], [ %4, %6 ]
%10 = phi i32 [ %12, %8 ], [ 0, %6 ]
%11 = udiv i32 %9, 10
%12 = add nuw nsw i32 %10, 1
%13 = icmp ult i32 %9, 10
br i1 %13, label %14, label %8
14: ; preds = %8, %6, %1
%15 = phi i32 [ 1, %1 ], [ 0, %6 ], [ %12, %8 ]
ret i32 %15
}