#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 ai_socktype;
  int ai_flags;
  int /*<<< orphan*/ ai_family;
};
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
struct addrinfo init_hints(int sock_type, int flags) {
  struct addrinfo hints;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = sock_type;
  if (flags)
    hints.ai_flags = flags;
  return hints;
}


x86 assembly (clang, -O0):
<init_hints>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1030 <memset@plt>
mov    0x2eb3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1150 <init_hints+0x40>
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%edx
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_hints>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1030 <memset@plt>
mov    0x2eb6(%rip),%rax
mov    (%rax),%edx
mov    %edx,0x10(%rsp)
mov    %ebp,0x8(%rsp)
test   %ebx,%ebx
je     1144 <init_hints+0x34>
mov    %ebx,0xc(%rsp)
mov    0x8(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32 }
@AF_UNSPEC = global i32 0
define { i64, i32 } @init_hints(i32 %0, i32 %1) {
%3 = alloca %struct.addrinfo
%4 = alloca i32
%5 = alloca i32
%6 = alloca { i64, i32 }
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 12)
%8 = load i32, i32* @AF_UNSPEC
%9 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i32 0, i32 2
store i32 %8, i32* %9
%10 = load i32, i32* %4
%11 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i32 0, i32 0
store i32 %10, i32* %11
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* %5
%16 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i32 0, i32 1
store i32 %15, i32* %16
br label %17
17: ; preds = %14, %2
%18 = bitcast { i64, i32 }* %6 to i8*
%19 = bitcast %struct.addrinfo* %3 to i8*
%20 = load { i64, i32 }, { i64, i32 }* %6
ret { i64, i32 } %20
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32 }
@AF_UNSPEC = global i32 0
define { i64, i32 } @init_hints(i32 %0, i32 %1) {
%3 = alloca %struct.addrinfo
%4 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 12)
%5 = load i32, i32* @AF_UNSPEC
%6 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 2
store i32 %5, i32* %6
%7 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 0
store i32 %0, i32* %7
%8 = icmp eq i32 %1, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 1
store i32 %1, i32* %10
br label %11
11: ; preds = %9, %2
%12 = bitcast %struct.addrinfo* %3 to i64*
%13 = load i64, i64* %12
%14 = insertvalue { i64, i32 } poison, i64 %13, 0
%15 = insertvalue { i64, i32 } %14, i32 %5, 1
ret { i64, i32 } %15
}