#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int);
char *inet_ntoa_r(struct in_addr in, char *buf, int bufsize) {
  register char *p;
  p = (char *)&in;
  (void)snprintf(buf, bufsize, "%d.%d.%d.%d", (((int)p[0]) & 0xff),
                 (((int)p[1]) & 0xff), (((int)p[2]) & 0xff),
                 (((int)p[3]) & 0xff));
  return (buf);
}


x86 assembly (clang, -O0):
<inet_ntoa_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
and    $0xff,%ecx
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%r8d
and    $0xff,%r8d
mov    -0x20(%rbp),%rax
movsbl 0x2(%rax),%r9d
and    $0xff,%r9d
mov    -0x20(%rbp),%rax
movsbl 0x3(%rax),%eax
and    $0xff,%eax
lea    0xe8e(%rip),%rdx
mov    %eax,(%rsp)
call   1030 <snprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_ntoa_r>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%eax
movzbl %al,%ecx
movzbl %ah,%ebp
mov    %edi,%esi
shr    $0x10,%esi
movzbl %sil,%r9d
shr    $0x18,%eax
mov    %eax,(%rsp)
lea    0xecc(%rip),%rax
mov    %rbx,%rdi
mov    %edx,%esi
mov    %rax,%rdx
mov    %ebp,%r8d
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @inet_ntoa_r(i32 %0, i8* %1, i32 %2) {
%4 = alloca %struct.in_addr
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %4, i32 0, i32 0
store i32 %0, i32* %8
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = bitcast %struct.in_addr* %4 to i8*
store i8* %9, i8** %7
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = load i8*, i8** %7
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = and i32 %15, 255
%17 = load i8*, i8** %7
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = and i32 %20, 255
%22 = load i8*, i8** %7
%23 = getelementptr inbounds i8, i8* %22, i64 2
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = and i32 %25, 255
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 3
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = and i32 %30, 255
%32 = call i32 @snprintf(i8* %10, i32 %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %21, i32 %26, i32 %31)
%33 = load i8*, i8** %5
ret i8* %33
}

LLVM IR (-O2):
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @inet_ntoa_r(i32 %0, i8* returned %1, i32 %2) {
%4 = and i32 %0, 255
%5 = lshr i32 %0, 8
%6 = and i32 %5, 255
%7 = lshr i32 %0, 16
%8 = and i32 %7, 255
%9 = lshr i32 %0, 24
%10 = tail call i32 @snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6, i32 %8, i32 %9)
ret i8* %1
}