#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 size_t u_int;

/* Variables and functions */
char *bpf_intoaV4(unsigned int addr, char *buf, u_int bufLen) {
  char *cp, *retStr;
  u_int 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):
<bpf_intoaV4>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%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,-0x34(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,%eax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
add    $0x30,%rdx
mov    %dl,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x30(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jbe    11ea <bpf_intoaV4+0xea>
mov    -0x30(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
add    $0x30,%rdx
mov    %dl,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x30(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jbe    11e5 <bpf_intoaV4+0xe5>
mov    -0x30(%rbp),%rax
add    $0x30,%rax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,-0x1(%rax)
jmp    11ea <bpf_intoaV4+0xea>
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    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jg     1135 <bpf_intoaV4+0x35>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpf_intoaV4>:
movb   $0x0,-0x1(%rsi,%rdx,1)
movzbl %dil,%r8d
imul   $0xcd,%r8d,%ecx
shr    $0xb,%ecx
lea    (%rcx,%rcx,1),%eax
lea    (%rax,%rax,4),%r9d
mov    %r8d,%eax
sub    %r9b,%al
or     $0x30,%al
mov    %al,-0x2(%rsi,%rdx,1)
cmp    $0xa,%r8d
jae    1136 <bpf_intoaV4+0x36>
lea    (%rsi,%rdx,1),%rax
add    $0xfffffffffffffffe,%rax
jmp    1179 <bpf_intoaV4+0x79>
lea    (%rsi,%rdx,1),%rax
add    $0xffffffffffffffff,%rax
movzbl %cl,%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    1164 <bpf_intoaV4+0x64>
add    $0xfffffffffffffffe,%rax
jmp    1179 <bpf_intoaV4+0x79>
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    11ae <bpf_intoaV4+0xae>
add    $0xfffffffffffffffe,%rax
jmp    11e9 <bpf_intoaV4+0xe9>
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    11d4 <bpf_intoaV4+0xd4>
add    $0xfffffffffffffffd,%rax
jmp    11e9 <bpf_intoaV4+0xe9>
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    121e <bpf_intoaV4+0x11e>
add    $0xfffffffffffffffe,%rax
jmp    1259 <bpf_intoaV4+0x159>
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    1244 <bpf_intoaV4+0x144>
add    $0xfffffffffffffffd,%rax
jmp    1259 <bpf_intoaV4+0x159>
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    1291 <bpf_intoaV4+0x191>
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    12bc <bpf_intoaV4+0x1bc>
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* @bpf_intoaV4(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%11 = load i8*, i8** %5
%12 = load i64, i64* %6
%13 = getelementptr inbounds i8, i8* %11, i64 %12
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i32 -1
store i8* %15, i8** %7
store i8 0, i8* %15
store i32 4, i32* %10
br label %16
16: ; preds = %53, %3
%17 = load i32, i32* %4
%18 = and i32 %17, 255
%19 = zext i32 %18 to i64
store i64 %19, i64* %9
%20 = load i64, i64* %9
%21 = urem i64 %20, 10
%22 = add i64 %21, 48
%23 = trunc i64 %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 i64, i64* %9
%27 = udiv i64 %26, 10
store i64 %27, i64* %9
%28 = load i64, i64* %9
%29 = icmp ugt i64 %28, 0
br i1 %29, label %30, label %48
30: ; preds = %16
%31 = load i64, i64* %9
%32 = urem i64 %31, 10
%33 = add i64 %32, 48
%34 = trunc i64 %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 i64, i64* %9
%38 = udiv i64 %37, 10
store i64 %38, i64* %9
%39 = load i64, i64* %9
%40 = icmp ugt i64 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %30
%42 = load i64, i64* %9
%43 = add i64 %42, 48
%44 = trunc i64 %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, %16
%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 %16, 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* @bpf_intoaV4(i32 %0, i8* writeonly %1, i64 %2) {
%4 = getelementptr inbounds i8, i8* %1, i64 %2
%5 = getelementptr inbounds i8, i8* %4, i64 -1
store i8 0, i8* %5
%6 = and i32 %0, 255
%7 = trunc i32 %0 to i8
%8 = urem i8 %7, 10
%9 = udiv i8 %7, 10
%10 = or i8 %8, 48
%11 = getelementptr inbounds i8, i8* %5, i64 -1
store i8 %10, i8* %11
%12 = icmp ult i32 %6, 10
br i1 %12, label %22, label %13
13: ; preds = %3
%14 = urem i8 %9, 10
%15 = or i8 %14, 48
%16 = getelementptr inbounds i8, i8* %5, i64 -2
store i8 %15, i8* %16
%17 = icmp ult i32 %6, 100
br i1 %17, label %22, label %18
18: ; preds = %13
%19 = udiv i8 %7, 100
%20 = or i8 %19, 48
%21 = getelementptr inbounds i8, i8* %5, i64 -3
store i8 %20, i8* %21
br label %22
22: ; preds = %13, %18, %3
%23 = phi i8* [ %21, %18 ], [ %16, %13 ], [ %11, %3 ]
%24 = getelementptr inbounds i8, i8* %23, i64 -1
store i8 46, i8* %24
%25 = lshr i32 %0, 8
%26 = and i32 %25, 255
%27 = trunc i32 %25 to i8
%28 = urem i8 %27, 10
%29 = udiv i8 %27, 10
%30 = or i8 %28, 48
%31 = getelementptr inbounds i8, i8* %23, i64 -2
store i8 %30, i8* %31
%32 = icmp ult i32 %26, 10
br i1 %32, label %42, label %33
33: ; preds = %22
%34 = urem i8 %29, 10
%35 = or i8 %34, 48
%36 = getelementptr inbounds i8, i8* %23, i64 -3
store i8 %35, i8* %36
%37 = icmp ult i32 %26, 100
br i1 %37, label %42, label %38
38: ; preds = %33
%39 = udiv i8 %27, 100
%40 = or i8 %39, 48
%41 = getelementptr inbounds i8, i8* %23, i64 -4
store i8 %40, i8* %41
br label %42
42: ; preds = %38, %33, %22
%43 = phi i8* [ %41, %38 ], [ %36, %33 ], [ %31, %22 ]
%44 = getelementptr inbounds i8, i8* %43, i64 -1
store i8 46, i8* %44
%45 = lshr i32 %0, 16
%46 = and i32 %45, 255
%47 = trunc i32 %45 to i8
%48 = urem i8 %47, 10
%49 = udiv i8 %47, 10
%50 = or i8 %48, 48
%51 = getelementptr inbounds i8, i8* %43, i64 -2
store i8 %50, i8* %51
%52 = icmp ult i32 %46, 10
br i1 %52, label %62, label %53
53: ; preds = %42
%54 = urem i8 %49, 10
%55 = or i8 %54, 48
%56 = getelementptr inbounds i8, i8* %43, i64 -3
store i8 %55, i8* %56
%57 = icmp ult i32 %46, 100
br i1 %57, label %62, label %58
58: ; preds = %53
%59 = udiv i8 %47, 100
%60 = or i8 %59, 48
%61 = getelementptr inbounds i8, i8* %43, i64 -4
store i8 %60, i8* %61
br label %62
62: ; preds = %58, %53, %42
%63 = phi i8* [ %61, %58 ], [ %56, %53 ], [ %51, %42 ]
%64 = getelementptr inbounds i8, i8* %63, i64 -1
store i8 46, i8* %64
%65 = lshr i32 %0, 24
%66 = trunc i32 %65 to i8
%67 = urem i8 %66, 10
%68 = udiv i8 %66, 10
%69 = or i8 %67, 48
%70 = getelementptr inbounds i8, i8* %63, i64 -2
store i8 %69, i8* %70
%71 = icmp ult i32 %0, 167772160
br i1 %71, label %81, label %72
72: ; preds = %62
%73 = urem i8 %68, 10
%74 = or i8 %73, 48
%75 = getelementptr inbounds i8, i8* %63, i64 -3
store i8 %74, i8* %75
%76 = icmp ult i32 %0, 1677721600
br i1 %76, label %81, label %77
77: ; preds = %72
%78 = udiv i8 %66, 100
%79 = or i8 %78, 48
%80 = getelementptr inbounds i8, i8* %63, i64 -4
store i8 %79, i8* %80
br label %81
81: ; preds = %77, %72, %62
%82 = phi i8* [ %80, %77 ], [ %75, %72 ], [ %70, %62 ]
%83 = getelementptr inbounds i8, i8* %82, i64 -1
store i8 46, i8* %83
ret i8* %82
}