#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 pow(int, int);
int /*<<< orphan*/ printf(char *, int);
int numsize(int n) {
  int j;
  for (j = 1; j <= 100; ++j) {
    int q;
    q = pow(10, j);
    if (n < q) {
      printf("The Number of Digits is %d\n", j);
      return j;
    }
  }
}


x86 assembly (clang, -O0):
<numsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jg     1185 <numsize+0x65>
mov    -0xc(%rbp),%esi
mov    $0xa,%edi
call   1040 <pow@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1172 <numsize+0x52>
mov    -0xc(%rbp),%esi
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1185 <numsize+0x65>
jmp    1177 <numsize+0x57>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1132 <numsize+0x12>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numsize>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    $0x5,%ebx
nopl   0x0(%rax)
lea    -0x4(%rbx),%ebp
mov    $0xa,%edi
mov    %ebp,%esi
call   1040 <pow@plt>
cmp    %r14d,%eax
jg     11a2 <numsize+0x82>
lea    -0x3(%rbx),%ebp
mov    $0xa,%edi
mov    %ebp,%esi
call   1040 <pow@plt>
cmp    %r14d,%eax
jg     11a2 <numsize+0x82>
lea    -0x2(%rbx),%ebp
mov    $0xa,%edi
mov    %ebp,%esi
call   1040 <pow@plt>
cmp    %r14d,%eax
jg     11a2 <numsize+0x82>
lea    -0x1(%rbx),%ebp
mov    $0xa,%edi
mov    %ebp,%esi
call   1040 <pow@plt>
cmp    %r14d,%eax
jg     11a2 <numsize+0x82>
mov    $0xa,%edi
mov    %ebx,%esi
call   1040 <pow@plt>
cmp    %r14d,%eax
jg     11a0 <numsize+0x80>
add    $0x5,%ebx
cmp    $0x69,%ebx
jne    1130 <numsize+0x10>
mov    $0x65,%ebp
jmp    11b0 <numsize+0x90>
mov    %ebx,%ebp
lea    0xe57(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"The Number of Digits is %d\0A\00"
define i32 @numsize(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %4
br label %6
6: ; preds = %20, %1
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 100
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i32, i32* %4
%11 = call i32 @pow(i32 10, i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* %3
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = load i32, i32* %4
%17 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %4
store i32 %18, i32* %2
br label %23
19: ; preds = %9
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %6
23: ; preds = %15, %6
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [28 x i8] c"The Number of Digits is %d\0A\00"
define i32 @numsize(i32 %0) {
br label %2
2: ; preds = %25, %1
%3 = phi i32 [ 1, %1 ], [ %26, %25 ]
%4 = tail call i32 @pow(i32 10, i32 %3)
%5 = icmp sgt i32 %4, %0
br i1 %5, label %6, label %9
6: ; preds = %21, %17, %13, %9, %2
%7 = phi i32 [ %3, %2 ], [ %10, %9 ], [ %14, %13 ], [ %18, %17 ], [ %22, %21 ]
%8 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %28
9: ; preds = %2
%10 = add nuw nsw i32 %3, 1
%11 = tail call i32 @pow(i32 10, i32 %10)
%12 = icmp sgt i32 %11, %0
br i1 %12, label %6, label %13
13: ; preds = %9
%14 = add nuw nsw i32 %3, 2
%15 = tail call i32 @pow(i32 10, i32 %14)
%16 = icmp sgt i32 %15, %0
br i1 %16, label %6, label %17
17: ; preds = %13
%18 = add nuw nsw i32 %3, 3
%19 = tail call i32 @pow(i32 10, i32 %18)
%20 = icmp sgt i32 %19, %0
br i1 %20, label %6, label %21
21: ; preds = %17
%22 = add nuw nsw i32 %3, 4
%23 = tail call i32 @pow(i32 10, i32 %22)
%24 = icmp sgt i32 %23, %0
br i1 %24, label %6, label %25
25: ; preds = %21
%26 = add nuw nsw i32 %3, 5
%27 = icmp eq i32 %26, 101
br i1 %27, label %28, label %2
28: ; preds = %25, %6
%29 = phi i32 [ %7, %6 ], [ 101, %25 ]
ret i32 %29
}