#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 u_int32_t;
typedef int u_int;

/* Variables and functions */
int ntohl(int);
char *intoa(u_int32_t addr) {
  char *cp;
  u_int byte;
  int n;
  static char buf[sizeof(".xxx.xxx.xxx.xxx")];
  addr = ntohl(addr);
  cp = &buf[sizeof buf];
  *--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);
  return cp + 1;
}


x86 assembly (clang, -O0):
<intoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <ntohl@plt>
mov    %eax,-0x4(%rbp)
lea    0x2f13(%rip),%rax
add    $0x11,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,-0x1(%rax)
movl   $0x4,-0x18(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11ed <intoa+0xdd>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11e8 <intoa+0xd8>
mov    -0x14(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,-0x1(%rax)
jmp    11ed <intoa+0xdd>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x2e,-0x1(%rax)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jg     114f <intoa+0x3f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intoa>:
push   %rax
call   1030 <ntohl@plt>
mov    %eax,%r8d
movb   $0x0,0x2f30(%rip)
movzbl %r8b,%eax
imul   $0xcd,%eax,%edx
shr    $0xb,%edx
lea    (%rdx,%rdx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %eax,%ecx
sub    %sil,%cl
or     $0x30,%cl
mov    %cl,0x2f0e(%rip)
cmp    $0xa,%eax
jae    114f <intoa+0x3f>
lea    0x2f02(%rip),%rax
jmp    1192 <intoa+0x82>
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,0x2ee2(%rip)
cmp    $0x64,%eax
jae    117a <intoa+0x6a>
lea    0x2ed6(%rip),%rax
jmp    1192 <intoa+0x82>
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,8),%eax
shr    $0xc,%eax
or     $0x30,%al
mov    %al,0x2ec2(%rip)
lea    0x2ebb(%rip),%rax
movb   $0x2e,-0x1(%rax)
mov    %r8d,%ecx
sar    $0x8,%ecx
movzbl %cl,%edx
imul   $0xcd,%edx,%esi
shr    $0xb,%esi
lea    (%rsi,%rsi,1),%ecx
lea    (%rcx,%rcx,4),%edi
mov    %edx,%ecx
sub    %dil,%cl
or     $0x30,%cl
mov    %cl,-0x2(%rax)
cmp    $0xa,%edx
jae    11c4 <intoa+0xb4>
add    $0xfffffffffffffffe,%rax
jmp    11fe <intoa+0xee>
movzbl %sil,%ecx
imul   $0xcd,%ecx,%esi
shr    $0xa,%esi
and    $0xfffffffe,%esi
lea    (%rsi,%rsi,4),%esi
sub    %sil,%cl
or     $0x30,%cl
mov    %cl,-0x3(%rax)
cmp    $0x64,%edx
jae    11eb <intoa+0xdb>
add    $0xfffffffffffffffd,%rax
jmp    11fe <intoa+0xee>
lea    (%rdx,%rdx,4),%ecx
lea    (%rdx,%rcx,8),%ecx
shr    $0xc,%ecx
or     $0x30,%cl
mov    %cl,-0x4(%rax)
add    $0xfffffffffffffffc,%rax
movb   $0x2e,-0x1(%rax)
mov    %r8d,%ecx
sar    $0x10,%ecx
movzbl %cl,%edx
imul   $0xcd,%edx,%esi
shr    $0xb,%esi
lea    (%rsi,%rsi,1),%ecx
lea    (%rcx,%rcx,4),%edi
mov    %edx,%ecx
sub    %dil,%cl
or     $0x30,%cl
mov    %cl,-0x2(%rax)
cmp    $0xa,%edx
jae    1230 <intoa+0x120>
add    $0xfffffffffffffffe,%rax
jmp    126a <intoa+0x15a>
movzbl %sil,%ecx
imul   $0xcd,%ecx,%esi
shr    $0xa,%esi
and    $0xfffffffe,%esi
lea    (%rsi,%rsi,4),%esi
sub    %sil,%cl
or     $0x30,%cl
mov    %cl,-0x3(%rax)
cmp    $0x64,%edx
jae    1257 <intoa+0x147>
add    $0xfffffffffffffffd,%rax
jmp    126a <intoa+0x15a>
lea    (%rdx,%rdx,4),%ecx
lea    (%rdx,%rcx,8),%ecx
shr    $0xc,%ecx
or     $0x30,%cl
mov    %cl,-0x4(%rax)
add    $0xfffffffffffffffc,%rax
movb   $0x2e,-0x1(%rax)
sar    $0x18,%r8d
movzbl %r8b,%edi
imul   $0xcd,%edi,%edx
shr    $0xb,%edx
lea    (%rdx,%rdx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %edi,%ecx
sub    %sil,%cl
or     $0x30,%cl
mov    %cl,-0x2(%rax)
cmp    $0xa,%edi
jae    129b <intoa+0x18b>
add    $0xfffffffffffffffe,%rax
jmp    12d3 <intoa+0x1c3>
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,%edi
jae    12c0 <intoa+0x1b0>
add    $0xfffffffffffffffd,%rax
jmp    12d3 <intoa+0x1c3>
lea    (%rdi,%rdi,4),%ecx
lea    (%rdi,%rcx,8),%ecx
shr    $0xc,%ecx
or     $0x30,%cl
mov    %cl,-0x4(%rax)
add    $0xfffffffffffffffc,%rax
movb   $0x2e,-0x1(%rax)
pop    %rcx
ret

LLVM IR (-O0):
@intoa.buf = internal global [17 x i8] zeroinitializer
define i8* @intoa(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @ntohl(i32 %6)
store i32 %7, i32* %2
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @intoa.buf, i64 1, i64 0), i8** %3
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i32 -1
store i8* %9, i8** %3
store i8 0, i8* %9
store i32 4, i32* %5
br label %10
10: ; preds = %46, %1
%11 = load i32, i32* %2
%12 = and i32 %11, 255
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = srem i32 %13, 10
%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* %18
%19 = load i32, i32* %4
%20 = sdiv i32 %19, 10
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %41
23: ; preds = %10
%24 = load i32, i32* %4
%25 = srem i32 %24, 10
%26 = add nsw i32 %25, 48
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i32 -1
store i8* %29, i8** %3
store i8 %27, i8* %29
%30 = load i32, i32* %4
%31 = sdiv i32 %30, 10
store i32 %31, i32* %4
%32 = load i32, i32* %4
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %23
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 48
%37 = trunc i32 %36 to i8
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i32 -1
store i8* %39, i8** %3
store i8 %37, i8* %39
br label %40
40: ; preds = %34, %23
br label %41
41: ; preds = %40, %10
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i32 -1
store i8* %43, i8** %3
store i8 46, i8* %43
%44 = load i32, i32* %2
%45 = ashr i32 %44, 8
store i32 %45, i32* %2
br label %46
46: ; preds = %41
%47 = load i32, i32* %5
%48 = add nsw i32 %47, -1
store i32 %48, i32* %5
%49 = icmp sgt i32 %48, 0
br i1 %49, label %10, label %50
50: ; preds = %46
%51 = load i8*, i8** %3
%52 = getelementptr inbounds i8, i8* %51, i64 1
ret i8* %52
}

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