#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*/ write_zx_byte(char);
void write_zx_number(int i) {
  int c;
  c = i / 10000;
  i -= c * 10000;
  write_zx_byte((char)(c + 48));
  c = i / 1000;
  i -= c * 1000;
  write_zx_byte((char)(c + 48));
  c = i / 100;
  i -= c * 100;
  write_zx_byte((char)(c + 48));
  c = i / 10;
  write_zx_byte((char)(c + 48));
  write_zx_byte((char)(c + 48));
}


x86 assembly (clang, -O0):
<write_zx_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
imul   $0x2710,-0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x30,%eax
movsbl %al,%edi
call   1030 <write_zx_byte@plt>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
imul   $0x3e8,-0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x30,%eax
movsbl %al,%edi
call   1030 <write_zx_byte@plt>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
imul   $0x64,-0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x30,%eax
movsbl %al,%edi
call   1030 <write_zx_byte@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x30,%eax
movsbl %al,%edi
call   1030 <write_zx_byte@plt>
mov    -0x8(%rbp),%eax
add    $0x30,%eax
movsbl %al,%edi
call   1030 <write_zx_byte@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_zx_number>:
push   %rbx
movslq %edi,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0xffffd8f0,%eax,%ecx
add    %ecx,%ebx
add    $0x30,%al
movsbl %al,%edi
call   1030 <write_zx_byte@plt>
movslq %ebx,%rbx
imul   $0x10624dd3,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0xfffffc18,%eax,%ecx
add    %ecx,%ebx
add    $0x30,%al
movsbl %al,%edi
call   1030 <write_zx_byte@plt>
movslq %ebx,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0xffffff9c,%eax,%ecx
add    %ecx,%ebx
add    $0x30,%al
movsbl %al,%edi
call   1030 <write_zx_byte@plt>
movslq %ebx,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x22,%rax
add    %ecx,%eax
add    $0x30,%al
movsbl %al,%ebx
mov    %ebx,%edi
call   1030 <write_zx_byte@plt>
mov    %ebx,%edi
pop    %rbx
jmp    1030 <write_zx_byte@plt>

LLVM IR (-O0):
define void @write_zx_number(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = sdiv i32 %4, 10000
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = mul nsw i32 %6, 10000
%8 = load i32, i32* %2
%9 = sub nsw i32 %8, %7
store i32 %9, i32* %2
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 48
%12 = trunc i32 %11 to i8
%13 = call i32 @write_zx_byte(i8 signext %12)
%14 = load i32, i32* %2
%15 = sdiv i32 %14, 1000
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = mul nsw i32 %16, 1000
%18 = load i32, i32* %2
%19 = sub nsw i32 %18, %17
store i32 %19, i32* %2
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 48
%22 = trunc i32 %21 to i8
%23 = call i32 @write_zx_byte(i8 signext %22)
%24 = load i32, i32* %2
%25 = sdiv i32 %24, 100
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = mul nsw i32 %26, 100
%28 = load i32, i32* %2
%29 = sub nsw i32 %28, %27
store i32 %29, i32* %2
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 48
%32 = trunc i32 %31 to i8
%33 = call i32 @write_zx_byte(i8 signext %32)
%34 = load i32, i32* %2
%35 = sdiv i32 %34, 10
store i32 %35, i32* %3
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 48
%38 = trunc i32 %37 to i8
%39 = call i32 @write_zx_byte(i8 signext %38)
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 48
%42 = trunc i32 %41 to i8
%43 = call i32 @write_zx_byte(i8 signext %42)
ret void
}

LLVM IR (-O2):
define void @write_zx_number(i32 %0) {
%2 = sdiv i32 %0, 10000
%3 = mul nsw i32 %2, -10000
%4 = add i32 %3, %0
%5 = trunc i32 %2 to i8
%6 = add i8 %5, 48
%7 = tail call i32 @write_zx_byte(i8 signext %6)
%8 = sdiv i32 %4, 1000
%9 = mul nsw i32 %8, -1000
%10 = add i32 %9, %4
%11 = trunc i32 %8 to i8
%12 = add i8 %11, 48
%13 = tail call i32 @write_zx_byte(i8 signext %12)
%14 = sdiv i32 %10, 100
%15 = mul nsw i32 %14, -100
%16 = add i32 %15, %10
%17 = trunc i32 %14 to i8
%18 = add i8 %17, 48
%19 = tail call i32 @write_zx_byte(i8 signext %18)
%20 = sdiv i32 %16, 10
%21 = trunc i32 %20 to i8
%22 = add i8 %21, 48
%23 = tail call i32 @write_zx_byte(i8 signext %22)
%24 = tail call i32 @write_zx_byte(i8 signext %22)
ret void
}