#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 uint32_t;

/* Variables and functions */
unsigned char *append_sub32(unsigned char *cp, uint32_t i) {
  *cp++ = i / 100000000 + '0', i %= 100000000;
  *cp++ = i / 10000000 + '0', i %= 10000000;
  *cp++ = i / 1000000 + '0', i %= 1000000;
  *cp++ = i / 100000 + '0', i %= 100000;
  *cp++ = i / 10000 + '0', i %= 10000;
  *cp++ = i / 1000 + '0', i %= 1000;
  *cp++ = i / 100 + '0', i %= 100;
  *cp++ = i / 10 + '0', i %= 10;
  *cp++ = i + '0';
  return cp;
}


x86 assembly (clang, -O0):
<append_sub32>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x5f5e100,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    $0x5f5e100,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x989680,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    $0x989680,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x186a0,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    $0x186a0,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_sub32>:
movslq %esi,%rax
imul   $0x55e63b89,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x39,%rcx
add    %edx,%ecx
lea    0x30(%rcx),%edx
mov    %dl,(%rdi)
imul   $0x5f5e100,%ecx,%ecx
sub    %ecx,%eax
cltq
imul   $0x6b5fca6b,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x36,%rcx
add    %edx,%ecx
lea    0x30(%rcx),%edx
mov    %dl,0x1(%rdi)
imul   $0x989680,%ecx,%ecx
sub    %ecx,%eax
cltq
imul   $0x431bde83,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x32,%rcx
add    %edx,%ecx
lea    0x30(%rcx),%edx
mov    %dl,0x2(%rdi)
imul   $0xf4240,%ecx,%ecx
sub    %ecx,%eax
cltq
imul   $0x14f8b589,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2d,%rcx
add    %edx,%ecx
lea    0x30(%rcx),%edx
mov    %dl,0x3(%rdi)
imul   $0x186a0,%ecx,%ecx
sub    %ecx,%eax
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2c,%rcx
add    %edx,%ecx
lea    0x30(%rcx),%edx
mov    %dl,0x4(%rdi)
imul   $0x2710,%ecx,%ecx
sub    %ecx,%eax
movswl %ax,%ecx
imul   $0xffff8313,%ecx,%ecx
shr    $0x10,%ecx
add    %eax,%ecx
movzwl %cx,%ecx
movswl %cx,%edx
shr    $0xf,%ecx
sar    $0x9,%edx
add    %ecx,%edx
lea    0x30(%rdx),%ecx
mov    %cl,0x5(%rdi)
imul   $0x3e8,%edx,%ecx
sub    %ecx,%eax
movswl %ax,%ecx
imul   $0x147b,%ecx,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x13,%ecx
add    %edx,%ecx
lea    0x30(%rcx),%edx
mov    %dl,0x6(%rdi)
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
movsbl %al,%ecx
imul   $0x67,%ecx,%ecx
movzwl %cx,%ecx
movswl %cx,%edx
shr    $0xf,%ecx
shr    $0xa,%edx
add    %cl,%dl
lea    0x30(%rdx),%ecx
mov    %cl,0x7(%rdi)
movzbl %dl,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
add    $0x30,%al
mov    %al,0x8(%rdi)
lea    0x9(%rdi),%rax
ret

LLVM IR (-O0):
define i8* @append_sub32(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = sdiv i32 %5, 100000000
%7 = add nsw i32 %6, 48
%8 = trunc i32 %7 to i8
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %3
store i8 %8, i8* %9
%11 = load i32, i32* %4
%12 = srem i32 %11, 100000000
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = sdiv i32 %13, 10000000
%15 = add nsw i32 %14, 48
%16 = trunc i32 %15 to i8
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
store i8 %16, i8* %17
%19 = load i32, i32* %4
%20 = srem i32 %19, 10000000
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = sdiv i32 %21, 1000000
%23 = add nsw i32 %22, 48
%24 = trunc i32 %23 to i8
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
store i8 %24, i8* %25
%27 = load i32, i32* %4
%28 = srem i32 %27, 1000000
store i32 %28, i32* %4
%29 = load i32, i32* %4
%30 = sdiv i32 %29, 100000
%31 = add nsw i32 %30, 48
%32 = trunc i32 %31 to i8
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
store i8 %32, i8* %33
%35 = load i32, i32* %4
%36 = srem i32 %35, 100000
store i32 %36, i32* %4
%37 = load i32, i32* %4
%38 = sdiv i32 %37, 10000
%39 = add nsw i32 %38, 48
%40 = trunc i32 %39 to i8
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %3
store i8 %40, i8* %41
%43 = load i32, i32* %4
%44 = srem i32 %43, 10000
store i32 %44, i32* %4
%45 = load i32, i32* %4
%46 = sdiv i32 %45, 1000
%47 = add nsw i32 %46, 48
%48 = trunc i32 %47 to i8
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %3
store i8 %48, i8* %49
%51 = load i32, i32* %4
%52 = srem i32 %51, 1000
store i32 %52, i32* %4
%53 = load i32, i32* %4
%54 = sdiv i32 %53, 100
%55 = add nsw i32 %54, 48
%56 = trunc i32 %55 to i8
%57 = load i8*, i8** %3
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %3
store i8 %56, i8* %57
%59 = load i32, i32* %4
%60 = srem i32 %59, 100
store i32 %60, i32* %4
%61 = load i32, i32* %4
%62 = sdiv i32 %61, 10
%63 = add nsw i32 %62, 48
%64 = trunc i32 %63 to i8
%65 = load i8*, i8** %3
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %3
store i8 %64, i8* %65
%67 = load i32, i32* %4
%68 = srem i32 %67, 10
store i32 %68, i32* %4
%69 = load i32, i32* %4
%70 = add nsw i32 %69, 48
%71 = trunc i32 %70 to i8
%72 = load i8*, i8** %3
%73 = getelementptr inbounds i8, i8* %72, i32 1
store i8* %73, i8** %3
store i8 %71, i8* %72
%74 = load i8*, i8** %3
ret i8* %74
}

LLVM IR (-O2):
define i8* @append_sub32(i8* writeonly %0, i32 %1) {
%3 = sdiv i32 %1, 100000000
%4 = trunc i32 %3 to i8
%5 = add nsw i8 %4, 48
%6 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %5, i8* %0
%7 = srem i32 %1, 100000000
%8 = sdiv i32 %7, 10000000
%9 = trunc i32 %8 to i8
%10 = add nsw i8 %9, 48
%11 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %10, i8* %6
%12 = srem i32 %7, 10000000
%13 = sdiv i32 %12, 1000000
%14 = trunc i32 %13 to i8
%15 = add nsw i8 %14, 48
%16 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %15, i8* %11
%17 = srem i32 %12, 1000000
%18 = sdiv i32 %17, 100000
%19 = trunc i32 %18 to i8
%20 = add nsw i8 %19, 48
%21 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %20, i8* %16
%22 = srem i32 %17, 100000
%23 = sdiv i32 %22, 10000
%24 = trunc i32 %23 to i8
%25 = add nsw i8 %24, 48
%26 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %25, i8* %21
%27 = srem i32 %22, 10000
%28 = trunc i32 %27 to i16
%29 = sdiv i16 %28, 1000
%30 = trunc i16 %29 to i8
%31 = add nsw i8 %30, 48
%32 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %31, i8* %26
%33 = srem i16 %28, 1000
%34 = sdiv i16 %33, 100
%35 = trunc i16 %34 to i8
%36 = add nsw i8 %35, 48
%37 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %36, i8* %32
%38 = srem i16 %33, 100
%39 = trunc i16 %38 to i8
%40 = sdiv i8 %39, 10
%41 = add nsw i8 %40, 48
%42 = getelementptr inbounds i8, i8* %0, i64 8
store i8 %41, i8* %37
%43 = srem i8 %39, 10
%44 = add nsw i8 %43, 48
%45 = getelementptr inbounds i8, i8* %0, i64 9
store i8 %44, i8* %42
ret i8* %45
}