#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 */
struct in_addr {
  int /*<<< orphan*/ s_addr;
};

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned char, unsigned char,
                            unsigned char, unsigned char);
char *inet_ntoa(struct in_addr in) {
  static char s[18];
  unsigned char *p;
  p = (unsigned char *)&in.s_addr;
  snprintf(s, sizeof s, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
  return s;
}


x86 assembly (clang, -O0):
<inet_ntoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%r8b
mov    -0x10(%rbp),%rax
mov    0x2(%rax),%r9b
mov    -0x10(%rbp),%rax
lea    0x2efc(%rip),%rdi
mov    $0x12,%esi
lea    0xeb0(%rip),%rdx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl 0x3(%rax),%eax
mov    %eax,(%rsp)
call   1030 <snprintf@plt>
lea    0x2ed2(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_ntoa>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%eax
mov    %edi,%edx
shr    $0x10,%edx
mov    %edi,%ecx
shr    $0x18,%ecx
mov    %ecx,(%rsp)
movzbl %al,%ecx
movzbl %ah,%eax
movzbl %dl,%r9d
lea    0x2f0b(%rip),%rbx
lea    0xec4(%rip),%rdx
mov    %rbx,%rdi
mov    $0x12,%esi
mov    %eax,%r8d
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@inet_ntoa.s = 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 i8*
%4 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %2, i32 0, i32 0
store i32 %0, i32* %4
%5 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %2, i32 0, i32 0
%6 = bitcast i32* %5 to i8*
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %11
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 2
%15 = load i8, i8* %14
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 3
%18 = load i8, i8* %17
%19 = call i32 @snprintf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @inet_ntoa.s, i64 0, i64 0), i32 18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 zeroext %9, i8 zeroext %12, i8 zeroext %15, i8 zeroext %18)
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @inet_ntoa.s, i64 0, i64 0)
}

LLVM IR (-O2):
@inet_ntoa.s = internal global [18 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
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 @snprintf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @inet_ntoa.s, i64 0, i64 0), i32 18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 zeroext %2, i8 zeroext %4, i8 zeroext %6, i8 zeroext %8)
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @inet_ntoa.s, i64 0, i64 0)
}