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

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ getaddrinfo(char *, int /*<<< orphan*/ *, struct addrinfo *,
                               struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, char, int);
int /*<<< orphan*/ puts(char *);
int main(void) {
  struct addrinfo req, *ai;
  char name[] = "3ffe:0200:0064:0000:0202:b3ff:fe16:ddc5";
  memset(&req, '\0', sizeof req);
  req.ai_family = AF_INET6;
  getaddrinfo(name, NULL, &req, &ai);
  puts("success!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x8(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1060 <getaddrinfo@plt>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x356364643a3631,%rax
mov    %rax,0x30(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rcx
xor    %esi,%esi
mov    %rbx,%rdx
call   1050 <getaddrinfo@plt>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32 }
@__const.main.name = [40 x i8] c"3ffe:0200:0064:0000:0202:b3ff:fe16:ddc5\00"
@AF_INET6 = global i32 0
@.str = [9 x i8] c"success!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.addrinfo
%3 = alloca %struct.addrinfo*
%4 = alloca [40 x i8]
store i32 0, i32* %1
%5 = bitcast [40 x i8]* %4 to i8*
%6 = call i32 @memset(%struct.addrinfo* %2, i8 signext 0, i32 4)
%7 = load i32, i32* @AF_INET6
%8 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %2, i32 0, i32 0
store i32 %7, i32* %8
%9 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%10 = call i32 @getaddrinfo(i8* %9, i32* null, %struct.addrinfo* %2, %struct.addrinfo** %3)
%11 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.addrinfo = type { i32 }
@__const.main.name = [40 x i8] c"3ffe:0200:0064:0000:0202:b3ff:fe16:ddc5\00"
@AF_INET6 = global i32 0
@.str = [9 x i8] c"success!\00"
define i32 @main() {
%1 = alloca %struct.addrinfo
%2 = alloca %struct.addrinfo*
%3 = alloca [40 x i8]
%4 = bitcast %struct.addrinfo* %1 to i8*
%5 = bitcast %struct.addrinfo** %2 to i8*
%6 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%7 = call i32 @memset(%struct.addrinfo* %1, i8 signext 0, i32 4)
%8 = load i32, i32* @AF_INET6
%9 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %1, i64 0, i32 0
store i32 %8, i32* %9
%10 = call i32 @getaddrinfo(i8* %6, i32* null, %struct.addrinfo* %1, %struct.addrinfo** %2)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret i32 0
}