#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 long floor(int /*<<< orphan*/);
long llabs(long);
int /*<<< orphan*/ log10(long);
unsigned long int get_number_count_digits(long int number) {
  if (number < 0)
    number = llabs(number);
  else if (number == 0)
    return 1;
  if (number < 999999999999997)
    return floor(log10(number)) + 1;
  unsigned long int count = 0;
  while (number > 0) {
    ++count;
    number /= 10;
  }
  return count;
}


x86 assembly (clang, -O0):
<get_number_count_digits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    1159 <get_number_count_digits+0x29>
mov    -0x10(%rbp),%rdi
call   1030 <llabs@plt>
mov    %rax,-0x10(%rbp)
jmp    1176 <get_number_count_digits+0x46>
cmpq   $0x0,-0x10(%rbp)
jne    1171 <get_number_count_digits+0x41>
movq   $0x1,-0x8(%rbp)
jmp    11e5 <get_number_count_digits+0xb5>
jmp    1176 <get_number_count_digits+0x46>
movabs $0x38d7ea4c67ffd,%rax
cmp    %rax,-0x10(%rbp)
jge    11a7 <get_number_count_digits+0x77>
mov    -0x10(%rbp),%rdi
call   1040 <log10@plt>
mov    %eax,%edi
call   1050 <floor@plt>
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11e5 <get_number_count_digits+0xb5>
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    11dd <get_number_count_digits+0xad>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
jmp    11af <get_number_count_digits+0x7f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_number_count_digits>:
test   %rdi,%rdi
js     112d <get_number_count_digits+0xd>
jne    1130 <get_number_count_digits+0x10>
mov    $0x1,%eax
ret
neg    %rdi
movabs $0x38d7ea4c67ffd,%rax
cmp    %rax,%rdi
jae    1159 <get_number_count_digits+0x39>
push   %rax
call   1030 <log10@plt>
mov    %eax,%edi
call   1040 <floor@plt>
mov    %rax,%rcx
add    $0x1,%rcx
add    $0x8,%rsp
jmp    1187 <get_number_count_digits+0x67>
xor    %ecx,%ecx
movabs $0xcccccccccccccccd,%rsi
cc cc cc
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rcx
mov    %rdi,%rax
mul    %rsi
shr    $0x3,%rdx
cmp    $0x9,%rdi
mov    %rdx,%rdi
ja     1170 <get_number_count_digits+0x50>
mov    %rcx,%rax
ret

LLVM IR (-O0):
define i64 @get_number_count_digits(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
%5 = load i64, i64* %3
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i64, i64* %3
%9 = call i64 @llabs(i64 %8)
store i64 %9, i64* %3
br label %15
10: ; preds = %1
%11 = load i64, i64* %3
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
store i64 1, i64* %2
br label %34
14: ; preds = %10
br label %15
15: ; preds = %14, %7
%16 = load i64, i64* %3
%17 = icmp slt i64 %16, 999999999999997
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i64, i64* %3
%20 = call i32 @log10(i64 %19)
%21 = call i64 @floor(i32 %20)
%22 = add i64 %21, 1
store i64 %22, i64* %2
br label %34
23: ; preds = %15
store i64 0, i64* %4
br label %24
24: ; preds = %27, %23
%25 = load i64, i64* %3
%26 = icmp sgt i64 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i64, i64* %4
%29 = add i64 %28, 1
store i64 %29, i64* %4
%30 = load i64, i64* %3
%31 = sdiv i64 %30, 10
store i64 %31, i64* %3
br label %24
32: ; preds = %24
%33 = load i64, i64* %4
store i64 %33, i64* %2
br label %34
34: ; preds = %32, %18, %13
%35 = load i64, i64* %2
ret i64 %35
}

LLVM IR (-O2):
define i64 @get_number_count_digits(i64 %0) {
%2 = icmp slt i64 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = sub nsw i64 0, %0
br label %7
5: ; preds = %1
%6 = icmp eq i64 %0, 0
br i1 %6, label %20, label %7
7: ; preds = %5, %3
%8 = phi i64 [ %4, %3 ], [ %0, %5 ]
%9 = icmp ult i64 %8, 999999999999997
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = tail call i32 @log10(i64 %8)
%12 = tail call i64 @floor(i32 %11)
%13 = add i64 %12, 1
br label %20
14: ; preds = %7, %14
%15 = phi i64 [ %17, %14 ], [ 0, %7 ]
%16 = phi i64 [ %18, %14 ], [ %8, %7 ]
%17 = add i64 %15, 1
%18 = udiv i64 %16, 10
%19 = icmp ult i64 %16, 10
br i1 %19, label %20, label %14
20: ; preds = %14, %5, %10
%21 = phi i64 [ %13, %10 ], [ 1, %5 ], [ %17, %14 ]
ret i64 %21
}