#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct sockaddr_in6 {
  int /*<<< orphan*/ sin6_addr;
  void *sin6_port;
  int /*<<< orphan*/ sin6_family;
  int /*<<< orphan*/ member_0;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  void *sin_port;
  int /*<<< orphan*/ sin_family;
  int /*<<< orphan*/ member_0;
};
typedef int /*<<< orphan*/ addr6;
typedef int /*<<< orphan*/ addr4;

/* Variables and functions */
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ PF_INET6;
int /*<<< orphan*/ do_main(void *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
void *htons(int);
int /*<<< orphan*/ in6addr_any;
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  struct sockaddr_in addr4 = {0};
  struct sockaddr_in6 addr6 = {0};
  fprintf(stderr, "PF_INET\n");
  addr4.sin_family = PF_INET;
  addr4.sin_port = htons(8000);
  addr4.sin_addr.s_addr = htonl(INADDR_ANY);
  do_main((void *)&addr4, sizeof(addr4));
  fprintf(stderr, "PF_INET6\n");
  addr6.sin6_family = PF_INET6;
  addr6.sin6_port = htons(8000);
  addr6.sin6_addr = in6addr_any;
  do_main((void *)&addr6, sizeof(addr6));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    $0x1f40,%edi
call   1030 <htons@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,-0x28(%rbp)
lea    -0x28(%rbp),%rdi
mov    $0x18,%esi
call   1070 <do_main@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    $0x1f40,%edi
call   1030 <htons@plt>
mov    %rax,-0x38(%rbp)
mov    0x2de6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x18,%esi
call   1070 <do_main@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x30(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2e5e(%rip),%rbx
mov    (%rbx),%edi
lea    0xe8d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
mov    $0x1f40,%edi
call   1030 <htons@plt>
mov    %rax,0x28(%rsp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,0x20(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x18,%esi
call   1060 <do_main@plt>
mov    (%rbx),%edi
lea    0xe4b(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    $0x1f40,%edi
call   1030 <htons@plt>
mov    %rax,0x8(%rsp)
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    %rsp,%rdi
mov    $0x18,%esi
call   1060 <do_main@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr_in6 = type { i32, i8*, i32, i32 }
@stderr = global i32 0
@.str = [9 x i8] c"PF_INET\0A\00"
@PF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str.1 = [10 x i8] c"PF_INET6\0A\00"
@PF_INET6 = global i32 0
@in6addr_any = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.sockaddr_in6
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast %struct.sockaddr_in* %6 to i8*
%9 = bitcast %struct.sockaddr_in6* %7 to i8*
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @PF_INET
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i32 %12, i32* %13
%14 = call i8* @htons(i32 8000)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
store i8* %14, i8** %15
%16 = load i32, i32* @INADDR_ANY
%17 = call i32 @htonl(i32 %16)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %18, i32 0, i32 0
store i32 %17, i32* %19
%20 = bitcast %struct.sockaddr_in* %6 to i8*
%21 = call i32 @do_main(i8* %20, i32 24)
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @PF_INET6
%25 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %7, i32 0, i32 2
store i32 %24, i32* %25
%26 = call i8* @htons(i32 8000)
%27 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %7, i32 0, i32 1
store i8* %26, i8** %27
%28 = load i32, i32* @in6addr_any
%29 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %7, i32 0, i32 0
store i32 %28, i32* %29
%30 = bitcast %struct.sockaddr_in6* %7 to i8*
%31 = call i32 @do_main(i8* %30, i32 24)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr_in6 = type { i32, i8*, i32, i32 }
@stderr = global i32 0
@.str = [9 x i8] c"PF_INET\0A\00"
@PF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str.1 = [10 x i8] c"PF_INET6\0A\00"
@PF_INET6 = global i32 0
@in6addr_any = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in6
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = bitcast %struct.sockaddr_in6* %4 to i8*
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @PF_INET
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %9, i32* %10
%11 = tail call i8* @htons(i32 8000)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i8* %11, i8** %12
%13 = load i32, i32* @INADDR_ANY
%14 = tail call i32 @htonl(i32 %13)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %14, i32* %15
%16 = call i32 @do_main(i8* %5, i32 24)
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @PF_INET6
%20 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i64 0, i32 2
store i32 %19, i32* %20
%21 = call i8* @htons(i32 8000)
%22 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i64 0, i32 1
store i8* %21, i8** %22
%23 = load i32, i32* @in6addr_any
%24 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i64 0, i32 0
store i32 %23, i32* %24
%25 = call i32 @do_main(i8* %6, i32 24)
ret i32 0
}