#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 */
char *fast_intoa(unsigned int addr, char *buf, int bufLen) {
  char *cp, *retStr;
  uint8_t byte;
  int n;
  cp = &buf[bufLen];
  *--cp = '\0';
  n = 4;
  do {
    byte = addr & 0xff;
    *--cp = byte % 10 + '0';
    byte /= 10;
    if (byte > 0) {
      *--cp = byte % 10 + '0';
      byte /= 10;
      if (byte > 0)
        *--cp = byte + '0';
    }
    *--cp = '.';
    addr >>= 8;
  } while (--n > 0);
  retStr = (char *)(cp + 1);
  return (retStr);
}


x86 assembly (clang, -O0):
<fast_intoa>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,-0x1(%rax)
movl   $0x4,-0x30(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x2c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    11d5 <fast_intoa+0xd5>
mov    -0x2c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x2c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    11d0 <fast_intoa+0xd0>
mov    -0x2c(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,-0x1(%rax)
jmp    11d5 <fast_intoa+0xd5>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2e,-0x1(%rax)
mov    -0x4(%rbp),%eax
shr    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jg     1137 <fast_intoa+0x37>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fast_intoa>:
movslq %edx,%rax
movb   $0x0,-0x1(%rsi,%rax,1)
movzbl %dil,%r8d
imul   $0xcd,%r8d,%edx
shr    $0xb,%edx
lea    (%rdx,%rdx,1),%ecx
lea    (%rcx,%rcx,4),%r9d
mov    %r8d,%ecx
sub    %r9b,%cl
or     $0x30,%cl
mov    %cl,-0x2(%rsi,%rax,1)
cmp    $0xa,%r8d
jae    1139 <fast_intoa+0x39>
add    %rsi,%rax
add    $0xfffffffffffffffe,%rax
jmp    117b <fast_intoa+0x7b>
add    %rsi,%rax
add    $0xffffffffffffffff,%rax
movzbl %dl,%ecx
imul   $0xcd,%ecx,%edx
shr    $0xa,%edx
and    $0xfffffffe,%edx
lea    (%rdx,%rdx,4),%edx
sub    %dl,%cl
or     $0x30,%cl
mov    %cl,-0x2(%rax)
cmp    $0x64,%r8d
jae    1166 <fast_intoa+0x66>
add    $0xfffffffffffffffe,%rax
jmp    117b <fast_intoa+0x7b>
lea    (%r8,%r8,4),%ecx
lea    (%r8,%rcx,8),%ecx
shr    $0xc,%ecx
or     $0x30,%cl
mov    %cl,-0x3(%rax)
add    $0xfffffffffffffffd,%rax
movb   $0x2e,-0x1(%rax)
mov    %edi,%ecx
shr    $0x8,%ecx
movzbl %cl,%r8d
imul   $0xcd,%r8d,%edx
shr    $0xb,%edx
lea    (%rdx,%rdx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %r8d,%ecx
sub    %sil,%cl
or     $0x30,%cl
mov    %cl,-0x2(%rax)
cmp    $0xa,%r8d
jae    11b0 <fast_intoa+0xb0>
add    $0xfffffffffffffffe,%rax
jmp    11eb <fast_intoa+0xeb>
movzbl %dl,%ecx
imul   $0xcd,%ecx,%edx
shr    $0xa,%edx
and    $0xfffffffe,%edx
lea    (%rdx,%rdx,4),%edx
sub    %dl,%cl
or     $0x30,%cl
mov    %cl,-0x3(%rax)
cmp    $0x64,%r8d
jae    11d6 <fast_intoa+0xd6>
add    $0xfffffffffffffffd,%rax
jmp    11eb <fast_intoa+0xeb>
lea    (%r8,%r8,4),%ecx
lea    (%r8,%rcx,8),%ecx
shr    $0xc,%ecx
or     $0x30,%cl
mov    %cl,-0x4(%rax)
add    $0xfffffffffffffffc,%rax
movb   $0x2e,-0x1(%rax)
mov    %edi,%ecx
shr    $0x10,%ecx
movzbl %cl,%r8d
imul   $0xcd,%r8d,%edx
shr    $0xb,%edx
lea    (%rdx,%rdx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %r8d,%ecx
sub    %sil,%cl
or     $0x30,%cl
mov    %cl,-0x2(%rax)
cmp    $0xa,%r8d
jae    1220 <fast_intoa+0x120>
add    $0xfffffffffffffffe,%rax
jmp    125b <fast_intoa+0x15b>
movzbl %dl,%ecx
imul   $0xcd,%ecx,%edx
shr    $0xa,%edx
and    $0xfffffffe,%edx
lea    (%rdx,%rdx,4),%edx
sub    %dl,%cl
or     $0x30,%cl
mov    %cl,-0x3(%rax)
cmp    $0x64,%r8d
jae    1246 <fast_intoa+0x146>
add    $0xfffffffffffffffd,%rax
jmp    125b <fast_intoa+0x15b>
lea    (%r8,%r8,4),%ecx
lea    (%r8,%rcx,8),%ecx
shr    $0xc,%ecx
or     $0x30,%cl
mov    %cl,-0x4(%rax)
add    $0xfffffffffffffffc,%rax
movb   $0x2e,-0x1(%rax)
mov    %edi,%r8d
shr    $0x18,%r8d
imul   $0xcd,%r8d,%edx
shr    $0xb,%edx
lea    (%rdx,%rdx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %r8d,%ecx
sub    %sil,%cl
or     $0x30,%cl
mov    %cl,-0x2(%rax)
cmp    $0xa000000,%edi
jae    1293 <fast_intoa+0x193>
add    $0xfffffffffffffffe,%rax
movb   $0x2e,-0x1(%rax)
ret
movzbl %dl,%ecx
imul   $0xcd,%ecx,%edx
shr    $0xa,%edx
and    $0xfffffffe,%edx
lea    (%rdx,%rdx,4),%edx
sub    %dl,%cl
or     $0x30,%cl
mov    %cl,-0x3(%rax)
cmp    $0x64000000,%edi
jae    12be <fast_intoa+0x1be>
add    $0xfffffffffffffffd,%rax
movb   $0x2e,-0x1(%rax)
ret
movzbl %r8b,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,8),%ecx
shr    $0xc,%ecx
or     $0x30,%cl
mov    %cl,-0x4(%rax)
add    $0xfffffffffffffffc,%rax
movb   $0x2e,-0x1(%rax)
ret

LLVM IR (-O0):
define i8* @fast_intoa(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i8*, i8** %5
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i32 -1
store i8* %16, i8** %7
store i8 0, i8* %16
store i32 4, i32* %10
br label %17
17: ; preds = %53, %3
%18 = load i32, i32* %4
%19 = and i32 %18, 255
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = srem i32 %20, 10
%22 = add nsw i32 %21, 48
%23 = trunc i32 %22 to i8
%24 = load i8*, i8** %7
%25 = getelementptr inbounds i8, i8* %24, i32 -1
store i8* %25, i8** %7
store i8 %23, i8* %25
%26 = load i32, i32* %9
%27 = sdiv i32 %26, 10
store i32 %27, i32* %9
%28 = load i32, i32* %9
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %48
30: ; preds = %17
%31 = load i32, i32* %9
%32 = srem i32 %31, 10
%33 = add nsw i32 %32, 48
%34 = trunc i32 %33 to i8
%35 = load i8*, i8** %7
%36 = getelementptr inbounds i8, i8* %35, i32 -1
store i8* %36, i8** %7
store i8 %34, i8* %36
%37 = load i32, i32* %9
%38 = sdiv i32 %37, 10
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %30
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 48
%44 = trunc i32 %43 to i8
%45 = load i8*, i8** %7
%46 = getelementptr inbounds i8, i8* %45, i32 -1
store i8* %46, i8** %7
store i8 %44, i8* %46
br label %47
47: ; preds = %41, %30
br label %48
48: ; preds = %47, %17
%49 = load i8*, i8** %7
%50 = getelementptr inbounds i8, i8* %49, i32 -1
store i8* %50, i8** %7
store i8 46, i8* %50
%51 = load i32, i32* %4
%52 = lshr i32 %51, 8
store i32 %52, i32* %4
br label %53
53: ; preds = %48
%54 = load i32, i32* %10
%55 = add nsw i32 %54, -1
store i32 %55, i32* %10
%56 = icmp sgt i32 %55, 0
br i1 %56, label %17, label %57
57: ; preds = %53
%58 = load i8*, i8** %7
%59 = getelementptr inbounds i8, i8* %58, i64 1
store i8* %59, i8** %8
%60 = load i8*, i8** %8
ret i8* %60
}

LLVM IR (-O2):
define i8* @fast_intoa(i32 %0, i8* writeonly %1, i32 %2) {
%4 = sext i32 %2 to i64
%5 = getelementptr inbounds i8, i8* %1, i64 %4
%6 = getelementptr inbounds i8, i8* %5, i64 -1
store i8 0, i8* %6
%7 = and i32 %0, 255
%8 = trunc i32 %0 to i8
%9 = urem i8 %8, 10
%10 = udiv i8 %8, 10
%11 = or i8 %9, 48
%12 = getelementptr inbounds i8, i8* %6, i64 -1
store i8 %11, i8* %12
%13 = icmp ult i32 %7, 10
br i1 %13, label %23, label %14
14: ; preds = %3
%15 = urem i8 %10, 10
%16 = or i8 %15, 48
%17 = getelementptr inbounds i8, i8* %6, i64 -2
store i8 %16, i8* %17
%18 = icmp ult i32 %7, 100
br i1 %18, label %23, label %19
19: ; preds = %14
%20 = udiv i8 %8, 100
%21 = or i8 %20, 48
%22 = getelementptr inbounds i8, i8* %6, i64 -3
store i8 %21, i8* %22
br label %23
23: ; preds = %14, %19, %3
%24 = phi i8* [ %22, %19 ], [ %17, %14 ], [ %12, %3 ]
%25 = getelementptr inbounds i8, i8* %24, i64 -1
store i8 46, i8* %25
%26 = lshr i32 %0, 8
%27 = and i32 %26, 255
%28 = trunc i32 %26 to i8
%29 = urem i8 %28, 10
%30 = udiv i8 %28, 10
%31 = or i8 %29, 48
%32 = getelementptr inbounds i8, i8* %24, i64 -2
store i8 %31, i8* %32
%33 = icmp ult i32 %27, 10
br i1 %33, label %43, label %34
34: ; preds = %23
%35 = urem i8 %30, 10
%36 = or i8 %35, 48
%37 = getelementptr inbounds i8, i8* %24, i64 -3
store i8 %36, i8* %37
%38 = icmp ult i32 %27, 100
br i1 %38, label %43, label %39
39: ; preds = %34
%40 = udiv i8 %28, 100
%41 = or i8 %40, 48
%42 = getelementptr inbounds i8, i8* %24, i64 -4
store i8 %41, i8* %42
br label %43
43: ; preds = %39, %34, %23
%44 = phi i8* [ %42, %39 ], [ %37, %34 ], [ %32, %23 ]
%45 = getelementptr inbounds i8, i8* %44, i64 -1
store i8 46, i8* %45
%46 = lshr i32 %0, 16
%47 = and i32 %46, 255
%48 = trunc i32 %46 to i8
%49 = urem i8 %48, 10
%50 = udiv i8 %48, 10
%51 = or i8 %49, 48
%52 = getelementptr inbounds i8, i8* %44, i64 -2
store i8 %51, i8* %52
%53 = icmp ult i32 %47, 10
br i1 %53, label %63, label %54
54: ; preds = %43
%55 = urem i8 %50, 10
%56 = or i8 %55, 48
%57 = getelementptr inbounds i8, i8* %44, i64 -3
store i8 %56, i8* %57
%58 = icmp ult i32 %47, 100
br i1 %58, label %63, label %59
59: ; preds = %54
%60 = udiv i8 %48, 100
%61 = or i8 %60, 48
%62 = getelementptr inbounds i8, i8* %44, i64 -4
store i8 %61, i8* %62
br label %63
63: ; preds = %59, %54, %43
%64 = phi i8* [ %62, %59 ], [ %57, %54 ], [ %52, %43 ]
%65 = getelementptr inbounds i8, i8* %64, i64 -1
store i8 46, i8* %65
%66 = lshr i32 %0, 24
%67 = trunc i32 %66 to i8
%68 = urem i8 %67, 10
%69 = udiv i8 %67, 10
%70 = or i8 %68, 48
%71 = getelementptr inbounds i8, i8* %64, i64 -2
store i8 %70, i8* %71
%72 = icmp ult i32 %0, 167772160
br i1 %72, label %82, label %73
73: ; preds = %63
%74 = urem i8 %69, 10
%75 = or i8 %74, 48
%76 = getelementptr inbounds i8, i8* %64, i64 -3
store i8 %75, i8* %76
%77 = icmp ult i32 %0, 1677721600
br i1 %77, label %82, label %78
78: ; preds = %73
%79 = udiv i8 %67, 100
%80 = or i8 %79, 48
%81 = getelementptr inbounds i8, i8* %64, i64 -4
store i8 %80, i8* %81
br label %82
82: ; preds = %78, %73, %63
%83 = phi i8* [ %81, %78 ], [ %76, %73 ], [ %71, %63 ]
%84 = getelementptr inbounds i8, i8* %83, i64 -1
store i8 46, i8* %84
ret i8* %83
}