#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 */
unsigned int Divide(unsigned int, int);
char Mod(unsigned int, int);
void WordToString(unsigned int Number, char *String) {
  int i;
  unsigned int Temp;
  Temp = Number;
  for (i = 0; i < 7; i++)
    String[i] = ' ';
  i = 0;
  while (Temp != 0) {
    String[5 - i] = Mod(Temp, 10) + '0';
    Temp = Divide(Temp, 10);
    i++;
  }
  String[6] = '\0';
}


x86 assembly (clang, -O0):
<WordToString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x7,-0x14(%rbp)
jge    1160 <WordToString+0x40>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <WordToString+0x1c>
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11b6 <WordToString+0x96>
mov    -0x18(%rbp),%edi
mov    $0xa,%esi
call   1030 <Mod@plt>
movsbl %al,%eax
add    $0x30,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    $0x5,%ecx
sub    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%edi
mov    $0xa,%esi
call   1040 <Divide@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1167 <WordToString+0x47>
mov    -0x10(%rbp),%rax
movb   $0x0,0x6(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WordToString>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
movl   $0x20202020,0x3(%rsi)
movl   $0x20202020,(%rsi)
test   %edi,%edi
je     1166 <WordToString+0x46>
mov    %edi,%ebp
lea    0x5(%r14),%rbx
xchg   %ax,%ax
mov    %ebp,%edi
mov    $0xa,%esi
call   1030 <Mod@plt>
add    $0x30,%al
mov    %al,(%rbx)
mov    %ebp,%edi
mov    $0xa,%esi
call   1040 <Divide@plt>
mov    %eax,%ebp
add    $0xffffffffffffffff,%rbx
test   %eax,%eax
jne    1140 <WordToString+0x20>
movb   $0x0,0x6(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @WordToString(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i32, i32* %3
store i32 %7, i32* %6
store i32 0, i32* %5
br label %8
8: ; preds = %16, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 7
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8 32, i8* %15
br label %16
16: ; preds = %11
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %8
19: ; preds = %8
store i32 0, i32* %5
br label %20
20: ; preds = %23, %19
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %38
23: ; preds = %20
%24 = load i32, i32* %6
%25 = call signext i8 @Mod(i32 %24, i32 10)
%26 = sext i8 %25 to i32
%27 = add nsw i32 %26, 48
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %4
%30 = load i32, i32* %5
%31 = sub nsw i32 5, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
store i8 %28, i8* %33
%34 = load i32, i32* %6
%35 = call i32 @Divide(i32 %34, i32 10)
store i32 %35, i32* %6
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %20
38: ; preds = %20
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 6
store i8 0, i8* %40
ret void
}

LLVM IR (-O2):
define void @WordToString(i32 %0, i8* nocapture writeonly %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %14, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %12, %4 ], [ 0, %2 ]
%6 = phi i32 [ %11, %4 ], [ %0, %2 ]
%7 = tail call signext i8 @Mod(i32 %6, i32 10)
%8 = add i8 %7, 48
%9 = sub nsw i64 5, %5
%10 = getelementptr inbounds i8, i8* %1, i64 %9
store i8 %8, i8* %10
%11 = tail call i32 @Divide(i32 %6, i32 10)
%12 = add nuw i64 %5, 1
%13 = icmp eq i32 %11, 0
br i1 %13, label %14, label %4
14: ; preds = %4, %2
%15 = getelementptr inbounds i8, i8* %1, i64 6
store i8 0, i8* %15
ret void
}