#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*/ printout_number_under1000(int, int);
void printout_number_under1000000(int N, int separator) {
  if (N < 1000)
    printout_number_under1000(N, 1);
  else {
    printout_number_under1000(N / 1000, 0);
    printf(" thousand");
    if (N % 1000) {
      if (separator && N % 1000 < 100)
        printf(" and ");
      else
        printf(" ");
      printout_number_under1000(N % 1000, 1);
    }
  }
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jge    114d <printout_number_under1000000+0x2d>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1030 <printout_number_under1000@plt>
jmp    11d8 <printout_number_under1000000+0xb8>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
xor    %esi,%esi
call   1030 <printout_number_under1000@plt>
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11d3 <printout_number_under1000000+0xb3>
cmpl   $0x0,-0x8(%rbp)
je     11b0 <printout_number_under1000000+0x90>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x64,%edx
jge    11b0 <printout_number_under1000000+0x90>
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
jmp    11bc <printout_number_under1000000+0x9c>
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
mov    $0x1,%esi
call   1030 <printout_number_under1000@plt>
jmp    11d8 <printout_number_under1000000+0xb8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
cmp    $0x3e8,%edi
jl     1194 <printout_number_under1000000+0x64>
mov    %esi,%r14d
mov    %ebx,%eax
imul   $0x10624dd3,%rax,%rbp
shr    $0x26,%rbp
mov    %ebp,%edi
xor    %esi,%esi
call   1040 <printout_number_under1000@plt>
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
imul   $0x3e8,%ebp,%eax
sub    %eax,%ebx
je     1185 <printout_number_under1000000+0x55>
test   %r14d,%r14d
je     118a <printout_number_under1000000+0x5a>
cmp    $0x63,%ebx
ja     118a <printout_number_under1000000+0x5a>
lea    0xe8c(%rip),%rdi
call   1050 <printf@plt>
jmp    1194 <printout_number_under1000000+0x64>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    $0x1,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printout_number_under1000@plt>

LLVM IR (-O0):
@.str = [10 x i8] c" thousand\00"
@.str.1 = [6 x i8] c" and \00"
@.str.2 = [2 x i8] c" \00"
define void @printout_number_under1000000(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 1000
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* %3
%9 = call i32 @printout_number_under1000(i32 %8, i32 1)
br label %34
10: ; preds = %2
%11 = load i32, i32* %3
%12 = sdiv i32 %11, 1000
%13 = call i32 @printout_number_under1000(i32 %12, i32 0)
%14 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %3
%16 = srem i32 %15, 1000
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %33
18: ; preds = %10
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = load i32, i32* %3
%23 = srem i32 %22, 1000
%24 = icmp slt i32 %23, 100
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %29
27: ; preds = %21, %18
%28 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
%30 = load i32, i32* %3
%31 = srem i32 %30, 1000
%32 = call i32 @printout_number_under1000(i32 %31, i32 1)
br label %33
33: ; preds = %29, %10
br label %34
34: ; preds = %33, %7
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c" thousand\00"
@.str.1 = [6 x i8] c" and \00"
define void @printout_number_under1000000(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 1000
br i1 %3, label %18, label %4
4: ; preds = %2
%5 = udiv i32 %0, 1000
%6 = tail call i32 @printout_number_under1000(i32 %5, i32 0)
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = urem i32 %0, 1000
%9 = icmp eq i32 %8, 0
br i1 %9, label %21, label %10
10: ; preds = %4
%11 = icmp ne i32 %1, 0
%12 = icmp ult i32 %8, 100
%13 = and i1 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %18
16: ; preds = %10
%17 = tail call i32 @putchar(i32 32)
br label %18
18: ; preds = %14, %16, %2
%19 = phi i32 [ %0, %2 ], [ %8, %16 ], [ %8, %14 ]
%20 = tail call i32 @printout_number_under1000(i32 %19, i32 1)
br label %21
21: ; preds = %18, %4
ret void
}