#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*/ cloneStr(char *, int, char *);
int /*<<< orphan*/ getNextTrio(char *, char *, long);
int /*<<< orphan*/ nameTrio(char *, unsigned char, char, char, char);
scalar_t__ strLen(char *, long);
int /*<<< orphan*/ strMerge(char *, int, char *, long, char *, long);
int /*<<< orphan*/ strProper(char *);
void nameNumber(char *numberStr, long digits, char *numberName,
                long nameLength) {
  char trio[3];
  char trioName[51];
  unsigned char trioOrder;
  digits = strLen(numberStr, digits) - 1;
  for (trioOrder = 0; digits >= 0; digits -= 3, trioOrder++) {
    getNextTrio(trio, numberStr, digits);
    nameTrio(trioName, trioOrder, trio[2], trio[1], trio[0]);
    strMerge(trioName, 51, numberName, nameLength, numberName, nameLength);
  }
  if (strLen(numberName, nameLength) == 0) {
    cloneStr("zero", 5, numberName);
  }
  strProper(numberName);
}


x86 assembly (clang, -O0):
<nameNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strLen@plt>
sub    $0x1,%rax
mov    %rax,-0x10(%rbp)
movb   $0x0,-0x61(%rbp)
cmpq   $0x0,-0x10(%rbp)
jl     1204 <nameNumber+0xa4>
lea    -0x23(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1060 <getNextTrio@plt>
lea    -0x60(%rbp),%rdi
mov    -0x61(%rbp),%dl
mov    -0x21(%rbp),%cl
mov    -0x22(%rbp),%al
movzbl %dl,%esi
movsbl %cl,%edx
movsbl %al,%ecx
movsbl -0x23(%rbp),%r8d
call   1070 <nameTrio@plt>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    $0x33,%esi
call   1040 <strMerge@plt>
mov    -0x10(%rbp),%rax
sub    $0x3,%rax
mov    %rax,-0x10(%rbp)
mov    -0x61(%rbp),%al
add    $0x1,%al
mov    %al,-0x61(%rbp)
jmp    1191 <nameNumber+0x31>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strLen@plt>
cmp    $0x0,%rax
jne    1230 <nameNumber+0xd0>
mov    -0x18(%rbp),%rdx
lea    0xdda(%rip),%rdi
mov    $0x5,%esi
call   1080 <cloneStr@plt>
mov    -0x18(%rbp),%rdi
call   1030 <strProper@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nameNumber>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rdi,%r15
call   1050 <strLen@plt>
test   %rax,%rax
jle    11e5 <nameNumber+0x85>
mov    %rax,%rbx
add    $0x2,%rbx
xor    %ebp,%ebp
lea    0x10(%rsp),%r13
nop
add    $0xfffffffffffffffd,%rbx
lea    0xd(%rsp),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <getNextTrio@plt>
movsbl 0xf(%rsp),%edx
movsbl 0xe(%rsp),%ecx
movsbl 0xd(%rsp),%r8d
movzbl %bpl,%ebp
mov    %r13,%rdi
mov    %ebp,%esi
call   1070 <nameTrio@plt>
mov    %r13,%rdi
mov    $0x33,%esi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r14,%r8
mov    %r12,%r9
call   1040 <strMerge@plt>
add    $0x1,%bpl
cmp    $0x2,%rbx
ja     1190 <nameNumber+0x30>
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <strLen@plt>
test   %rax,%rax
jne    1209 <nameNumber+0xa9>
lea    0xe04(%rip),%rdi
mov    $0x5,%esi
mov    %r14,%rdx
call   1080 <cloneStr@plt>
mov    %r14,%rdi
call   1030 <strProper@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"zero\00"
define void @nameNumber(i8* %0, i64 %1, i8* %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca [3 x i8]
%10 = alloca [51 x i8]
%11 = alloca i8
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%12 = load i8*, i8** %5
%13 = load i64, i64* %6
%14 = call i64 @strLen(i8* %12, i64 %13)
%15 = sub nsw i64 %14, 1
store i64 %15, i64* %6
store i8 0, i8* %11
br label %16
16: ; preds = %39, %4
%17 = load i64, i64* %6
%18 = icmp sge i64 %17, 0
br i1 %18, label %19, label %44
19: ; preds = %16
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%21 = load i8*, i8** %5
%22 = load i64, i64* %6
%23 = call i32 @getNextTrio(i8* %20, i8* %21, i64 %22)
%24 = getelementptr inbounds [51 x i8], [51 x i8]* %10, i64 0, i64 0
%25 = load i8, i8* %11
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 2
%27 = load i8, i8* %26
%28 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 1
%29 = load i8, i8* %28
%30 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%31 = load i8, i8* %30
%32 = call i32 @nameTrio(i8* %24, i8 zeroext %25, i8 signext %27, i8 signext %29, i8 signext %31)
%33 = getelementptr inbounds [51 x i8], [51 x i8]* %10, i64 0, i64 0
%34 = load i8*, i8** %7
%35 = load i64, i64* %8
%36 = load i8*, i8** %7
%37 = load i64, i64* %8
%38 = call i32 @strMerge(i8* %33, i32 51, i8* %34, i64 %35, i8* %36, i64 %37)
br label %39
39: ; preds = %19
%40 = load i64, i64* %6
%41 = sub nsw i64 %40, 3
store i64 %41, i64* %6
%42 = load i8, i8* %11
%43 = add i8 %42, 1
store i8 %43, i8* %11
br label %16
44: ; preds = %16
%45 = load i8*, i8** %7
%46 = load i64, i64* %8
%47 = call i64 @strLen(i8* %45, i64 %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = load i8*, i8** %7
%51 = call i32 @cloneStr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 5, i8* %50)
br label %52
52: ; preds = %49, %44
%53 = load i8*, i8** %7
%54 = call i32 @strProper(i8* %53)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"zero\00"
define void @nameNumber(i8* %0, i64 %1, i8* %2, i64 %3) {
%5 = alloca [3 x i8]
%6 = alloca [51 x i8]
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [51 x i8], [51 x i8]* %6, i64 0, i64 0
%9 = tail call i64 @strLen(i8* %0, i64 %1)
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %4
%12 = add nsw i64 %9, -1
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 2
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 1
br label %15
15: ; preds = %11, %15
%16 = phi i8 [ 0, %11 ], [ %25, %15 ]
%17 = phi i64 [ %12, %11 ], [ %24, %15 ]
%18 = call i32 @getNextTrio(i8* %7, i8* %0, i64 %17)
%19 = load i8, i8* %13
%20 = load i8, i8* %14
%21 = load i8, i8* %7
%22 = call i32 @nameTrio(i8* %8, i8 zeroext %16, i8 signext %19, i8 signext %20, i8 signext %21)
%23 = call i32 @strMerge(i8* %8, i32 51, i8* %2, i64 %3, i8* %2, i64 %3)
%24 = add nsw i64 %17, -3
%25 = add i8 %16, 1
%26 = icmp ugt i64 %17, 2
br i1 %26, label %15, label %27
27: ; preds = %15, %4
%28 = call i64 @strLen(i8* %2, i64 %3)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @cloneStr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 5, i8* %2)
br label %32
32: ; preds = %30, %27
%33 = call i32 @strProper(i8* %2)
ret void
}