#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 parse_number_from_char(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int);
char *make_ipv4_readable(char *readable_addr, char *addr) {
  sprintf(readable_addr, "%u.%u.%u.%u", parse_number_from_char(&addr[0], 0, 7),
          parse_number_from_char(&addr[1], 0, 7),
          parse_number_from_char(&addr[2], 0, 7),
          parse_number_from_char(&addr[3], 0, 7));
  return readable_addr;
}


x86 assembly (clang, -O0):
<make_ipv4_readable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x3,%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1030 <parse_number_from_char@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    %eax,%r9d
lea    0xe5b(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_ipv4_readable>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,%r15d
lea    0x1(%rbx),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,%r12d
lea    0x2(%rbx),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,%ebp
add    $0x3,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1030 <parse_number_from_char@plt>
lea    0xe81(%rip),%rsi
mov    %r14,%rdi
mov    %r15d,%edx
mov    %r12d,%ecx
mov    %ebp,%r8d
mov    %eax,%r9d
call   1040 <sprintf@plt>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i8* @make_ipv4_readable(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = call i32 @parse_number_from_char(i8* %7, i32 0, i32 7)
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = call i32 @parse_number_from_char(i8* %10, i32 0, i32 7)
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 2
%14 = call i32 @parse_number_from_char(i8* %13, i32 0, i32 7)
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 3
%17 = call i32 @parse_number_from_char(i8* %16, i32 0, i32 7)
%18 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11, i32 %14, i32 %17)
%19 = load i8*, i8** %3
ret i8* %19
}

LLVM IR (-O2):
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i8* @make_ipv4_readable(i8* returned writeonly %0, i8* %1) {
%3 = tail call i32 @parse_number_from_char(i8* %1, i32 0, i32 7)
%4 = getelementptr inbounds i8, i8* %1, i64 1
%5 = tail call i32 @parse_number_from_char(i8* %4, i32 0, i32 7)
%6 = getelementptr inbounds i8, i8* %1, i64 2
%7 = tail call i32 @parse_number_from_char(i8* %6, i32 0, i32 7)
%8 = getelementptr inbounds i8, i8* %1, i64 3
%9 = tail call i32 @parse_number_from_char(i8* %8, i32 0, i32 7)
%10 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %5, i32 %7, i32 %9)
ret i8* %0
}