#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, int, int, int,
                           int);
char *make_ipv6_readable(char *readable_addr, char *addr) {
  sprintf(readable_addr, "%x:%x:%x:%x:%x:%x:%x:%x",
          parse_number_from_char(&addr[0], 0, 15),
          parse_number_from_char(&addr[2], 0, 15),
          parse_number_from_char(&addr[4], 0, 15),
          parse_number_from_char(&addr[6], 0, 15),
          parse_number_from_char(&addr[8], 0, 15),
          parse_number_from_char(&addr[10], 0, 15),
          parse_number_from_char(&addr[12], 0, 15),
          parse_number_from_char(&addr[14], 0, 15));
  return readable_addr;
}


x86 assembly (clang, -O0):
<make_ipv6_readable>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x2,%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x6,%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x8,%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,%ebx
mov    -0x18(%rbp),%rdi
add    $0xa,%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
add    $0xc,%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
add    $0xe,%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x24(%rbp),%r9d
mov    -0x20(%rbp),%r11d
mov    -0x1c(%rbp),%r10d
lea    0xdf6(%rip),%rsi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_ipv6_readable>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    %rdi,0x10(%rsp)
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,0xc(%rsp)
lea    0x2(%rbp),%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,0x8(%rsp)
lea    0x4(%rbp),%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,%r13d
lea    0x6(%rbp),%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,%r14d
lea    0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,%ebx
lea    0xa(%rbp),%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,%r15d
lea    0xc(%rbp),%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
mov    %eax,%r12d
add    $0xe,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xf,%edx
call   1030 <parse_number_from_char@plt>
lea    0xe2b(%rip),%rsi
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    %r13d,%r8d
mov    %r14d,%r9d
push   %rax
push   %r12
push   %r15
push   %rbx
call   1040 <sprintf@plt>
add    $0x20,%rsp
mov    %rbp,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"%x:%x:%x:%x:%x:%x:%x:%x\00"
define i8* @make_ipv6_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 15)
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 2
%11 = call i32 @parse_number_from_char(i8* %10, i32 0, i32 15)
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 4
%14 = call i32 @parse_number_from_char(i8* %13, i32 0, i32 15)
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 6
%17 = call i32 @parse_number_from_char(i8* %16, i32 0, i32 15)
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 8
%20 = call i32 @parse_number_from_char(i8* %19, i32 0, i32 15)
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 10
%23 = call i32 @parse_number_from_char(i8* %22, i32 0, i32 15)
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i64 12
%26 = call i32 @parse_number_from_char(i8* %25, i32 0, i32 15)
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 14
%29 = call i32 @parse_number_from_char(i8* %28, i32 0, i32 15)
%30 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11, i32 %14, i32 %17, i32 %20, i32 %23, i32 %26, i32 %29)
%31 = load i8*, i8** %3
ret i8* %31
}

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