#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 {
  unsigned int s_addr;
};
typedef int /*<<< orphan*/ ipstr;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned int, unsigned int,
                            unsigned int, unsigned int);
char *inet_ntoa(struct in_addr addr) {
  unsigned int ip;
  static char ipstr[32];
  ip = addr.s_addr;
  snprintf(ipstr, sizeof(ipstr), "%u.%u.%u.%u", ((ip >> 0) & 0xff),
           ((ip >> 8) & 0xff), ((ip >> 16) & 0xff), ((ip >> 24) & 0xff));
  return ipstr;
}


x86 assembly (clang, -O0):
<inet_ntoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
shr    $0x0,%ecx
and    $0xff,%ecx
mov    -0xc(%rbp),%r8d
shr    $0x8,%r8d
and    $0xff,%r8d
mov    -0xc(%rbp),%r9d
shr    $0x10,%r9d
and    $0xff,%r9d
mov    -0xc(%rbp),%eax
shr    $0x18,%eax
and    $0xff,%eax
lea    0x2ee3(%rip),%rdi
mov    $0x20,%esi
lea    0xe97(%rip),%rdx
mov    %eax,(%rsp)
call   1030 <snprintf@plt>
lea    0x2ec8(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_ntoa>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%edx
movzbl %dl,%ecx
movzbl %dh,%eax
mov    %edi,%esi
shr    $0x10,%esi
movzbl %sil,%r9d
shr    $0x18,%edx
mov    %edx,(%rsp)
lea    0x2f0d(%rip),%rbx
lea    0xec6(%rip),%rdx
mov    %rbx,%rdi
mov    $0x20,%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.ipstr = internal global [32 x i8] zeroinitializer
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i8* @inet_ntoa(i32 %0) {
%2 = alloca %struct.in_addr
%3 = alloca i32
%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 = load i32, i32* %5
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = lshr i32 %7, 0
%9 = and i32 %8, 255
%10 = load i32, i32* %3
%11 = lshr i32 %10, 8
%12 = and i32 %11, 255
%13 = load i32, i32* %3
%14 = lshr i32 %13, 16
%15 = and i32 %14, 255
%16 = load i32, i32* %3
%17 = lshr i32 %16, 24
%18 = and i32 %17, 255
%19 = call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @inet_ntoa.ipstr, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12, i32 %15, i32 %18)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @inet_ntoa.ipstr, i64 0, i64 0)
}

LLVM IR (-O2):
@inet_ntoa.ipstr = internal global [32 x i8] zeroinitializer
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i8* @inet_ntoa(i32 %0) {
%2 = and i32 %0, 255
%3 = lshr i32 %0, 8
%4 = and i32 %3, 255
%5 = lshr i32 %0, 16
%6 = and i32 %5, 255
%7 = lshr i32 %0, 24
%8 = tail call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @inet_ntoa.ipstr, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %4, i32 %6, i32 %7)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @inet_ntoa.ipstr, i64 0, i64 0)
}