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

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int);
char *inet_ntoa(unsigned long addr) {
  static char addr_str[32];
  memset(addr_str, 0, 32);
  sprintf(addr_str, "%d.%d.%d.%d", (int)(addr >> 24 & 0xFF),
          (int)(addr >> 16 & 0xFF), (int)(addr >> 8 & 0xFF),
          (int)(addr & 0xFF));
  return addr_str;
}


x86 assembly (clang, -O0):
<inet_ntoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f0d(%rip),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %eax,%edx
mov    -0x8(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %eax,%r8d
mov    -0x8(%rbp),%rax
and    $0xff,%rax
mov    %eax,%r9d
lea    0x2ebc(%rip),%rdi
lea    0xe75(%rip),%rsi
call   1040 <sprintf@plt>
lea    0x2ea9(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_ntoa>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x2f12(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
mov    %ebx,%edx
shr    $0x18,%edx
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%ecx
movzbl %bh,%eax
movzbl %bl,%r9d
lea    0xea8(%rip),%rsi
mov    %r14,%rdi
mov    %eax,%r8d
call   1040 <sprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@inet_ntoa.addr_str = internal global [32 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @inet_ntoa(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = call i32 @memset(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @inet_ntoa.addr_str, i64 0, i64 0), i32 0, i32 32)
%4 = load i64, i64* %2
%5 = lshr i64 %4, 24
%6 = and i64 %5, 255
%7 = trunc i64 %6 to i32
%8 = load i64, i64* %2
%9 = lshr i64 %8, 16
%10 = and i64 %9, 255
%11 = trunc i64 %10 to i32
%12 = load i64, i64* %2
%13 = lshr i64 %12, 8
%14 = and i64 %13, 255
%15 = trunc i64 %14 to i32
%16 = load i64, i64* %2
%17 = and i64 %16, 255
%18 = trunc i64 %17 to i32
%19 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @inet_ntoa.addr_str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %11, i32 %15, i32 %18)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @inet_ntoa.addr_str, i64 0, i64 0)
}

LLVM IR (-O2):
@inet_ntoa.addr_str = internal global [32 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @inet_ntoa(i64 %0) {
%2 = tail call i32 @memset(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @inet_ntoa.addr_str, i64 0, i64 0), i32 0, i32 32)
%3 = trunc i64 %0 to i32
%4 = lshr i32 %3, 24
%5 = lshr i32 %3, 16
%6 = and i32 %5, 255
%7 = lshr i32 %3, 8
%8 = and i32 %7, 255
%9 = and i32 %3, 255
%10 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @inet_ntoa.addr_str, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6, i32 %8, i32 %9)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @inet_ntoa.addr_str, i64 0, i64 0)
}