#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 */
typedef int /*<<< orphan*/ humble;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int SHRT_MAX;
scalar_t__ isHumble(int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf_s(char *, int, char *, int);
size_t strlen(char *);
int main() {
  int limit = SHRT_MAX;
  int humble[16];
  int count = 0;
  int num = 1;
  char buffer[16];
  memset(humble, 0, sizeof(humble));
  for (; count < limit; num++) {
    if (isHumble(num)) {
      size_t len;
      sprintf_s(buffer, sizeof(buffer), "%d", num);
      len = strlen(buffer);
      if (len >= 16) {
        break;
      }
      humble[len]++;
      if (count < 50) {
        printf("%d ", num);
      }
      count++;
    }
  }
  printf("\n\n");
  printf("Of the first %d humble numbers:\n", count);
  for (num = 1; num < 10; num++) {
    printf("%5d have %d digits\n", humble[num], num);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x1,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
mov    -0x54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1225 <main+0xd5>
mov    -0x58(%rbp),%edi
call   1070 <isHumble@plt>
cmp    $0x0,%rax
je     1212 <main+0xc2>
lea    -0x70(%rbp),%rdi
mov    -0x58(%rbp),%ecx
mov    $0x10,%esi
lea    0xe43(%rip),%rdx
call   1030 <sprintf_s@plt>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x10,-0x78(%rbp)
jb     11df <main+0x8f>
jmp    1225 <main+0xd5>
mov    -0x78(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x50(%rbp,%rax,4)
cmpl   $0x32,-0x54(%rbp)
jge    1209 <main+0xb9>
mov    -0x58(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1217 <main+0xc7>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    118c <main+0x3c>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x54(%rbp),%esi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x58(%rbp)
cmpl   $0xa,-0x58(%rbp)
jge    127c <main+0x12c>
movslq -0x58(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%esi
mov    -0x58(%rbp),%edx
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    124b <main+0xfb>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    0x2e6b(%rip),%rax
mov    (%rax),%r13d
mov    %rsp,%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
test   %r13d,%r13d
jle    11fe <main+0x9e>
mov    $0x1,%ebp
lea    0xe66(%rip),%r14
lea    0x40(%rsp),%r15
lea    0xe5d(%rip),%r12
xor    %ebx,%ebx
jmp    11bb <main+0x5b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
add    $0x1,%ebp
cmp    %r13d,%ebx
jge    11fe <main+0x9e>
mov    %ebp,%edi
call   1080 <isHumble@plt>
test   %rax,%rax
je     11b3 <main+0x53>
mov    %r15,%rdi
mov    $0x10,%esi
mov    %r14,%rdx
mov    %ebp,%ecx
call   1030 <sprintf_s@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
cmp    $0xf,%rax
ja     11fe <main+0x9e>
addl   $0x1,(%rsp,%rax,4)
cmp    $0x31,%ebx
jg     11b0 <main+0x50>
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11b0 <main+0x50>
lea    0xe21(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf6(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xe03(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
mov    $0x2,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
mov    $0x3,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
mov    $0x5,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
mov    $0x6,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
mov    $0x7,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
mov    $0x8,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
mov    $0x9,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SHRT_MAX = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
@.str.3 = [33 x i8] c"Of the first %d humble numbers:\0A\00"
@.str.4 = [20 x i8] c"%5d have %d digits\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [16 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [16 x i8]
%7 = alloca i64
store i32 0, i32* %1
%8 = load i32, i32* @SHRT_MAX
store i32 %8, i32* %2
store i32 0, i32* %4
store i32 1, i32* %5
%9 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%10 = call i32 @memset(i32* %9, i32 0, i32 64)
br label %11
11: ; preds = %42, %0
%12 = load i32, i32* %4
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %45
15: ; preds = %11
%16 = load i32, i32* %5
%17 = call i64 @isHumble(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %41
19: ; preds = %15
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%21 = load i32, i32* %5
%22 = call i32 @sprintf_s(i8* %20, i32 16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%24 = call i64 @strlen(i8* %23)
store i64 %24, i64* %7
%25 = load i64, i64* %7
%26 = icmp uge i64 %25, 16
br i1 %26, label %27, label %28
27: ; preds = %19
br label %45
28: ; preds = %19
%29 = load i64, i64* %7
%30 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
%33 = load i32, i32* %4
%34 = icmp slt i32 %33, 50
br i1 %34, label %35, label %38
35: ; preds = %28
%36 = load i32, i32* %5
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %28
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %41
41: ; preds = %38, %15
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %11
45: ; preds = %27, %11
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32, i32* %4
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %47)
store i32 1, i32* %5
br label %49
49: ; preds = %59, %45
%50 = load i32, i32* %5
%51 = icmp slt i32 %50, 10
br i1 %51, label %52, label %62
52: ; preds = %49
%53 = load i32, i32* %5
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = load i32, i32* %5
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %56, i32 %57)
br label %59
59: ; preds = %52
%60 = load i32, i32* %5
%61 = add nsw i32 %60, 1
store i32 %61, i32* %5
br label %49
62: ; preds = %49
ret i32 0
}

LLVM IR (-O2):
@SHRT_MAX = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.3 = [33 x i8] c"Of the first %d humble numbers:\0A\00"
@.str.4 = [20 x i8] c"%5d have %d digits\0A\00"
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [16 x i32]
%2 = alloca [16 x i8]
%3 = load i32, i32* @SHRT_MAX
%4 = bitcast [16 x i32]* %1 to i8*
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
%7 = call i32 @memset(i32* %6, i32 0, i32 64)
%8 = icmp sgt i32 %3, 0
br i1 %8, label %9, label %31
9: ; preds = %0, %27
%10 = phi i32 [ %29, %27 ], [ 1, %0 ]
%11 = phi i32 [ %28, %27 ], [ 0, %0 ]
%12 = call i64 @isHumble(i32 %10)
%13 = icmp eq i64 %12, 0
br i1 %13, label %27, label %14
14: ; preds = %9
%15 = call i32 @sprintf_s(i8* %5, i32 16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%16 = call i64 @strlen(i8* %5)
%17 = icmp ugt i64 %16, 15
br i1 %17, label %31, label %18
18: ; preds = %14
%19 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 %16
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
store i32 %21, i32* %19
%22 = icmp slt i32 %11, 50
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %25
25: ; preds = %18, %23
%26 = add nsw i32 %11, 1
br label %27
27: ; preds = %25, %9
%28 = phi i32 [ %11, %9 ], [ %26, %25 ]
%29 = add nuw nsw i32 %10, 1
%30 = icmp slt i32 %28, %3
br i1 %30, label %9, label %31
31: ; preds = %27, %14, %0
%32 = phi i32 [ 0, %0 ], [ %11, %14 ], [ %28, %27 ]
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%35 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 1
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %36, i32 1)
%38 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 2
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %39, i32 2)
%41 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 3
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %42, i32 3)
%44 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 4
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %45, i32 4)
%47 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 5
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %48, i32 5)
%50 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 6
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %51, i32 6)
%53 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 7
%54 = load i32, i32* %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %54, i32 7)
%56 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 8
%57 = load i32, i32* %56
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %57, i32 8)
%59 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 9
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %60, i32 9)
ret i32 0
}