#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() {
  int num;
  printf("Enter a number: ");
  scanf("%d", &num);
  if (num < 0 || num > 9999)
    printf("ERROR: Too many digits");
  else if (num > 999)
    printf("The number %d has 4 digits", num);
  else if (num > 99)
    printf("The number %d has 3 digits", num);
  else if (num > 9)
    printf("The number %d has 2 digits", num);
  else
    printf("The number %d has 1 digit", 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)
jl     1164 <main+0x44>
cmpl   $0x270f,-0x8(%rbp)
jle    1177 <main+0x57>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fa <main+0xda>
cmpl   $0x3e7,-0x8(%rbp)
jle    119a <main+0x7a>
mov    -0x8(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f5 <main+0xd5>
cmpl   $0x63,-0x8(%rbp)
jle    11ba <main+0x9a>
mov    -0x8(%rbp),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f0 <main+0xd0>
cmpl   $0x9,-0x8(%rbp)
jle    11da <main+0xba>
mov    -0x8(%rbp),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11eb <main+0xcb>
mov    -0x8(%rbp),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f0 <main+0xd0>
jmp    11f5 <main+0xd5>
jmp    11fa <main+0xda>
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
cmp    $0x2710,%esi
jb     115c <main+0x3c>
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1197 <main+0x77>
cmp    $0x3e8,%esi
jb     116d <main+0x4d>
lea    0xec0(%rip),%rdi
jmp    1190 <main+0x70>
cmp    $0x64,%esi
jb     117b <main+0x5b>
lea    0xecd(%rip),%rdi
jmp    1190 <main+0x70>
cmp    $0xa,%esi
jb     1189 <main+0x69>
lea    0xeda(%rip),%rdi
jmp    1190 <main+0x70>
lea    0xeec(%rip),%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 = [23 x i8] c"ERROR: Too many digits\00"
@.str.3 = [27 x i8] c"The number %d has 4 digits\00"
@.str.4 = [27 x i8] c"The number %d has 3 digits\00"
@.str.5 = [27 x i8] c"The number %d has 2 digits\00"
@.str.6 = [26 x i8] c"The number %d has 1 digit\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 slt i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 9999
br i1 %9, label %10, label %12
10: ; preds = %7, %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %36
12: ; preds = %7
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 999
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %16)
br label %35
18: ; preds = %12
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 99
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %22)
br label %34
24: ; preds = %18
%25 = load i32, i32* %2
%26 = icmp sgt i32 %25, 9
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %28)
br label %33
30: ; preds = %24
%31 = load i32, i32* %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %27
br label %34
34: ; preds = %33, %21
br label %35
35: ; preds = %34, %15
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 = [23 x i8] c"ERROR: Too many digits\00"
@.str.3 = [27 x i8] c"The number %d has 4 digits\00"
@.str.4 = [27 x i8] c"The number %d has 3 digits\00"
@.str.5 = [27 x i8] c"The number %d has 2 digits\00"
@.str.6 = [26 x i8] c"The number %d has 1 digit\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 ugt i32 %5, 9999
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %23
9: ; preds = %0
%10 = icmp ugt i32 %5, 999
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %5)
br label %23
13: ; preds = %9
%14 = icmp ugt i32 %5, 99
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %5)
br label %23
17: ; preds = %13
%18 = icmp ugt i32 %5, 9
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %5)
br label %23
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %5)
br label %23
23: ; preds = %11, %19, %21, %15, %7
ret i32 0
}