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

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/ *, char *,
                             int);
int /*<<< orphan*/ inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
void ip6() {
  struct sockaddr_in6 sa6;
  inet_pton(AF_INET6, "2001:db8:63b3:1::3490", &(sa6.sin6_addr));
  char ip6[INET6_ADDRSTRLEN];
  inet_ntop(AF_INET6, &(sa6.sin6_addr), ip6, INET6_ADDRSTRLEN);
  printf("round-tripped ip6: %s\n", ip6);
}


x86 assembly (clang, -O0):
<ip6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
lea    0xeb8(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <inet_pton@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x18(%rbp)
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
mov    0x2e57(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
mov    -0x20(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ip6>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x2e9a(%rip),%r15
mov    (%r15),%edi
lea    0xeb0(%rip),%rsi
lea    -0x28(%rbp),%r14
mov    %r14,%rdx
call   1050 <inet_pton@plt>
mov    %rsp,%r12
mov    0x2e82(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rbx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
mov    (%r15),%edi
mov    (%rax),%ecx
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <inet_ntop@plt>
lea    0xe86(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r12,%rsp
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i32 }
@AF_INET6 = global i32 0
@.str = [22 x i8] c"2001:db8:63b3:1::3490\00"
@INET6_ADDRSTRLEN = global i32 0
@.str.1 = [23 x i8] c"round-tripped ip6: %s\0A\00"
define void @ip6() {
%1 = alloca %struct.sockaddr_in6
%2 = alloca i8*
%3 = alloca i64
%4 = load i32, i32* @AF_INET6
%5 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %1, i32 0, i32 0
%6 = call i32 @inet_pton(i32 %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32* %5)
%7 = load i32, i32* @INET6_ADDRSTRLEN
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %2
%10 = alloca i8, i64 %8
store i64 %8, i64* %3
%11 = load i32, i32* @AF_INET6
%12 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %1, i32 0, i32 0
%13 = load i32, i32* @INET6_ADDRSTRLEN
%14 = call i32 @inet_ntop(i32 %11, i32* %12, i8* %10, i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%16 = load i8*, i8** %2
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i32 }
@AF_INET6 = global i32 0
@.str = [22 x i8] c"2001:db8:63b3:1::3490\00"
@INET6_ADDRSTRLEN = global i32 0
@.str.1 = [23 x i8] c"round-tripped ip6: %s\0A\00"
define void @ip6() {
%1 = alloca %struct.sockaddr_in6
%2 = bitcast %struct.sockaddr_in6* %1 to i8*
%3 = load i32, i32* @AF_INET6
%4 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %1, i64 0, i32 0
%5 = call i32 @inet_pton(i32 %3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32* %4)
%6 = load i32, i32* @INET6_ADDRSTRLEN
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
%9 = alloca i8, i64 %7
%10 = load i32, i32* @AF_INET6
%11 = load i32, i32* @INET6_ADDRSTRLEN
%12 = call i32 @inet_ntop(i32 %10, i32* %4, i8* %9, i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %9)
ret void
}