#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*/ uint8_t;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ _itoa(int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
char *_inet_ntoa(uint32_t in) {
  static char b[18];
  uint8_t *p = (uint8_t *)&in;
  char *o = b;
  while (p != ((uint8_t *)&in) + 3) {
    strcpy(o, _itoa(*p++));
    o += strlen(o);
    *o++ = '.';
  }
  o[-1] = 0;
  return b;
}


x86 assembly (clang, -O0):
<_inet_ntoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0x2f06(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
lea    -0x4(%rbp),%rcx
add    $0xc,%rcx
cmp    %rcx,%rax
je     11bc <_inet_ntoa+0x8c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%edi
call   1050 <_itoa@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x2e,(%rax)
jmp    114e <_inet_ntoa+0x1e>
mov    -0x18(%rbp),%rax
movb   $0x0,-0x1(%rax)
lea    0x2e85(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_inet_ntoa>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
call   1050 <_itoa@plt>
lea    0x2f09(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
lea    (%r14,%rax,1),%rbp
lea    (%rax,%r14,1),%rbx
add    $0x1,%rbx
movb   $0x2e,(%rax,%r14,1)
mov    %r15d,%edi
call   1050 <_itoa@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rax,%rbp,1),%r12
add    $0x1,%r12
lea    (%rax,%rbp,1),%rbx
add    $0x2,%rbx
movb   $0x2e,0x1(%rax,%rbp,1)
mov    %r15d,%edi
call   1050 <_itoa@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,0x1(%rax,%r12,1)
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@_inet_ntoa.b = internal global [18 x i8] zeroinitializer
define i8* @_inet_ntoa(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
store i32 %0, i32* %2
store i32* %2, i32** %3
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @_inet_ntoa.b, i64 0, i64 0), i8** %4
br label %5
5: ; preds = %9, %1
%6 = load i32*, i32** %3
%7 = getelementptr inbounds i32, i32* %2, i64 3
%8 = icmp ne i32* %6, %7
br i1 %8, label %9, label %23
9: ; preds = %5
%10 = load i8*, i8** %4
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i32 1
store i32* %12, i32** %3
%13 = load i32, i32* %11
%14 = call i32 @_itoa(i32 %13)
%15 = call i32 @strcpy(i8* %10, i32 %14)
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
%18 = load i8*, i8** %4
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds i8, i8* %18, i64 %19
store i8* %20, i8** %4
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
store i8 46, i8* %21
br label %5
23: ; preds = %5
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i64 -1
store i8 0, i8* %25
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @_inet_ntoa.b, i64 0, i64 0)
}

LLVM IR (-O2):
@_inet_ntoa.b = internal global [18 x i8] zeroinitializer
define i8* @_inet_ntoa(i32 %0) {
%2 = tail call i32 @_itoa(i32 %0)
%3 = tail call i32 @strcpy(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @_inet_ntoa.b, i64 0, i64 0), i32 %2)
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @_inet_ntoa.b, i64 0, i64 0))
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds [18 x i8], [18 x i8]* @_inet_ntoa.b, i64 0, i64 %5
%7 = getelementptr inbounds i8, i8* %6, i64 1
store i8 46, i8* %6
%8 = tail call i32 @_itoa(i32 %0)
%9 = tail call i32 @strcpy(i8* %7, i32 %8)
%10 = tail call i32 @strlen(i8* %7)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %7, i64 %11
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8 46, i8* %12
%14 = tail call i32 @_itoa(i32 %0)
%15 = tail call i32 @strcpy(i8* %13, i32 %14)
%16 = tail call i32 @strlen(i8* %13)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %13, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 1
store i8 46, i8* %18
%20 = getelementptr inbounds i8, i8* %19, i64 -1
store i8 0, i8* %20
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @_inet_ntoa.b, i64 0, i64 0)
}