#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 ULLONG_MAX;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, unsigned long long *);
int main() {
  unsigned long long number = 0;
  printf("Enter the number(less than %llu):", ULLONG_MAX / 2);
  scanf("%lld", &number);
  int counter = 0;
  while (number) {
    number = number / 10;
    counter++;
  }
  printf("%d\n", counter);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1198 <main+0x78>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <main+0x4d>
mov    -0x14(%rbp),%esi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movq   $0x0,(%rsp)
mov    0x2eb8(%rip),%rax
mov    (%rax),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%rdx
xor    %esi,%esi
test   %rdx,%rdx
je     118a <main+0x6a>
movabs $0xcccccccccccccccd,%rdi
cc cc cc
nopl   0x0(%rax,%rax,1)
mov    %rdx,%rcx
mov    %rdx,%rax
mul    %rdi
shr    $0x3,%rdx
add    $0x1,%esi
cmp    $0x9,%rcx
ja     1170 <main+0x50>
mov    %rdx,(%rsp)
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Enter the number(less than %llu):\00"
@ULLONG_MAX = global i32 0
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %2
%4 = load i32, i32* @ULLONG_MAX
%5 = sdiv i32 %4, 2
%6 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
store i32 0, i32* %3
br label %8
8: ; preds = %11, %0
%9 = load i64, i64* %2
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = load i64, i64* %2
%13 = udiv i64 %12, 10
store i64 %13, i64* %2
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %8
16: ; preds = %8
%17 = load i32, i32* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"Enter the number(less than %llu):\00"
@ULLONG_MAX = global i32 0
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%3 = load i32, i32* @ULLONG_MAX
%4 = sdiv i32 %3, 2
%5 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%7 = load i64, i64* %1
%8 = icmp eq i64 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %0, %9
%10 = phi i32 [ %13, %9 ], [ 0, %0 ]
%11 = phi i64 [ %12, %9 ], [ %7, %0 ]
%12 = udiv i64 %11, 10
%13 = add nuw nsw i32 %10, 1
%14 = icmp ult i64 %11, 10
br i1 %14, label %15, label %9
15: ; preds = %9
store i64 %12, i64* %1
br label %16
16: ; preds = %15, %0
%17 = phi i32 [ %13, %15 ], [ 0, %0 ]
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
ret i32 0
}