#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*/ sprintf(char *, char *, char const, char const, char const,
                           char const);
char *strcpy(char *, char *);
char *inet_ntop4(const char *src, char *dst) {
  char tmp[sizeof "255.255.255.255"];
  sprintf(tmp, "%u.%u.%u.%u", src[0], src[1], src[2], src[3]);
  return strcpy(dst, tmp);
}


x86 assembly (clang, -O0):
<inet_ntop4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%dl
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%r8b
mov    -0x8(%rbp),%rax
lea    0xeac(%rip),%rsi
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl 0x3(%rax),%r9d
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_ntop4>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movsbl (%rdi),%edx
movsbl 0x1(%rdi),%ecx
movsbl 0x2(%rdi),%r8d
movsbl 0x3(%rdi),%r9d
lea    0xebe(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i8* @inet_ntop4(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [16 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%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 @sprintf(i8* %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 signext %9, i8 signext %12, i8 signext %15, i8 signext %18)
%20 = load i8*, i8** %4
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%22 = call i8* @strcpy(i8* %20, i8* %21)
ret i8* %22
}

LLVM IR (-O2):
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i8* @inet_ntop4(i8* nocapture %0, i8* returned %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = load i8, i8* %0
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = getelementptr inbounds i8, i8* %0, i64 2
%9 = load i8, i8* %8
%10 = getelementptr inbounds i8, i8* %0, i64 3
%11 = load i8, i8* %10
%12 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 signext %5, i8 signext %7, i8 signext %9, i8 signext %11)
%13 = call i8* @strcpy(i8* dereferenceable(1) %1, i8* %4)
ret i8* %1
}