#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 dummy;
};
struct sockaddr_in {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ getnameinfo(struct sockaddr_in6 *, int, char *, int, char *,
                               int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  struct sockaddr_in6 sa;
  struct sockaddr_in sa_v4;
  char host[1024];
  char service[20];
  getnameinfo(&sa, sizeof sa, host, sizeof host, service, sizeof service, 0);
  printf("   host: %s\n", host);
  printf("service: %s\n", service);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x420(%rbp),%rdx
lea    -0x440(%rbp),%r8
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x400,%ecx
mov    $0x14,%r9d
xor    %eax,%eax
movl   $0x0,(%rsp)
call   1040 <getnameinfo@plt>
lea    -0x420(%rbp),%rsi
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
lea    -0x440(%rbp),%rsi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x438,%rsp
movl   $0x0,(%rsp)
lea    0x8(%rsp),%rdi
lea    0x30(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    $0x4,%esi
mov    %rbx,%rdx
mov    $0x400,%ecx
mov    %r14,%r8
mov    $0x14,%r9d
call   1040 <getnameinfo@plt>
lea    0xe9e(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i32 }
%struct.sockaddr_in = type { i32 }
@.str = [13 x i8] c" host: %s\0A\00"
@.str.1 = [13 x i8] c"service: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_in6
%7 = alloca %struct.sockaddr_in
%8 = alloca [1024 x i8]
%9 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%12 = call i32 @getnameinfo(%struct.sockaddr_in6* %6, i32 4, i8* %10, i32 1024, i8* %11, i32 20, i32 0)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %15)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i32 }
@.str = [13 x i8] c" host: %s\0A\00"
@.str.1 = [13 x i8] c"service: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in6
%4 = alloca [1024 x i8]
%5 = alloca [20 x i8]
%6 = bitcast %struct.sockaddr_in6* %3 to i8*
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%9 = call i32 @getnameinfo(%struct.sockaddr_in6* %3, i32 4, i8* %7, i32 1024, i8* %8, i32 20, i32 0)
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %7)
%11 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %8)
ret i32 0
}