#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 uint8_t;
struct in_addr {
  unsigned int s_addr;
};

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int);
char *inet_ntoa(struct in_addr in) {
  unsigned int ip;
  static char __inet_ntoa_result[18];
  int i;
  uint8_t bytes[4];
  uint8_t *addrbyte;
  ip = in.s_addr;
  addrbyte = (uint8_t *)&ip;
  for (i = 0; i < 4; i++) {
    bytes[i] = *addrbyte++;
  }
  snprintf(__inet_ntoa_result, 18, "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2],
           bytes[3]);
  return __inet_ntoa_result;
}


x86 assembly (clang, -O0):
<inet_ntoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    1161 <inet_ntoa+0x51>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1130 <inet_ntoa+0x20>
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x14(%rbp),%eax
lea    0x2eca(%rip),%rdi
mov    $0x12,%esi
lea    0xe7e(%rip),%rdx
mov    %eax,(%rsp)
call   1030 <snprintf@plt>
lea    0x2eaf(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_ntoa>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ecx
lea    0x2f22(%rip),%rbx
lea    0xedb(%rip),%rdx
mov    %rbx,%rdi
mov    $0x12,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@inet_ntoa.__inet_ntoa_result = internal global [18 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @inet_ntoa(i32 %0) {
%2 = alloca %struct.in_addr
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 x i32]
%6 = alloca i32*
%7 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %2, i32 0, i32 0
store i32 %0, i32* %7
%8 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %2, i32 0, i32 0
%9 = load i32, i32* %8
store i32 %9, i32* %3
store i32* %3, i32** %6
store i32 0, i32* %4
br label %10
10: ; preds = %20, %1
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32*, i32** %6
%15 = getelementptr inbounds i32, i32* %14, i32 1
store i32* %15, i32** %6
%16 = load i32, i32* %14
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 %18
store i32 %16, i32* %19
br label %20
20: ; preds = %13
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %10
23: ; preds = %10
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%25 = load i32, i32* %24
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 1
%27 = load i32, i32* %26
%28 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 2
%29 = load i32, i32* %28
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 3
%31 = load i32, i32* %30
%32 = call i32 @snprintf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @inet_ntoa.__inet_ntoa_result, i64 0, i64 0), i32 18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %27, i32 %29, i32 %31)
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @inet_ntoa.__inet_ntoa_result, i64 0, i64 0)
}

LLVM IR (-O2):
@inet_ntoa.__inet_ntoa_result = internal global [18 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @inet_ntoa(i32 %0) {
%2 = tail call i32 @snprintf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @inet_ntoa.__inet_ntoa_result, i64 0, i64 0), i32 18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %0, i32 poison, i32 poison, i32 poison)
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @inet_ntoa.__inet_ntoa_result, i64 0, i64 0)
}