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

/* Variables and functions */
uint8_t *appendnumber(uint8_t *msg, uint8_t value) {
  if (value >= 100) {
    *msg++ = '0' + value / 100;
    value %= 100;
  }
  *msg++ = '0' + value / 10;
  *msg++ = '0' + value % 10;
  return msg;
}


x86 assembly (clang, -O0):
<appendnumber>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jl     1144 <appendnumber+0x44>
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
add    $0x30,%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%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
mov    %eax,%ecx
add    $0x30,%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    %edx,(%rax)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<appendnumber>:
mov    %rdi,%rax
cmp    $0x64,%esi
jl     1123 <appendnumber+0x23>
mov    %esi,%ecx
imul   $0x51eb851f,%rcx,%rcx
shr    $0x25,%rcx
lea    0x30(%rcx),%edx
mov    %edx,(%rax)
add    $0x4,%rax
imul   $0x64,%ecx,%ecx
sub    %ecx,%esi
movslq %esi,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
lea    (%rdx,%rsi,1),%edi
add    $0x30,%edi
mov    %edi,(%rax)
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
neg    %edx
add    %edx,%ecx
add    $0x30,%ecx
mov    %ecx,0x4(%rax)
add    $0x8,%rax
ret

LLVM IR (-O0):
define i32* @appendnumber(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp sge i32 %5, 100
br i1 %6, label %7, label %15
7: ; preds = %2
%8 = load i32, i32* %4
%9 = sdiv i32 %8, 100
%10 = add nsw i32 48, %9
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i32 1
store i32* %12, i32** %3
store i32 %10, i32* %11
%13 = load i32, i32* %4
%14 = srem i32 %13, 100
store i32 %14, i32* %4
br label %15
15: ; preds = %7, %2
%16 = load i32, i32* %4
%17 = sdiv i32 %16, 10
%18 = add nsw i32 48, %17
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i32 1
store i32* %20, i32** %3
store i32 %18, i32* %19
%21 = load i32, i32* %4
%22 = srem i32 %21, 10
%23 = add nsw i32 48, %22
%24 = load i32*, i32** %3
%25 = getelementptr inbounds i32, i32* %24, i32 1
store i32* %25, i32** %3
store i32 %23, i32* %24
%26 = load i32*, i32** %3
ret i32* %26
}

LLVM IR (-O2):
define i32* @appendnumber(i32* writeonly %0, i32 %1) {
%3 = icmp sgt i32 %1, 99
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = udiv i32 %1, 100
%6 = add nuw nsw i32 %5, 48
%7 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %6, i32* %0
%8 = urem i32 %1, 100
br label %9
9: ; preds = %4, %2
%10 = phi i32* [ %7, %4 ], [ %0, %2 ]
%11 = phi i32 [ %8, %4 ], [ %1, %2 ]
%12 = sdiv i32 %11, 10
%13 = add nsw i32 %12, 48
%14 = getelementptr inbounds i32, i32* %10, i64 1
store i32 %13, i32* %10
%15 = srem i32 %11, 10
%16 = add nsw i32 %15, 48
%17 = getelementptr inbounds i32, i32* %10, i64 2
store i32 %16, i32* %14
ret i32* %17
}