#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 in_addr {
  scalar_t__ s_addr;
};
struct in6_addr {
  scalar_t__ *s6_addr32;
};

/* Variables and functions */
scalar_t__ htonl(int);
void map_v4_to_v6(struct in_addr *ip4, struct in6_addr *ip6) {
  ip6->s6_addr32[0] = 0;
  ip6->s6_addr32[1] = 0;
  ip6->s6_addr32[2] = htonl(0xffff);
  ip6->s6_addr32[3] = ip4->s_addr;
}


x86 assembly (clang, -O0):
<map_v4_to_v6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movq   $0x0,0x8(%rax)
mov    $0xffff,%edi
call   1030 <htonl@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rcx,0x10(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rcx,0x18(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<map_v4_to_v6>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%rax
xorps  %xmm0,%xmm0
movups %xmm0,(%rax)
mov    $0xffff,%edi
call   1030 <htonl@plt>
mov    (%rbx),%rcx
mov    %rax,0x10(%rcx)
mov    (%r14),%rax
mov    %rax,0x18(%rcx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.in_addr = type { i64 }
%struct.in6_addr = type { i64* }
define void @map_v4_to_v6(%struct.in_addr* %0, %struct.in6_addr* %1) {
%3 = alloca %struct.in_addr*
%4 = alloca %struct.in6_addr*
store %struct.in_addr* %0, %struct.in_addr** %3
store %struct.in6_addr* %1, %struct.in6_addr** %4
%5 = load %struct.in6_addr*, %struct.in6_addr** %4
%6 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %5, i32 0, i32 0
%7 = load i64*, i64** %6
%8 = getelementptr inbounds i64, i64* %7, i64 0
store i64 0, i64* %8
%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 i64*, i64** %10
%12 = getelementptr inbounds i64, i64* %11, i64 1
store i64 0, i64* %12
%13 = call i64 @htonl(i32 65535)
%14 = load %struct.in6_addr*, %struct.in6_addr** %4
%15 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %14, i32 0, i32 0
%16 = load i64*, i64** %15
%17 = getelementptr inbounds i64, i64* %16, i64 2
store i64 %13, i64* %17
%18 = load %struct.in_addr*, %struct.in_addr** %3
%19 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %18, i32 0, i32 0
%20 = load i64, i64* %19
%21 = load %struct.in6_addr*, %struct.in6_addr** %4
%22 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %21, i32 0, i32 0
%23 = load i64*, i64** %22
%24 = getelementptr inbounds i64, i64* %23, i64 3
store i64 %20, i64* %24
ret void
}

LLVM IR (-O2):
%struct.in_addr = type { i64 }
%struct.in6_addr = type { i64* }
define void @map_v4_to_v6(%struct.in_addr* nocapture %0, %struct.in6_addr* nocapture %1) {
%3 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %1, i64 0, i32 0
%4 = bitcast %struct.in6_addr* %1 to i8**
%5 = load i8*, i8** %4
%6 = tail call i64 @htonl(i32 65535)
%7 = load i64*, i64** %3
%8 = getelementptr inbounds i64, i64* %7, i64 2
store i64 %6, i64* %8
%9 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %0, i64 0, i32 0
%10 = load i64, i64* %9
%11 = getelementptr inbounds i64, i64* %7, i64 3
store i64 %10, i64* %11
ret void
}