#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 number = 0;
  printf("enter a number(0-32767):\n");
  scanf("%d", &number);
  printf("the number %d has", number);
  if (number < 10) {
    printf(" 1 ");
  } else if (number < 100) {
    printf(" 2 ");
  } else if (number < 1000) {
    printf(" 3 ");
  } else if (number < 10000) {
    printf(" 4 ");
  } else {
    printf(" 5 ");
  }
  printf("digits\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xa,-0x8(%rbp)
jge    1182 <main+0x62>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fc <main+0xdc>
cmpl   $0x64,-0x8(%rbp)
jge    119f <main+0x7f>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f7 <main+0xd7>
cmpl   $0x3e8,-0x8(%rbp)
jge    11bf <main+0x9f>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f2 <main+0xd2>
cmpl   $0x2710,-0x8(%rbp)
jge    11df <main+0xbf>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ed <main+0xcd>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f2 <main+0xd2>
jmp    11f7 <main+0xd7>
jmp    11fc <main+0xdc>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
cmp    $0xa,%eax
jge    117a <main+0x4a>
lea    0xe9d(%rip),%rdi
jmp    11af <main+0x7f>
cmp    $0x64,%eax
jae    1188 <main+0x58>
lea    0xe93(%rip),%rdi
jmp    11af <main+0x7f>
cmp    $0x3e8,%eax
jae    1198 <main+0x68>
lea    0xe87(%rip),%rdi
jmp    11af <main+0x7f>
cmp    $0x2710,%eax
lea    0xe7d(%rip),%rax
lea    0xe7a(%rip),%rdi
cmovb  %rax,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"enter a number(0-32767):\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"the number %d has\00"
@.str.3 = [4 x i8] c" 1 \00"
@.str.4 = [4 x i8] c" 2 \00"
@.str.5 = [4 x i8] c" 3 \00"
@.str.6 = [4 x i8] c" 4 \00"
@.str.7 = [4 x i8] c" 5 \00"
@.str.8 = [8 x i8] c"digits\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %31
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 100
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %30
16: ; preds = %11
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 1000
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %29
21: ; preds = %16
%22 = load i32, i32* %2
%23 = icmp slt i32 %22, 10000
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %28
26: ; preds = %21
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %28
28: ; preds = %26, %24
br label %29
29: ; preds = %28, %19
br label %30
30: ; preds = %29, %14
br label %31
31: ; preds = %30, %9
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"the number %d has\00"
@.str.3 = [4 x i8] c" 1 \00"
@.str.4 = [4 x i8] c" 2 \00"
@.str.5 = [4 x i8] c" 3 \00"
@.str.6 = [4 x i8] c" 4 \00"
@.str.7 = [4 x i8] c" 5 \00"
@str = [25 x i8] c"enter a number(0-32767):\00"
@str.9 = [7 x i8] c"digits\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 10
br i1 %8, label %16, label %9
9: ; preds = %0
%10 = icmp ult i32 %7, 100
br i1 %10, label %16, label %11
11: ; preds = %9
%12 = icmp ult i32 %7, 1000
br i1 %12, label %16, label %13
13: ; preds = %11
%14 = icmp ult i32 %7, 10000
%15 = select i1 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
br label %16
16: ; preds = %13, %11, %9, %0
%17 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %9 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), %11 ], [ %15, %13 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %17)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.9, i64 0, i64 0))
ret i32 0
}