#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*/ buf;

/* Variables and functions */
scalar_t__ isdigit(char const);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
const char *conv_udf_name(const char *cmd) {
  static const char *nums[] = {"ZERO", "ONE", "TWO",   "THREE", "FOUR",
                               "FIVE", "SIX", "SEVEN", "EIGHT", "NINE"};
  static char buf[256];
  char *p = buf;
  while (*cmd != '\0')
    if (isdigit(*cmd)) {
      if (p + strlen(nums[*cmd - '0']) + 1 >= buf + sizeof(buf))
        break;
      strcpy(p, nums[*cmd - '0']);
      p += strlen(p);
      cmd++;
    } else {
      *p++ = *cmd++;
    }
  *p = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<conv_udf_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f5d(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1230 <conv_udf_name+0x100>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1209 <conv_udf_name+0xd9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
movslq %eax,%rcx
lea    0x2eb7(%rip),%rax
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x1,%rax
lea    0x2ef7(%rip),%rcx
add    $0x100,%rcx
cmp    %rcx,%rax
jb     11be <conv_udf_name+0x8e>
jmp    1230 <conv_udf_name+0x100>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
movslq %eax,%rcx
lea    0x2e6a(%rip),%rax
mov    (%rax,%rcx,8),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    122b <conv_udf_name+0xfb>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1147 <conv_udf_name+0x17>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e62(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_udf_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     11c5 <conv_udf_name+0x95>
mov    %rdi,%rbx
lea    0x2f04(%rip),%r14
lea    0x2c7d(%rip),%r15
lea    0x2ff6(%rip),%r12
jmp    1173 <conv_udf_name+0x43>
nopl   0x0(%rax)
mov    %cl,(%r14)
add    $0x1,%r14
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11cc <conv_udf_name+0x9c>
movsbl %al,%edi
call   1030 <isdigit@plt>
movzbl (%rbx),%ecx
test   %rax,%rax
je     1160 <conv_udf_name+0x30>
movsbq %cl,%rax
mov    -0x180(%r15,%rax,8),%rdi
ff
call   1050 <strlen@plt>
cltq
add    %r14,%rax
add    $0x1,%rax
cmp    %r12,%rax
jae    11cc <conv_udf_name+0x9c>
movsbq (%rbx),%rax
mov    -0x180(%r15,%rax,8),%rsi
ff
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%r14
jmp    1167 <conv_udf_name+0x37>
lea    0x2e84(%rip),%r14
movb   $0x0,(%r14)
lea    0x2e79(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@conv_udf_name.nums = internal global [10 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0)]
@.str = [5 x i8] c"ZERO\00"
@.str.1 = [4 x i8] c"ONE\00"
@.str.2 = [4 x i8] c"TWO\00"
@.str.3 = [6 x i8] c"THREE\00"
@.str.4 = [5 x i8] c"FOUR\00"
@.str.5 = [5 x i8] c"FIVE\00"
@.str.6 = [4 x i8] c"SIX\00"
@.str.7 = [6 x i8] c"SEVEN\00"
@.str.8 = [6 x i8] c"EIGHT\00"
@.str.9 = [5 x i8] c"NINE\00"
@conv_udf_name.buf = internal global [256 x i8] zeroinitializer
define i8* @conv_udf_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @conv_udf_name.buf, i64 0, i64 0), i8** %3
br label %4
4: ; preds = %52, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %53
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = call i64 @isdigit(i8 signext %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %46
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = sub nsw i32 %18, 48
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [10 x i8*], [10 x i8*]* @conv_udf_name.nums, i64 0, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @strlen(i8* %22)
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %15, i64 %24
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = icmp uge i8* %26, getelementptr inbounds ([256 x i8], [256 x i8]* @conv_udf_name.buf, i64 1, i64 0)
br i1 %27, label %28, label %29
28: ; preds = %14
br label %53
29: ; preds = %14
%30 = load i8*, i8** %3
%31 = load i8*, i8** %2
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = sub nsw i32 %33, 48
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [10 x i8*], [10 x i8*]* @conv_udf_name.nums, i64 0, i64 %35
%37 = load i8*, i8** %36
%38 = call i32 @strcpy(i8* %30, i8* %37)
%39 = load i8*, i8** %3
%40 = call i32 @strlen(i8* %39)
%41 = load i8*, i8** %3
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds i8, i8* %41, i64 %42
store i8* %43, i8** %3
%44 = load i8*, i8** %2
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %2
br label %52
46: ; preds = %9
%47 = load i8*, i8** %2
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %2
%49 = load i8, i8* %47
%50 = load i8*, i8** %3
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %3
store i8 %49, i8* %50
br label %52
52: ; preds = %46, %29
br label %4
53: ; preds = %28, %4
%54 = load i8*, i8** %3
store i8 0, i8* %54
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @conv_udf_name.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@conv_udf_name.nums = internal unnamed_addr constant [10 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0)]
@.str = [5 x i8] c"ZERO\00"
@.str.1 = [4 x i8] c"ONE\00"
@.str.2 = [4 x i8] c"TWO\00"
@.str.3 = [6 x i8] c"THREE\00"
@.str.4 = [5 x i8] c"FOUR\00"
@.str.5 = [5 x i8] c"FIVE\00"
@.str.6 = [4 x i8] c"SIX\00"
@.str.7 = [6 x i8] c"SEVEN\00"
@.str.8 = [6 x i8] c"EIGHT\00"
@.str.9 = [5 x i8] c"NINE\00"
@conv_udf_name.buf = internal global [256 x i8] zeroinitializer
define i8* @conv_udf_name(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %38, label %4
4: ; preds = %1, %33
%5 = phi i8 [ %36, %33 ], [ %2, %1 ]
%6 = phi i8* [ %34, %33 ], [ getelementptr inbounds ([256 x i8], [256 x i8]* @conv_udf_name.buf, i64 0, i64 0), %1 ]
%7 = phi i8* [ %35, %33 ], [ %0, %1 ]
%8 = tail call i64 @isdigit(i8 signext %5)
%9 = icmp eq i64 %8, 0
%10 = load i8, i8* %7
br i1 %9, label %31, label %11
11: ; preds = %4
%12 = sext i8 %10 to i64
%13 = add nsw i64 %12, -48
%14 = getelementptr inbounds [10 x i8*], [10 x i8*]* @conv_udf_name.nums, i64 0, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 @strlen(i8* %15)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %6, i64 1
%19 = getelementptr inbounds i8, i8* %18, i64 %17
%20 = icmp ult i8* %19, getelementptr inbounds ([256 x i8], [256 x i8]* @conv_udf_name.buf, i64 1, i64 0)
br i1 %20, label %21, label %38
21: ; preds = %11
%22 = load i8, i8* %7
%23 = sext i8 %22 to i64
%24 = add nsw i64 %23, -48
%25 = getelementptr inbounds [10 x i8*], [10 x i8*]* @conv_udf_name.nums, i64 0, i64 %24
%26 = load i8*, i8** %25
%27 = tail call i32 @strcpy(i8* %6, i8* %26)
%28 = tail call i32 @strlen(i8* %6)
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %6, i64 %29
br label %33
31: ; preds = %4
%32 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %10, i8* %6
br label %33
33: ; preds = %31, %21
%34 = phi i8* [ %30, %21 ], [ %32, %31 ]
%35 = getelementptr inbounds i8, i8* %7, i64 1
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 0
br i1 %37, label %38, label %4
38: ; preds = %33, %11, %1
%39 = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @conv_udf_name.buf, i64 0, i64 0), %1 ], [ %6, %11 ], [ %34, %33 ]
store i8 0, i8* %39
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @conv_udf_name.buf, i64 0, i64 0)
}