#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*/ diag_sprintf(char *, char *, unsigned char, unsigned char,
                                unsigned char, unsigned char);
char *inet_ntoa_r(struct in_addr ina, char *buf) {
  unsigned char *ucp = (unsigned char *)&ina;
  diag_sprintf(buf, "%d.%d.%d.%d", ucp[0] & 0xff, ucp[1] & 0xff, ucp[2] & 0xff,
               ucp[3] & 0xff);
  return buf;
}


x86 assembly (clang, -O0):
<inet_ntoa_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
movzbl 0x2(%rax),%eax
and    $0xff,%eax
mov    %al,%r8b
mov    -0x18(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0xff,%eax
lea    0xe94(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %al,%r9d
call   1030 <diag_sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_ntoa_r>:
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ecx
mov    %edi,%esi
shr    $0x10,%esi
mov    %edi,%eax
shr    $0x18,%eax
movzbl %cl,%edx
movzbl %ch,%ecx
movzbl %sil,%r8d
lea    0xecf(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%r9d
call   1030 <diag_sprintf@plt>
mov    %rbx,%rax
pop    %rbx
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) {
%3 = alloca %struct.in_addr
%4 = alloca i8*
%5 = alloca i8*
%6 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
store i32 %0, i32* %6
store i8* %1, i8** %4
%7 = bitcast %struct.in_addr* %3 to i8*
store i8* %7, i8** %5
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = and i32 %12, 255
%14 = trunc i32 %13 to i8
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = and i32 %18, 255
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 2
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = and i32 %24, 255
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 3
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = and i32 %30, 255
%32 = trunc i32 %31 to i8
%33 = call i32 @diag_sprintf(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 zeroext %14, i8 zeroext %20, i8 zeroext %26, i8 zeroext %32)
%34 = load i8*, i8** %4
ret i8* %34
}

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