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

/* Variables and functions */
char *inet_nsap_ntoa(int binlen, const u_char *binary, char *ascii) {
  int nib;
  int i;
  static char tmpbuf[255 * 2 + 128];
  char *start;
  if (ascii)
    start = ascii;
  else {
    ascii = tmpbuf;
    start = tmpbuf;
  }
  if (binlen > 255)
    binlen = 255;
  for (i = 0; i < binlen; i++) {
    nib = *binary >> 4;
    *ascii++ = nib + (nib < 10 ? '0' : '7');
    nib = *binary++ & 0x0f;
    *ascii++ = nib + (nib < 10 ? '0' : '7');
    if (((i % 2) == 0 && (i + 1) < binlen))
      *ascii++ = '.';
  }
  *ascii = '\0';
  return (start);
}


x86 assembly (clang, -O0):
<inet_nsap_ntoa>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1127 <inet_nsap_ntoa+0x27>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    113d <inet_nsap_ntoa+0x3d>
lea    0x2f02(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0x2ef7(%rip),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0xff,-0x4(%rbp)
jle    1151 <inet_nsap_ntoa+0x51>
movl   $0xff,-0x4(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1225 <inet_nsap_ntoa+0x125>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sar    $0x4,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x1c(%rbp),%esi
mov    $0x37,%ecx
mov    $0x30,%edx
cmp    $0xa,%esi
cmovl  %edx,%ecx
add    %ecx,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%eax
and    $0xf,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x1c(%rbp),%esi
mov    $0x37,%ecx
mov    $0x30,%edx
cmp    $0xa,%esi
cmovl  %edx,%ecx
add    %ecx,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1212 <inet_nsap_ntoa+0x112>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cmp    -0x4(%rbp),%eax
jge    1212 <inet_nsap_ntoa+0x112>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x2e,(%rax)
jmp    1217 <inet_nsap_ntoa+0x117>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1158 <inet_nsap_ntoa+0x58>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_nsap_ntoa>:
push   %rbx
test   %rdx,%rdx
lea    0x2f25(%rip),%rax
cmovne %rdx,%rax
cmp    $0xff,%edi
mov    $0xff,%r8d
cmovl  %edi,%r8d
mov    %rax,%rdx
test   %edi,%edi
jle    11a0 <inet_nsap_ntoa+0xa0>
cmp    $0x2,%r8d
mov    $0x1,%r9d
cmovge %r8d,%r9d
xor    %edi,%edi
mov    %rax,%rbx
jmp    114c <inet_nsap_ntoa+0x4c>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rdi
mov    %rdx,%rbx
cmp    %edi,%r9d
je     11a0 <inet_nsap_ntoa+0xa0>
mov    (%rsi,%rdi,4),%r10d
mov    %r10d,%edx
shr    $0x4,%edx
lea    0x37(%rdx),%r11d
add    $0x30,%edx
cmp    $0xa0,%r10d
cmovge %r11d,%edx
mov    %dl,(%rbx)
mov    (%rsi,%rdi,4),%edx
and    $0xf,%edx
lea    0x37(%rdx),%r10d
lea    0x30(%rdx),%ecx
cmp    $0xa,%edx
cmovae %r10d,%ecx
lea    0x2(%rbx),%rdx
mov    %cl,0x1(%rbx)
test   $0x1,%dil
jne    1140 <inet_nsap_ntoa+0x40>
lea    0x1(%rdi),%ecx
cmp    %r8d,%ecx
jge    1140 <inet_nsap_ntoa+0x40>
movb   $0x2e,0x2(%rbx)
add    $0x3,%rbx
mov    %rbx,%rdx
jmp    1140 <inet_nsap_ntoa+0x40>
movb   $0x0,(%rdx)
pop    %rbx
ret

LLVM IR (-O0):
@inet_nsap_ntoa.tmpbuf = internal global [638 x i8] zeroinitializer
define i8* @inet_nsap_ntoa(i32 %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = load i8*, i8** %6
store i8* %13, i8** %9
br label %15
14: ; preds = %3
store i8* getelementptr inbounds ([638 x i8], [638 x i8]* @inet_nsap_ntoa.tmpbuf, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([638 x i8], [638 x i8]* @inet_nsap_ntoa.tmpbuf, i64 0, i64 0), i8** %9
br label %15
15: ; preds = %14, %12
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 255
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 255, i32* %4
br label %19
19: ; preds = %18, %15
store i32 0, i32* %8
br label %20
20: ; preds = %62, %19
%21 = load i32, i32* %8
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %65
24: ; preds = %20
%25 = load i32*, i32** %5
%26 = load i32, i32* %25
%27 = ashr i32 %26, 4
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = load i32, i32* %7
%30 = icmp slt i32 %29, 10
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 48, i32 55
%33 = add nsw i32 %28, %32
%34 = trunc i32 %33 to i8
%35 = load i8*, i8** %6
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %6
store i8 %34, i8* %35
%37 = load i32*, i32** %5
%38 = getelementptr inbounds i32, i32* %37, i32 1
store i32* %38, i32** %5
%39 = load i32, i32* %37
%40 = and i32 %39, 15
store i32 %40, i32* %7
%41 = load i32, i32* %7
%42 = load i32, i32* %7
%43 = icmp slt i32 %42, 10
%44 = zext i1 %43 to i64
%45 = select i1 %43, i32 48, i32 55
%46 = add nsw i32 %41, %45
%47 = trunc i32 %46 to i8
%48 = load i8*, i8** %6
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %6
store i8 %47, i8* %48
%50 = load i32, i32* %8
%51 = srem i32 %50, 2
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %61
53: ; preds = %24
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
%56 = load i32, i32* %4
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %61
58: ; preds = %53
%59 = load i8*, i8** %6
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %6
store i8 46, i8* %59
br label %61
61: ; preds = %58, %53, %24
br label %62
62: ; preds = %61
%63 = load i32, i32* %8
%64 = add nsw i32 %63, 1
store i32 %64, i32* %8
br label %20
65: ; preds = %20
%66 = load i8*, i8** %6
store i8 0, i8* %66
%67 = load i8*, i8** %9
ret i8* %67
}

LLVM IR (-O2):
@inet_nsap_ntoa.tmpbuf = internal global [638 x i8] zeroinitializer
define i8* @inet_nsap_ntoa(i32 %0, i32* nocapture %1, i8* writeonly %2) {
%4 = icmp eq i8* %2, null
%5 = select i1 %4, i8* getelementptr inbounds ([638 x i8], [638 x i8]* @inet_nsap_ntoa.tmpbuf, i64 0, i64 0), i8* %2
%6 = icmp slt i32 %0, 255
%7 = select i1 %6, i32 %0, i32 255
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %40
9: ; preds = %3
%10 = call i32 @llvm.smax.i32(i32 %7, i32 1)
br label %11
11: ; preds = %9, %37
%12 = phi i32 [ %32, %37 ], [ 0, %9 ]
%13 = phi i8* [ %38, %37 ], [ %5, %9 ]
%14 = phi i32* [ %22, %37 ], [ %1, %9 ]
%15 = load i32, i32* %14
%16 = lshr i32 %15, 4
%17 = icmp slt i32 %15, 160
%18 = select i1 %17, i32 48, i32 55
%19 = add nuw nsw i32 %18, %16
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %20, i8* %13
%22 = getelementptr inbounds i32, i32* %14, i64 1
%23 = load i32, i32* %14
%24 = and i32 %23, 15
%25 = icmp ult i32 %24, 10
%26 = select i1 %25, i32 48, i32 55
%27 = add nuw nsw i32 %26, %24
%28 = trunc i32 %27 to i8
%29 = getelementptr inbounds i8, i8* %13, i64 2
store i8 %28, i8* %21
%30 = and i32 %12, 1
%31 = icmp eq i32 %30, 0
%32 = add nuw nsw i32 %12, 1
%33 = icmp slt i32 %32, %7
%34 = select i1 %31, i1 %33, i1 false
br i1 %34, label %35, label %37
35: ; preds = %11
%36 = getelementptr inbounds i8, i8* %13, i64 3
store i8 46, i8* %29
br label %37
37: ; preds = %11, %35
%38 = phi i8* [ %36, %35 ], [ %29, %11 ]
%39 = icmp eq i32 %32, %10
br i1 %39, label %40, label %11
40: ; preds = %37, %3
%41 = phi i8* [ %5, %3 ], [ %38, %37 ]
store i8 0, i8* %41
ret i8* %5
}