#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 */
typedef int /*<<< orphan*/ v4address;
typedef int /*<<< orphan*/ uint32_t;
typedef int uint16_t;
struct in6_addr {
  int /*<<< orphan*/ *s6_addr;
};

/* Variables and functions */
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ memset(struct in6_addr *, int /*<<< orphan*/, int);
void MapIPv4ToIPv6(uint32_t v4address, struct in6_addr *v6address) {
  memset(v6address, 0, sizeof(struct in6_addr));
  v4address = htonl(v4address);
  ((uint16_t *)v6address->s6_addr)[5] = 0xFFFF;
  memcpy(&v6address->s6_addr[12], &v4address, sizeof(v4address));
}


x86 assembly (clang, -O0):
<MapIPv4ToIPv6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    -0x4(%rbp),%edi
call   1030 <htonl@plt>
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0xffff,0x14(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
add    $0x30,%rdi
lea    -0x4(%rbp),%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MapIPv4ToIPv6>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    %ebp,%edi
call   1030 <htonl@plt>
mov    %eax,0x4(%rsp)
mov    (%rbx),%rdi
movl   $0xffff,0x14(%rdi)
add    $0x30,%rdi
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.in6_addr = type { i32* }
define void @MapIPv4ToIPv6(i32 %0, %struct.in6_addr* %1) {
%3 = alloca i32
%4 = alloca %struct.in6_addr*
store i32 %0, i32* %3
store %struct.in6_addr* %1, %struct.in6_addr** %4
%5 = load %struct.in6_addr*, %struct.in6_addr** %4
%6 = call i32 @memset(%struct.in6_addr* %5, i32 0, i32 8)
%7 = load i32, i32* %3
%8 = call i32 @htonl(i32 %7)
store i32 %8, i32* %3
%9 = load %struct.in6_addr*, %struct.in6_addr** %4
%10 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %9, i32 0, i32 0
%11 = load i32*, i32** %10
%12 = getelementptr inbounds i32, i32* %11, i64 5
store i32 65535, i32* %12
%13 = load %struct.in6_addr*, %struct.in6_addr** %4
%14 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %13, i32 0, i32 0
%15 = load i32*, i32** %14
%16 = getelementptr inbounds i32, i32* %15, i64 12
%17 = call i32 @memcpy(i32* %16, i32* %3, i32 4)
ret void
}

LLVM IR (-O2):
%struct.in6_addr = type { i32* }
define void @MapIPv4ToIPv6(i32 %0, %struct.in6_addr* %1) {
%3 = alloca i32
%4 = tail call i32 @memset(%struct.in6_addr* %1, i32 0, i32 8)
%5 = tail call i32 @htonl(i32 %0)
store i32 %5, i32* %3
%6 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %1, i64 0, i32 0
%7 = load i32*, i32** %6
%8 = getelementptr inbounds i32, i32* %7, i64 5
store i32 65535, i32* %8
%9 = getelementptr inbounds i32, i32* %7, i64 12
%10 = call i32 @memcpy(i32* %9, i32* %3, i32 4)
ret void
}