#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 sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};

/* Variables and functions */
char *allocateString(char *, char, char, char, char);
char *ipv4ToString(const struct sockaddr_in *address) {
  return allocateString("%u.%u.%u.%u", ((char *)&address->sin_addr)[0],
                        ((char *)&address->sin_addr)[1],
                        ((char *)&address->sin_addr)[2],
                        ((char *)&address->sin_addr)[3]);
}


x86 assembly (clang, -O0):
<ipv4ToString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%sil
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%dl
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%cl
mov    -0x8(%rbp),%rax
lea    0xec4(%rip),%rdi
movsbl %sil,%esi
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl 0x3(%rax),%r8d
call   1030 <allocateString@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipv4ToString>:
movsbl (%rdi),%esi
movsbl 0x1(%rdi),%edx
movsbl 0x2(%rdi),%ecx
movsbl 0x3(%rdi),%r8d
lea    0xed9(%rip),%rdi
jmp    1030 <allocateString@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i8* @ipv4ToString(%struct.sockaddr_in* %0) {
%2 = alloca %struct.sockaddr_in*
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %2
%3 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%4 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%5 = bitcast i32* %4 to i8*
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%10 = bitcast i32* %9 to i8*
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %11
%13 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 0
%15 = bitcast i32* %14 to i8*
%16 = getelementptr inbounds i8, i8* %15, i64 2
%17 = load i8, i8* %16
%18 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 0
%20 = bitcast i32* %19 to i8*
%21 = getelementptr inbounds i8, i8* %20, i64 3
%22 = load i8, i8* %21
%23 = call i8* @allocateString(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 signext %7, i8 signext %12, i8 signext %17, i8 signext %22)
ret i8* %23
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i8* @ipv4ToString(%struct.sockaddr_in* nocapture %0) {
%2 = bitcast %struct.sockaddr_in* %0 to i8*
%3 = load i8, i8* %2
%4 = getelementptr inbounds i8, i8* %2, i64 1
%5 = load i8, i8* %4
%6 = getelementptr inbounds i8, i8* %2, i64 2
%7 = load i8, i8* %6
%8 = getelementptr inbounds i8, i8* %2, i64 3
%9 = load i8, i8* %8
%10 = tail call i8* @allocateString(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 signext %3, i8 signext %5, i8 signext %7, i8 signext %9)
ret i8* %10
}