#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 num;
  printf("Enter a number: ");
  scanf("%d", &num);
  if (num > 0 && num < 9) {
    printf("The number %d has 1 digit.\n", num);
  } else if (num > 9 && num < 99) {
    printf("The number %d has 2 digits.\n", num);
  } else if (num > 99 && num < 999) {
    printf("The number %d has 3 digits.\n", num);
  } else {
    printf("The number %d has 4 digits.\n", num);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1177 <main+0x57>
cmpl   $0x9,-0x8(%rbp)
jge    1177 <main+0x57>
mov    -0x8(%rbp),%esi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e9 <main+0xc9>
cmpl   $0x9,-0x8(%rbp)
jle    11a1 <main+0x81>
cmpl   $0x63,-0x8(%rbp)
jge    11a1 <main+0x81>
mov    -0x8(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e4 <main+0xc4>
cmpl   $0x63,-0x8(%rbp)
jle    11ce <main+0xae>
cmpl   $0x3e7,-0x8(%rbp)
jge    11ce <main+0xae>
mov    -0x8(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11df <main+0xbf>
mov    -0x8(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e4 <main+0xc4>
jmp    11e9 <main+0xc9>
xor    %eax,%eax
add    $0x10,%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
lea    -0x1(%rsi),%eax
cmp    $0x8,%eax
jae    1155 <main+0x35>
lea    0xec1(%rip),%rdi
jmp    1180 <main+0x60>
lea    -0xa(%rsi),%eax
cmp    $0x59,%eax
jae    1166 <main+0x46>
lea    0xecc(%rip),%rdi
jmp    1180 <main+0x60>
lea    -0x64(%rsi),%eax
cmp    $0x383,%eax
lea    0xed8(%rip),%rax
lea    0xeee(%rip),%rdi
cmovb  %rax,%rdi
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 = [28 x i8] c"The number %d has 1 digit.\0A\00"
@.str.3 = [29 x i8] c"The number %d has 2 digits.\0A\00"
@.str.4 = [29 x i8] c"The number %d has 3 digits.\0A\00"
@.str.5 = [29 x i8] c"The number %d has 4 digits.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* 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* %2)
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 9
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %36
13: ; preds = %7, %0
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 9
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 99
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %20)
br label %35
22: ; preds = %16, %13
%23 = load i32, i32* %2
%24 = icmp sgt i32 %23, 99
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i32, i32* %2
%27 = icmp slt i32 %26, 999
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %2
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %34
31: ; preds = %25, %22
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %28
br label %35
35: ; preds = %34, %19
br label %36
36: ; preds = %35, %10
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 = [28 x i8] c"The number %d has 1 digit.\0A\00"
@.str.3 = [29 x i8] c"The number %d has 2 digits.\0A\00"
@.str.4 = [29 x i8] c"The number %d has 3 digits.\0A\00"
@.str.5 = [29 x i8] c"The number %d has 4 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 = add i32 %5, -1
%7 = icmp ult i32 %6, 8
br i1 %7, label %15, label %8
8: ; preds = %0
%9 = add i32 %5, -10
%10 = icmp ult i32 %9, 89
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = add i32 %5, -100
%13 = icmp ult i32 %12, 899
%14 = select i1 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0)
br label %15
15: ; preds = %11, %8, %0
%16 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), %0 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), %8 ], [ %14, %11 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %16, i32 %5)
ret i32 0
}