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

/* Variables and functions */
int /*<<< orphan*/ DECIMAL_SIZE(long);
int /*<<< orphan*/ doapr_outch(char **, char **, size_t *, size_t *,
                               char const);
int strlen(char const *);
void fmtint(char **sbuffer, char **buffer, size_t *currlen, size_t *maxlen,
            long value, int base, int min, int max, int flags) {
  int signvalue = 0;
  const char *prefix = "";
  unsigned long uvalue;
  char convert[DECIMAL_SIZE(value) + 3];
  int place = 0;
  int spadlen = 0;
  int zpadlen = 0;
  int caps = 0;
  if (max < 0)
    max = 0;
  uvalue = value;
  if (!(flags & (1 << 6))) {
    if (value < 0) {
      signvalue = '-';
      uvalue = -value;
    } else if (flags & (1 << 1))
      signvalue = '+';
    else if (flags & (1 << 2))
      signvalue = ' ';
  }
  if (flags & (1 << 3)) {
    if (base == 8)
      prefix = "0";
    if (base == 16)
      prefix = "0x";
  }
  if (flags & (1 << 5))
    caps = 1;
  do {
    convert[place++] = (caps ? "0123456789ABCDEF"
                             : "0123456789abcdef")[uvalue % (unsigned)base];
    uvalue = (uvalue / (unsigned)base);
  } while (uvalue && (place < (int)sizeof(convert)));
  if (place == sizeof(convert))
    place--;
  convert[place] = 0;
  zpadlen = max - place;
  spadlen = min - ((max >= place) ? max : place) - (signvalue ? 1 : 0) -
            strlen(prefix);
  if (zpadlen < 0)
    zpadlen = 0;
  if (spadlen < 0)
    spadlen = 0;
  if (flags & (1 << 4)) {
    zpadlen = ((zpadlen >= spadlen) ? zpadlen : spadlen);
    spadlen = 0;
  }
  if (flags & (1 << 0))
    spadlen = -spadlen;
  while (spadlen > 0) {
    doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
    --spadlen;
  }
  if (signvalue)
    doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
  while (*prefix) {
    doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix);
    prefix++;
  }
  if (zpadlen > 0) {
    while (zpadlen > 0) {
      doapr_outch(sbuffer, buffer, currlen, maxlen, '0');
      --zpadlen;
    }
  }
  while (place > 0)
    doapr_outch(sbuffer, buffer, currlen, maxlen, convert[--place]);
  while (spadlen < 0) {
    doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
    ++spadlen;
  }
  return;
}


x86 assembly (clang, -O0):
<fmtint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xe97(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <DECIMAL_SIZE@plt>
add    $0x3,%eax
mov    %rax,-0x70(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
cmpl   $0x0,0x18(%rbp)
jge    11ce <fmtint+0x9e>
movl   $0x0,0x18(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x20(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
jne    1246 <fmtint+0x116>
cmpq   $0x0,-0x28(%rbp)
jge    1206 <fmtint+0xd6>
movl   $0x2d,-0x30(%rbp)
xor    %eax,%eax
sub    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    1241 <fmtint+0x111>
mov    0x20(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1221 <fmtint+0xf1>
movl   $0x2b,-0x30(%rbp)
jmp    123c <fmtint+0x10c>
mov    0x20(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1237 <fmtint+0x107>
movl   $0x20,-0x30(%rbp)
jmp    123c <fmtint+0x10c>
jmp    1241 <fmtint+0x111>
jmp    1246 <fmtint+0x116>
mov    0x20(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1284 <fmtint+0x154>
cmpl   $0x8,-0x2c(%rbp)
jne    126a <fmtint+0x13a>
lea    0xd9a(%rip),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x10,-0x2c(%rbp)
jne    127f <fmtint+0x14f>
lea    0xd87(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    1284 <fmtint+0x154>
mov    0x20(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     129a <fmtint+0x16a>
movl   $0x1,-0x60(%rbp)
jmp    129f <fmtint+0x16f>
mov    -0x60(%rbp),%edx
lea    0xd6d(%rip),%rcx
lea    0xd55(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%rcx
mov    -0x40(%rbp),%rax
mov    -0x2c(%rbp),%edx
mov    %edx,%esi
xor    %edx,%edx
div    %rsi
mov    -0x68(%rbp),%rax
mov    (%rcx,%rdx,1),%dl
mov    -0x54(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x54(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x40(%rbp),%rax
mov    -0x2c(%rbp),%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x40(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x40(%rbp)
mov    %al,-0x71(%rbp)
je     130c <fmtint+0x1dc>
mov    -0x70(%rbp),%rcx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
setl   %al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    129f <fmtint+0x16f>
mov    -0x70(%rbp),%rcx
movslq -0x54(%rbp),%rax
cmp    %rcx,%rax
jne    1331 <fmtint+0x201>
mov    -0x54(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x54(%rbp)
mov    -0x68(%rbp),%rax
movslq -0x54(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    0x18(%rbp),%eax
sub    -0x54(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    0x10(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    0x18(%rbp),%eax
cmp    -0x54(%rbp),%eax
jl     1363 <fmtint+0x233>
mov    0x18(%rbp),%eax
mov    %eax,-0x7c(%rbp)
jmp    1369 <fmtint+0x239>
mov    -0x54(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x78(%rbp),%eax
mov    -0x7c(%rbp),%ecx
sub    %ecx,%eax
mov    -0x30(%rbp),%esi
xor    %ecx,%ecx
mov    $0x1,%edx
cmp    $0x0,%esi
cmovne %edx,%ecx
sub    %ecx,%eax
mov    %eax,-0x80(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x80(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jge    13aa <fmtint+0x27a>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    13bb <fmtint+0x28b>
movl   $0x0,-0x58(%rbp)
mov    0x20(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     13fd <fmtint+0x2cd>
mov    -0x5c(%rbp),%eax
cmp    -0x58(%rbp),%eax
jl     13e4 <fmtint+0x2b4>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x84(%rbp)
jmp    13ed <fmtint+0x2bd>
mov    -0x58(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x5c(%rbp)
movl   $0x0,-0x58(%rbp)
mov    0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1414 <fmtint+0x2e4>
xor    %eax,%eax
sub    -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
jmp    1419 <fmtint+0x2e9>
cmpl   $0x0,-0x58(%rbp)
jle    144c <fmtint+0x31c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x20,%r8d
call   1030 <doapr_outch@plt>
mov    -0x58(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x58(%rbp)
jmp    1419 <fmtint+0x2e9>
cmpl   $0x0,-0x30(%rbp)
je     1472 <fmtint+0x342>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%eax
movsbl %al,%r8d
call   1030 <doapr_outch@plt>
jmp    1477 <fmtint+0x347>
mov    -0x38(%rbp),%rax
cmpb   $0x0,(%rax)
je     14b2 <fmtint+0x382>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x38(%rbp),%rax
movsbl (%rax),%r8d
call   1030 <doapr_outch@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1477 <fmtint+0x347>
cmpl   $0x0,-0x5c(%rbp)
jle    14f9 <fmtint+0x3c9>
jmp    14c1 <fmtint+0x391>
cmpl   $0x0,-0x5c(%rbp)
jle    14f4 <fmtint+0x3c4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x30,%r8d
call   1030 <doapr_outch@plt>
mov    -0x5c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x5c(%rbp)
jmp    14c1 <fmtint+0x391>
jmp    14f9 <fmtint+0x3c9>
jmp    14fe <fmtint+0x3ce>
cmpl   $0x0,-0x54(%rbp)
jle    153a <fmtint+0x40a>
mov    -0x68(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x54(%rbp),%r8d
add    $0xffffffff,%r8d
mov    %r8d,-0x54(%rbp)
movslq %r8d,%r8
movsbl (%rax,%r8,1),%r8d
call   1030 <doapr_outch@plt>
jmp    14fe <fmtint+0x3ce>
jmp    153f <fmtint+0x40f>
cmpl   $0x0,-0x58(%rbp)
jge    1572 <fmtint+0x442>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x20,%r8d
call   1030 <doapr_outch@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    153f <fmtint+0x40f>
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmtint>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9d,%r15d
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rdx,-0x58(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %rdi,-0x38(%rbp)
mov    0x20(%rbp),%r12d
mov    0x18(%rbp),%r13d
mov    %r8,%rdi
call   1050 <DECIMAL_SIZE@plt>
mov    %eax,%r9d
add    $0x3,%r9d
mov    %rsp,%r10
lea    0xf(%r9),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r10
mov    %r10,%rsp
xor    %eax,%eax
test   %r13d,%r13d
cmovs  %eax,%r13d
test   $0x40,%r12b
mov    %rbx,-0x50(%rbp)
jne    11af <fmtint+0x7f>
test   %r14,%r14
js     11bb <fmtint+0x8b>
mov    0x20(%rbp),%eax
test   $0x2,%al
jne    11c2 <fmtint+0x92>
mov    0x20(%rbp),%eax
and    $0x4,%eax
sete   %r11b
shl    $0x3,%al
mov    %eax,-0x2c(%rbp)
jmp    11ca <fmtint+0x9a>
movl   $0x0,-0x2c(%rbp)
mov    $0x1,%r11b
jmp    11ca <fmtint+0x9a>
neg    %r14
mov    $0x2d,%al
jmp    11c4 <fmtint+0x94>
mov    $0x2b,%al
mov    %eax,-0x2c(%rbp)
xor    %r11d,%r11d
cmp    $0x8,%r15d
lea    0xe2b(%rip),%rax
lea    0xe25(%rip),%r8
cmovne %r8,%rax
cmp    $0x10,%r15d
lea    0xe17(%rip),%rbx
cmovne %rax,%rbx
mov    0x20(%rbp),%eax
test   $0x20,%al
lea    0xe1b(%rip),%rax
lea    0xe03(%rip),%rcx
cmove  %rax,%rcx
mov    %r15d,%esi
movslq %r9d,%r15
xor    %edi,%edi
xchg   %ax,%ax
mov    %r14,%rax
shr    $0x20,%rax
je     1230 <fmtint+0x100>
mov    %r14,%rax
xor    %edx,%edx
div    %rsi
jmp    1237 <fmtint+0x107>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14d,%eax
xor    %edx,%edx
div    %esi
movzbl (%rcx,%rdx,1),%edx
mov    %dl,(%r10,%rdi,1)
add    $0x1,%rdi
cmp    %rsi,%r14
jb     1250 <fmtint+0x120>
mov    %rax,%r14
cmp    %r15,%rdi
jl     1210 <fmtint+0xe0>
mov    0x20(%rbp),%r15d
test   $0x8,%r15b
cmove  %r8,%rbx
lea    -0x1(%rdi),%eax
cmp    %edi,%r9d
cmovne %edi,%eax
mov    %r10,-0x68(%rbp)
movb   $0x0,(%r10,%rax,1)
mov    %r13d,%r12d
sub    %eax,%r12d
mov    %rax,-0x60(%rbp)
cmovl  %eax,%r13d
mov    %r11d,-0x44(%rbp)
mov    %r11d,%r14d
xor    $0x1,%r14b
mov    %rbx,%rdi
call   1040 <strlen@plt>
movzbl %r14b,%ecx
mov    0x10(%rbp),%edx
sub    %ecx,%edx
add    %r13d,%eax
sub    %eax,%edx
xor    %eax,%eax
test   %r12d,%r12d
cmovs  %eax,%r12d
test   %edx,%edx
cmovs  %eax,%edx
cmp    %edx,%r12d
mov    %r12d,%r14d
cmovb  %edx,%r14d
test   $0x10,%r15b
cmovne %eax,%edx
cmove  %r12d,%r14d
mov    %edx,%r13d
neg    %r13d
test   $0x1,%r15b
cmove  %edx,%r13d
test   %r13d,%r13d
jle    145b <fmtint+0x32b>
add    $0x1,%r13d
mov    -0x50(%rbp),%r12
mov    -0x38(%rbp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    -0x40(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    %r12,%rcx
mov    $0x20,%r8d
call   1030 <doapr_outch@plt>
add    $0xffffffff,%r13d
cmp    $0x1,%r13d
ja     12f0 <fmtint+0x1c0>
xor    %r13d,%r13d
mov    -0x2c(%rbp),%ecx
mov    -0x44(%rbp),%eax
test   %al,%al
jne    1338 <fmtint+0x208>
movzbl %cl,%r8d
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    %r12,%rcx
call   1030 <doapr_outch@plt>
mov    (%rbx),%al
test   %al,%al
mov    -0x58(%rbp),%r15
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdi
mov    %r12,%rcx
je     138b <fmtint+0x25b>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%r8d
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %r15,%rdx
call   1030 <doapr_outch@plt>
mov    -0x50(%rbp),%rcx
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdi
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1360 <fmtint+0x230>
test   %r14d,%r14d
jle    13cc <fmtint+0x29c>
add    $0x1,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %r15,%rdx
mov    $0x30,%r8d
call   1030 <doapr_outch@plt>
mov    -0x50(%rbp),%rcx
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdi
add    $0xffffffff,%r14d
cmp    $0x1,%r14d
ja     13a0 <fmtint+0x270>
mov    -0x60(%rbp),%r8
test   %r8d,%r8d
mov    %rcx,%r12
mov    -0x68(%rbp),%r14
mov    %r15,%rdx
je     141e <fmtint+0x2ee>
lea    0x1(%r8),%ebx
add    $0xffffffff,%r8d
add    %r8,%r14
nopw   0x0(%rax,%rax,1)
movsbl (%r14),%r8d
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %rdx,%r15
mov    %r12,%rcx
call   1030 <doapr_outch@plt>
mov    %r15,%rdx
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdi
add    $0xffffffff,%ebx
add    $0xffffffffffffffff,%r14
cmp    $0x1,%ebx
jg     13f0 <fmtint+0x2c0>
test   %r13d,%r13d
jns    144c <fmtint+0x31c>
mov    %r12,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rdx,%rbx
nop
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    $0x20,%r8d
call   1030 <doapr_outch@plt>
inc    %r13d
jne    1430 <fmtint+0x300>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    -0x50(%rbp),%r12
mov    -0x44(%rbp),%eax
mov    -0x2c(%rbp),%ecx
test   %al,%al
je     1320 <fmtint+0x1f0>
jmp    1338 <fmtint+0x208>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [3 x i8] c"0x\00"
@.str.3 = [17 x i8] c"0123456789ABCDEF\00"
@.str.4 = [17 x i8] c"0123456789abcdef\00"
define void @fmtint(i8** %0, i8** %1, i64* %2, i64* %3, i64 %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca i8**
%11 = alloca i8**
%12 = alloca i64*
%13 = alloca i64*
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i64
%22 = alloca i8*
%23 = alloca i64
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
store i8** %0, i8*** %10
store i8** %1, i8*** %11
store i64* %2, i64** %12
store i64* %3, i64** %13
store i64 %4, i64* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store i32 %8, i32* %18
store i32 0, i32* %19
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %20
%28 = load i64, i64* %14
%29 = call i32 @DECIMAL_SIZE(i64 %28)
%30 = add nsw i32 %29, 3
%31 = zext i32 %30 to i64
%32 = call i8* @llvm.stacksave()
store i8* %32, i8** %22
%33 = alloca i8, i64 %31
store i64 %31, i64* %23
store i32 0, i32* %24
store i32 0, i32* %25
store i32 0, i32* %26
store i32 0, i32* %27
%34 = load i32, i32* %17
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %9
store i32 0, i32* %17
br label %37
37: ; preds = %36, %9
%38 = load i64, i64* %14
store i64 %38, i64* %21
%39 = load i32, i32* %18
%40 = and i32 %39, 64
%41 = icmp ne i32 %40, 0
br i1 %41, label %61, label %42
42: ; preds = %37
%43 = load i64, i64* %14
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %42
store i32 45, i32* %19
%46 = load i64, i64* %14
%47 = sub nsw i64 0, %46
store i64 %47, i64* %21
br label %60
48: ; preds = %42
%49 = load i32, i32* %18
%50 = and i32 %49, 2
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %48
store i32 43, i32* %19
br label %59
53: ; preds = %48
%54 = load i32, i32* %18
%55 = and i32 %54, 4
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %53
store i32 32, i32* %19
br label %58
58: ; preds = %57, %53
br label %59
59: ; preds = %58, %52
br label %60
60: ; preds = %59, %45
br label %61
61: ; preds = %60, %37
%62 = load i32, i32* %18
%63 = and i32 %62, 8
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %74
65: ; preds = %61
%66 = load i32, i32* %15
%67 = icmp eq i32 %66, 8
br i1 %67, label %68, label %69
68: ; preds = %65
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %20
br label %69
69: ; preds = %68, %65
%70 = load i32, i32* %15
%71 = icmp eq i32 %70, 16
br i1 %71, label %72, label %73
72: ; preds = %69
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %20
br label %73
73: ; preds = %72, %69
br label %74
74: ; preds = %73, %61
%75 = load i32, i32* %18
%76 = and i32 %75, 32
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %74
store i32 1, i32* %27
br label %79
79: ; preds = %78, %74
br label %80
80: ; preds = %106, %79
%81 = load i32, i32* %27
%82 = icmp ne i32 %81, 0
%83 = zext i1 %82 to i64
%84 = select i1 %82, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0)
%85 = load i64, i64* %21
%86 = load i32, i32* %15
%87 = zext i32 %86 to i64
%88 = urem i64 %85, %87
%89 = getelementptr inbounds i8, i8* %84, i64 %88
%90 = load i8, i8* %89
%91 = load i32, i32* %24
%92 = add nsw i32 %91, 1
store i32 %92, i32* %24
%93 = sext i32 %91 to i64
%94 = getelementptr inbounds i8, i8* %33, i64 %93
store i8 %90, i8* %94
%95 = load i64, i64* %21
%96 = load i32, i32* %15
%97 = zext i32 %96 to i64
%98 = udiv i64 %95, %97
store i64 %98, i64* %21
br label %99
99: ; preds = %80
%100 = load i64, i64* %21
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %106
102: ; preds = %99
%103 = load i32, i32* %24
%104 = trunc i64 %31 to i32
%105 = icmp slt i32 %103, %104
br label %106
106: ; preds = %102, %99
%107 = phi i1 [ false, %99 ], [ %105, %102 ]
br i1 %107, label %80, label %108
108: ; preds = %106
%109 = load i32, i32* %24
%110 = sext i32 %109 to i64
%111 = icmp eq i64 %110, %31
br i1 %111, label %112, label %115
112: ; preds = %108
%113 = load i32, i32* %24
%114 = add nsw i32 %113, -1
store i32 %114, i32* %24
br label %115
115: ; preds = %112, %108
%116 = load i32, i32* %24
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8, i8* %33, i64 %117
store i8 0, i8* %118
%119 = load i32, i32* %17
%120 = load i32, i32* %24
%121 = sub nsw i32 %119, %120
store i32 %121, i32* %26
%122 = load i32, i32* %16
%123 = load i32, i32* %17
%124 = load i32, i32* %24
%125 = icmp sge i32 %123, %124
br i1 %125, label %126, label %128
126: ; preds = %115
%127 = load i32, i32* %17
br label %130
128: ; preds = %115
%129 = load i32, i32* %24
br label %130
130: ; preds = %128, %126
%131 = phi i32 [ %127, %126 ], [ %129, %128 ]
%132 = sub nsw i32 %122, %131
%133 = load i32, i32* %19
%134 = icmp ne i32 %133, 0
%135 = zext i1 %134 to i64
%136 = select i1 %134, i32 1, i32 0
%137 = sub nsw i32 %132, %136
%138 = load i8*, i8** %20
%139 = call i32 @strlen(i8* %138)
%140 = sub nsw i32 %137, %139
store i32 %140, i32* %25
%141 = load i32, i32* %26
%142 = icmp slt i32 %141, 0
br i1 %142, label %143, label %144
143: ; preds = %130
store i32 0, i32* %26
br label %144
144: ; preds = %143, %130
%145 = load i32, i32* %25
%146 = icmp slt i32 %145, 0
br i1 %146, label %147, label %148
147: ; preds = %144
store i32 0, i32* %25
br label %148
148: ; preds = %147, %144
%149 = load i32, i32* %18
%150 = and i32 %149, 16
%151 = icmp ne i32 %150, 0
br i1 %151, label %152, label %162
152: ; preds = %148
%153 = load i32, i32* %26
%154 = load i32, i32* %25
%155 = icmp sge i32 %153, %154
br i1 %155, label %156, label %158
156: ; preds = %152
%157 = load i32, i32* %26
br label %160
158: ; preds = %152
%159 = load i32, i32* %25
br label %160
160: ; preds = %158, %156
%161 = phi i32 [ %157, %156 ], [ %159, %158 ]
store i32 %161, i32* %26
store i32 0, i32* %25
br label %162
162: ; preds = %160, %148
%163 = load i32, i32* %18
%164 = and i32 %163, 1
%165 = icmp ne i32 %164, 0
br i1 %165, label %166, label %169
166: ; preds = %162
%167 = load i32, i32* %25
%168 = sub nsw i32 0, %167
store i32 %168, i32* %25
br label %169
169: ; preds = %166, %162
br label %170
170: ; preds = %173, %169
%171 = load i32, i32* %25
%172 = icmp sgt i32 %171, 0
br i1 %172, label %173, label %181
173: ; preds = %170
%174 = load i8**, i8*** %10
%175 = load i8**, i8*** %11
%176 = load i64*, i64** %12
%177 = load i64*, i64** %13
%178 = call i32 @doapr_outch(i8** %174, i8** %175, i64* %176, i64* %177, i8 signext 32)
%179 = load i32, i32* %25
%180 = add nsw i32 %179, -1
store i32 %180, i32* %25
br label %170
181: ; preds = %170
%182 = load i32, i32* %19
%183 = icmp ne i32 %182, 0
br i1 %183, label %184, label %192
184: ; preds = %181
%185 = load i8**, i8*** %10
%186 = load i8**, i8*** %11
%187 = load i64*, i64** %12
%188 = load i64*, i64** %13
%189 = load i32, i32* %19
%190 = trunc i32 %189 to i8
%191 = call i32 @doapr_outch(i8** %185, i8** %186, i64* %187, i64* %188, i8 signext %190)
br label %192
192: ; preds = %184, %181
br label %193
193: ; preds = %197, %192
%194 = load i8*, i8** %20
%195 = load i8, i8* %194
%196 = icmp ne i8 %195, 0
br i1 %196, label %197, label %207
197: ; preds = %193
%198 = load i8**, i8*** %10
%199 = load i8**, i8*** %11
%200 = load i64*, i64** %12
%201 = load i64*, i64** %13
%202 = load i8*, i8** %20
%203 = load i8, i8* %202
%204 = call i32 @doapr_outch(i8** %198, i8** %199, i64* %200, i64* %201, i8 signext %203)
%205 = load i8*, i8** %20
%206 = getelementptr inbounds i8, i8* %205, i32 1
store i8* %206, i8** %20
br label %193
207: ; preds = %193
%208 = load i32, i32* %26
%209 = icmp sgt i32 %208, 0
br i1 %209, label %210, label %223
210: ; preds = %207
br label %211
211: ; preds = %214, %210
%212 = load i32, i32* %26
%213 = icmp sgt i32 %212, 0
br i1 %213, label %214, label %222
214: ; preds = %211
%215 = load i8**, i8*** %10
%216 = load i8**, i8*** %11
%217 = load i64*, i64** %12
%218 = load i64*, i64** %13
%219 = call i32 @doapr_outch(i8** %215, i8** %216, i64* %217, i64* %218, i8 signext 48)
%220 = load i32, i32* %26
%221 = add nsw i32 %220, -1
store i32 %221, i32* %26
br label %211
222: ; preds = %211
br label %223
223: ; preds = %222, %207
br label %224
224: ; preds = %227, %223
%225 = load i32, i32* %24
%226 = icmp sgt i32 %225, 0
br i1 %226, label %227, label %238
227: ; preds = %224
%228 = load i8**, i8*** %10
%229 = load i8**, i8*** %11
%230 = load i64*, i64** %12
%231 = load i64*, i64** %13
%232 = load i32, i32* %24
%233 = add nsw i32 %232, -1
store i32 %233, i32* %24
%234 = sext i32 %233 to i64
%235 = getelementptr inbounds i8, i8* %33, i64 %234
%236 = load i8, i8* %235
%237 = call i32 @doapr_outch(i8** %228, i8** %229, i64* %230, i64* %231, i8 signext %236)
br label %224
238: ; preds = %224
br label %239
239: ; preds = %242, %238
%240 = load i32, i32* %25
%241 = icmp slt i32 %240, 0
br i1 %241, label %242, label %250
242: ; preds = %239
%243 = load i8**, i8*** %10
%244 = load i8**, i8*** %11
%245 = load i64*, i64** %12
%246 = load i64*, i64** %13
%247 = call i32 @doapr_outch(i8** %243, i8** %244, i64* %245, i64* %246, i8 signext 32)
%248 = load i32, i32* %25
%249 = add nsw i32 %248, 1
store i32 %249, i32* %25
br label %239
250: ; preds = %239
%251 = load i8*, i8** %22
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [3 x i8] c"0x\00"
@.str.3 = [17 x i8] c"0123456789ABCDEF\00"
@.str.4 = [17 x i8] c"0123456789abcdef\00"
define void @fmtint(i8** %0, i8** %1, i64* %2, i64* %3, i64 %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = tail call i32 @DECIMAL_SIZE(i64 %4)
%11 = add nsw i32 %10, 3
%12 = zext i32 %11 to i64
%13 = alloca i8, i64 %12
%14 = icmp sgt i32 %7, 0
%15 = select i1 %14, i32 %7, i32 0
%16 = and i32 %8, 64
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %9
%19 = icmp slt i64 %4, 0
br i1 %19, label %20, label %22
20: ; preds = %18
%21 = sub nsw i64 0, %4
br label %30
22: ; preds = %18
%23 = and i32 %8, 2
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = and i32 %8, 4
%27 = icmp eq i32 %26, 0
%28 = trunc i32 %26 to i8
%29 = shl nuw nsw i8 %28, 3
br label %30
30: ; preds = %25, %22, %20, %9
%31 = phi i64 [ %4, %9 ], [ %21, %20 ], [ %4, %22 ], [ %4, %25 ]
%32 = phi i1 [ true, %9 ], [ false, %20 ], [ false, %22 ], [ %27, %25 ]
%33 = phi i8 [ 0, %9 ], [ 45, %20 ], [ 43, %22 ], [ %29, %25 ]
%34 = and i32 %8, 8
%35 = icmp eq i32 %5, 8
%36 = select i1 %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
%37 = icmp eq i32 %5, 16
%38 = select i1 %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %36
%39 = and i32 %8, 32
%40 = icmp eq i32 %39, 0
%41 = select i1 %40, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0)
%42 = zext i32 %5 to i64
%43 = sext i32 %11 to i64
br label %44
44: ; preds = %44, %30
%45 = phi i64 [ %50, %44 ], [ 0, %30 ]
%46 = phi i64 [ %52, %44 ], [ %31, %30 ]
%47 = urem i64 %46, %42
%48 = getelementptr inbounds i8, i8* %41, i64 %47
%49 = load i8, i8* %48
%50 = add nuw nsw i64 %45, 1
%51 = getelementptr inbounds i8, i8* %13, i64 %45
store i8 %49, i8* %51
%52 = udiv i64 %46, %42
%53 = icmp uge i64 %46, %42
%54 = icmp slt i64 %50, %43
%55 = select i1 %53, i1 %54, i1 false
br i1 %55, label %44, label %56
56: ; preds = %44
%57 = icmp eq i32 %34, 0
%58 = select i1 %57, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %38
%59 = trunc i64 %45 to i32
%60 = trunc i64 %50 to i32
%61 = icmp eq i32 %11, %60
%62 = select i1 %61, i32 %59, i32 %60
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %13, i64 %63
store i8 0, i8* %64
%65 = sub nsw i32 %15, %62
%66 = icmp slt i32 %15, %62
%67 = select i1 %66, i32 %62, i32 %15
%68 = xor i1 %32, true
%69 = sext i1 %68 to i32
%70 = tail call i32 @strlen(i8* %58)
%71 = add i32 %69, %6
%72 = add i32 %67, %70
%73 = sub i32 %71, %72
%74 = icmp sgt i32 %65, 0
%75 = select i1 %74, i32 %65, i32 0
%76 = icmp sgt i32 %73, 0
%77 = select i1 %76, i32 %73, i32 0
%78 = and i32 %8, 16
%79 = icmp eq i32 %78, 0
%80 = icmp ult i32 %75, %77
%81 = select i1 %80, i32 %77, i32 %75
%82 = select i1 %79, i32 %77, i32 0
%83 = select i1 %79, i32 %75, i32 %81
%84 = and i32 %8, 1
%85 = icmp eq i32 %84, 0
%86 = sub nsw i32 0, %82
%87 = select i1 %85, i32 %82, i32 %86
%88 = icmp sgt i32 %87, 0
br i1 %88, label %89, label %94
89: ; preds = %56, %89
%90 = phi i32 [ %92, %89 ], [ %87, %56 ]
%91 = tail call i32 @doapr_outch(i8** %0, i8** %1, i64* %2, i64* %3, i8 signext 32)
%92 = add nsw i32 %90, -1
%93 = icmp ugt i32 %90, 1
br i1 %93, label %89, label %94
94: ; preds = %89, %56
%95 = phi i32 [ %87, %56 ], [ 0, %89 ]
br i1 %32, label %98, label %96
96: ; preds = %94
%97 = tail call i32 @doapr_outch(i8** %0, i8** %1, i64* %2, i64* %3, i8 signext %33)
br label %98
98: ; preds = %96, %94
%99 = load i8, i8* %58
%100 = icmp eq i8 %99, 0
br i1 %100, label %108, label %101
101: ; preds = %98, %101
%102 = phi i8 [ %106, %101 ], [ %99, %98 ]
%103 = phi i8* [ %105, %101 ], [ %58, %98 ]
%104 = tail call i32 @doapr_outch(i8** %0, i8** %1, i64* %2, i64* %3, i8 signext %102)
%105 = getelementptr inbounds i8, i8* %103, i64 1
%106 = load i8, i8* %105
%107 = icmp eq i8 %106, 0
br i1 %107, label %108, label %101
108: ; preds = %101, %98
%109 = icmp sgt i32 %83, 0
br i1 %109, label %110, label %115
110: ; preds = %108, %110
%111 = phi i32 [ %113, %110 ], [ %83, %108 ]
%112 = tail call i32 @doapr_outch(i8** %0, i8** %1, i64* %2, i64* %3, i8 signext 48)
%113 = add nsw i32 %111, -1
%114 = icmp ugt i32 %111, 1
br i1 %114, label %110, label %115
115: ; preds = %110, %108
%116 = icmp eq i32 %62, 0
br i1 %116, label %117, label %119
117: ; preds = %119, %115
%118 = icmp slt i32 %95, 0
br i1 %118, label %128, label %133
119: ; preds = %115, %119
%120 = phi i64 [ %121, %119 ], [ %63, %115 ]
%121 = add nsw i64 %120, -1
%122 = and i64 %121, 4294967295
%123 = getelementptr inbounds i8, i8* %13, i64 %122
%124 = load i8, i8* %123
%125 = tail call i32 @doapr_outch(i8** %0, i8** %1, i64* %2, i64* %3, i8 signext %124)
%126 = trunc i64 %120 to i32
%127 = icmp sgt i32 %126, 1
br i1 %127, label %119, label %117
128: ; preds = %117, %128
%129 = phi i32 [ %131, %128 ], [ %95, %117 ]
%130 = tail call i32 @doapr_outch(i8** %0, i8** %1, i64* %2, i64* %3, i8 signext 32)
%131 = add i32 %129, 1
%132 = icmp eq i32 %131, 0
br i1 %132, label %133, label %128
133: ; preds = %128, %117
ret void
}