#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_in {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_pton(int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ nslkup(char const *);
struct sockaddr_in NewTCPAddr(const char *host, int port) {
  struct sockaddr_in server;
  memset(&server, 0, sizeof(struct sockaddr_in));
  server.sin_family = AF_INET;
  server.sin_port = htons(port);
  inet_pton(AF_INET, nslkup(host), &(server.sin_addr));
  return server;
}


x86 assembly (clang, -O0):
<NewTCPAddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
lea    -0x10(%rbp),%rdi
mov    %rdi,-0x38(%rbp)
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e7e(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,-0xc(%rbp)
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <nslkup@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    %eax,%esi
call   1060 <inet_pton@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%edx
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NewTCPAddr>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e7d(%rip),%r12
mov    (%r12),%eax
mov    %eax,0x10(%rsp)
mov    %ebx,%edi
call   1030 <htons@plt>
mov    %eax,0xc(%rsp)
mov    (%r12),%ebx
mov    %r14,%rdi
call   1050 <nslkup@plt>
mov    %ebx,%edi
mov    %eax,%esi
mov    %r15,%rdx
call   1060 <inet_pton@plt>
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%edx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
@AF_INET = global i32 0
define { i64, i32 } @NewTCPAddr(i8* %0, i32 %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i8*
%5 = alloca i32
%6 = alloca { i64, i32 }
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%8 = load i32, i32* @AF_INET
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 2
store i32 %8, i32* %9
%10 = load i32, i32* %5
%11 = call i32 @htons(i32 %10)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
store i32 %11, i32* %12
%13 = load i32, i32* @AF_INET
%14 = load i8*, i8** %4
%15 = call i32 @nslkup(i8* %14)
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%17 = call i32 @inet_pton(i32 %13, i32 %15, i32* %16)
%18 = bitcast { i64, i32 }* %6 to i8*
%19 = bitcast %struct.sockaddr_in* %3 to i8*
%20 = load { i64, i32 }, { i64, i32 }* %6
ret { i64, i32 } %20
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
@AF_INET = global i32 0
define { i64, i32 } @NewTCPAddr(i8* %0, i32 %1) {
%3 = alloca %struct.sockaddr_in
%4 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%5 = load i32, i32* @AF_INET
%6 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %5, i32* %6
%7 = call i32 @htons(i32 %1)
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %7, i32* %8
%9 = load i32, i32* @AF_INET
%10 = call i32 @nslkup(i8* %0)
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%12 = call i32 @inet_pton(i32 %9, i32 %10, i32* %11)
%13 = bitcast %struct.sockaddr_in* %3 to i64*
%14 = load i64, i64* %13
%15 = load i32, i32* %6
%16 = insertvalue { i64, i32 } poison, i64 %14, 0
%17 = insertvalue { i64, i32 } %16, i32 %15, 1
ret { i64, i32 } %17
}