#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*/ uint32_t;

/* Variables and functions */
unsigned int integer_to_ascii(char *, unsigned char);
char *inet_ntoa(uint32_t ip_address) {
  static char buffer[20];
  unsigned int length;
  unsigned char *ip = (unsigned char *)&ip_address;
  length = integer_to_ascii(buffer, ip[3]);
  buffer[length] = '.';
  ++length;
  length += integer_to_ascii(buffer + length, ip[2]);
  buffer[length] = '.';
  ++length;
  length += integer_to_ascii(buffer + length, ip[1]);
  buffer[length] = '.';
  ++length;
  length += integer_to_ascii(buffer + length, ip[0]);
  buffer[length] = 0;
  return buffer;
}


x86 assembly (clang, -O0):
<inet_ntoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    0x2f12(%rip),%rdi
movzbl 0x3(%rax),%esi
call   1030 <integer_to_ascii@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
lea    0x2efa(%rip),%rax
movb   $0x2e,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
lea    0x2ee3(%rip),%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%esi
call   1030 <integer_to_ascii@plt>
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
lea    0x2ec1(%rip),%rax
movb   $0x2e,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
lea    0x2eaa(%rip),%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%esi
call   1030 <integer_to_ascii@plt>
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
lea    0x2e88(%rip),%rax
movb   $0x2e,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
lea    0x2e71(%rip),%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%rax
movzbl (%rax),%esi
call   1030 <integer_to_ascii@plt>
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
lea    0x2e50(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e45(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_ntoa>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebp
shr    $0x10,%ebp
mov    %edi,%eax
mov    %edi,%r15d
shr    $0x18,%eax
lea    0x2f15(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <integer_to_ascii@plt>
mov    %eax,%ebx
mov    %eax,%eax
movb   $0x2e,(%rax,%r14,1)
lea    0x1(%rbx),%edi
add    %r14,%rdi
movzbl %bpl,%esi
call   1030 <integer_to_ascii@plt>
lea    (%rax,%rbx,1),%ebp
add    $0x1,%ebp
movb   $0x2e,0x0(%rbp,%r14,1)
lea    (%rax,%rbx,1),%edi
add    $0x2,%edi
add    %r14,%rdi
mov    %r15d,%eax
movzbl %ah,%esi
call   1030 <integer_to_ascii@plt>
lea    (%rax,%rbp,1),%ebx
add    $0x1,%ebx
movb   $0x2e,(%rbx,%r14,1)
lea    (%rax,%rbp,1),%edi
add    $0x2,%edi
add    %r14,%rdi
movzbl %r15b,%esi
call   1030 <integer_to_ascii@plt>
add    %ebx,%eax
add    $0x1,%eax
movb   $0x0,(%rax,%r14,1)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@inet_ntoa.buffer = internal global [20 x i8] zeroinitializer
define i8* @inet_ntoa(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
%5 = bitcast i32* %2 to i8*
store i8* %5, i8** %4
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 3
%8 = load i8, i8* %7
%9 = call i32 @integer_to_ascii(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 0), i8 zeroext %8)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 %11
store i8 46, i8* %12
%13 = load i32, i32* %3
%14 = add i32 %13, 1
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 0), i64 %16
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = load i8, i8* %19
%21 = call i32 @integer_to_ascii(i8* %17, i8 zeroext %20)
%22 = load i32, i32* %3
%23 = add i32 %22, %21
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds [20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 %25
store i8 46, i8* %26
%27 = load i32, i32* %3
%28 = add i32 %27, 1
store i32 %28, i32* %3
%29 = load i32, i32* %3
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 0), i64 %30
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = load i8, i8* %33
%35 = call i32 @integer_to_ascii(i8* %31, i8 zeroext %34)
%36 = load i32, i32* %3
%37 = add i32 %36, %35
store i32 %37, i32* %3
%38 = load i32, i32* %3
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds [20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 %39
store i8 46, i8* %40
%41 = load i32, i32* %3
%42 = add i32 %41, 1
store i32 %42, i32* %3
%43 = load i32, i32* %3
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 0), i64 %44
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i64 0
%48 = load i8, i8* %47
%49 = call i32 @integer_to_ascii(i8* %45, i8 zeroext %48)
%50 = load i32, i32* %3
%51 = add i32 %50, %49
store i32 %51, i32* %3
%52 = load i32, i32* %3
%53 = zext i32 %52 to i64
%54 = getelementptr inbounds [20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 %53
store i8 0, i8* %54
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@inet_ntoa.buffer = internal global [20 x i8] zeroinitializer
define i8* @inet_ntoa(i32 %0) {
%2 = trunc i32 %0 to i8
%3 = lshr i32 %0, 8
%4 = trunc i32 %3 to i8
%5 = lshr i32 %0, 16
%6 = trunc i32 %5 to i8
%7 = lshr i32 %0, 24
%8 = trunc i32 %7 to i8
%9 = tail call i32 @integer_to_ascii(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 0), i8 zeroext %8)
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds [20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 %10
store i8 46, i8* %11
%12 = add i32 %9, 1
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds [20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 %13
%15 = tail call i32 @integer_to_ascii(i8* %14, i8 zeroext %6)
%16 = add i32 %15, %12
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 %17
store i8 46, i8* %18
%19 = add i32 %16, 1
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds [20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 %20
%22 = tail call i32 @integer_to_ascii(i8* %21, i8 zeroext %4)
%23 = add i32 %19, %22
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 %24
store i8 46, i8* %25
%26 = add i32 %23, 1
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 %27
%29 = tail call i32 @integer_to_ascii(i8* %28, i8 zeroext %2)
%30 = add i32 %26, %29
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds [20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 %31
store i8 0, i8* %32
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @inet_ntoa.buffer, i64 0, i64 0)
}