#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int current_exponent = 1, digits = 1, input_number;
  int keep_testing = 1;
  printf("Enter a number: ");
  scanf("%d", &input_number);
  while (keep_testing == 1) {
    if (input_number / current_exponent > 10) {
      current_exponent *= 10;
      digits++;
      keep_testing = 1;
    } else {
      keep_testing = 0;
    }
  }
  printf("The number %d has %d digits.\n", input_number, digits);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    11a4 <main+0x84>
mov    -0x10(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0xa,%eax
jle    1198 <main+0x78>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    119f <main+0x7f>
movl   $0x0,-0x14(%rbp)
jmp    1162 <main+0x42>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
mov    $0x1,%ecx
cmp    $0xb,%esi
jl     1172 <main+0x52>
mov    $0x1,%ecx
mov    $0x1,%edi
nopl   0x0(%rax,%rax,1)
add    $0x1,%ecx
add    %edi,%edi
lea    (%rdi,%rdi,4),%edi
mov    %esi,%eax
cltd
idiv   %edi
cmp    $0xa,%eax
jg     1160 <main+0x40>
lea    0xe9b(%rip),%rdi
mov    %ecx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"The number %d has %d digits.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 1, i32* %3
store i32 1, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %8
8: ; preds = %22, %0
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i32, i32* %4
%13 = load i32, i32* %2
%14 = sdiv i32 %12, %13
%15 = icmp sgt i32 %14, 10
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* %2
%18 = mul nsw i32 %17, 10
store i32 %18, i32* %2
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
store i32 1, i32* %5
br label %22
21: ; preds = %11
store i32 0, i32* %5
br label %22
22: ; preds = %21, %16
br label %8
23: ; preds = %8
%24 = load i32, i32* %4
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"The number %d has %d digits.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 10
br i1 %6, label %7, label %14
7: ; preds = %0, %7
%8 = phi i32 [ %10, %7 ], [ 1, %0 ]
%9 = phi i32 [ %11, %7 ], [ 1, %0 ]
%10 = add nuw nsw i32 %8, 1
%11 = mul nsw i32 %9, 10
%12 = sdiv i32 %5, %11
%13 = icmp sgt i32 %12, 10
br i1 %13, label %7, label %14
14: ; preds = %7, %0
%15 = phi i32 [ 1, %0 ], [ %10, %7 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %5, i32 %15)
ret i32 0
}