#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 */

/* Variables and functions */
int AF_INET;
int AI_NUMERICHOST;
int AI_NUMERICSERV;
int /*<<< orphan*/ resolve(char *, char *, int, int, int);
int main() {
  resolve("127.0.0.1", "80", 0, 0, AI_NUMERICHOST | AI_NUMERICSERV);
  resolve("localhost", "http", 0, 0, AI_NUMERICHOST | AI_NUMERICSERV);
  resolve("localhost", "http", 0, 0, 0);
  resolve("localhost", "http", AF_INET, 0, 0);
  resolve("ipv6.google.com", "https", 0, 0, 0);
  resolve("does.not.exist", "https", 0, 0, 0);
  resolve("does.not.exist", "xxx", -1, -1, -1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ebd(%rip),%rax
mov    (%rax),%r8d
mov    0x2ed3(%rip),%rax
or     (%rax),%r8d
lea    0xed1(%rip),%rdi
lea    0xed4(%rip),%rsi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <resolve@plt>
mov    0x2e92(%rip),%rax
mov    (%rax),%r8d
mov    0x2ea8(%rip),%rax
or     (%rax),%r8d
lea    0xeb3(%rip),%rdi
lea    0xeb6(%rip),%rsi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <resolve@plt>
lea    0xe9c(%rip),%rdi
lea    0xe9f(%rip),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1030 <resolve@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%edx
lea    0xe77(%rip),%rdi
lea    0xe7a(%rip),%rsi
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1030 <resolve@plt>
lea    0xe6d(%rip),%rdi
lea    0xe76(%rip),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1030 <resolve@plt>
lea    0xe67(%rip),%rdi
lea    0xe5a(%rip),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1030 <resolve@plt>
lea    0xe4b(%rip),%rdi
lea    0xe53(%rip),%rsi
mov    $0xffffffff,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1030 <resolve@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2ebd(%rip),%r14
mov    0x2ed6(%rip),%rbx
mov    (%rbx),%r8d
or     (%r14),%r8d
lea    0xed1(%rip),%rdi
lea    0xed4(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <resolve@plt>
mov    (%rbx),%r8d
or     (%r14),%r8d
lea    0xec1(%rip),%rbx
lea    0xec4(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <resolve@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <resolve@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <resolve@plt>
lea    0xe88(%rip),%rdi
lea    0xe91(%rip),%rbx
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <resolve@plt>
lea    0xe81(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <resolve@plt>
lea    0xe77(%rip),%rsi
mov    %r14,%rdi
mov    $0xffffffff,%edx
mov    $0xffffffff,%ecx
mov    $0xffffffff,%r8d
call   1030 <resolve@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [3 x i8] c"80\00"
@AI_NUMERICHOST = global i32 0
@AI_NUMERICSERV = global i32 0
@.str.2 = [10 x i8] c"localhost\00"
@.str.3 = [5 x i8] c"http\00"
@AF_INET = global i32 0
@.str.4 = [16 x i8] c"ipv6.google.com\00"
@.str.5 = [6 x i8] c"https\00"
@.str.6 = [15 x i8] c"does.not.exist\00"
@.str.7 = [4 x i8] c"xxx\00"
define i32 @main() {
%1 = load i32, i32* @AI_NUMERICHOST
%2 = load i32, i32* @AI_NUMERICSERV
%3 = or i32 %1, %2
%4 = call i32 @resolve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0, i32 %3)
%5 = load i32, i32* @AI_NUMERICHOST
%6 = load i32, i32* @AI_NUMERICSERV
%7 = or i32 %5, %6
%8 = call i32 @resolve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0, i32 %7)
%9 = call i32 @resolve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0, i32 0)
%10 = load i32, i32* @AF_INET
%11 = call i32 @resolve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %10, i32 0, i32 0)
%12 = call i32 @resolve(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 0, i32 0, i32 0)
%13 = call i32 @resolve(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 0, i32 0, i32 0)
%14 = call i32 @resolve(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 -1, i32 -1, i32 -1)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [3 x i8] c"80\00"
@AI_NUMERICHOST = global i32 0
@AI_NUMERICSERV = global i32 0
@.str.2 = [10 x i8] c"localhost\00"
@.str.3 = [5 x i8] c"http\00"
@AF_INET = global i32 0
@.str.4 = [16 x i8] c"ipv6.google.com\00"
@.str.5 = [6 x i8] c"https\00"
@.str.6 = [15 x i8] c"does.not.exist\00"
@.str.7 = [4 x i8] c"xxx\00"
define i32 @main() {
%1 = load i32, i32* @AI_NUMERICHOST
%2 = load i32, i32* @AI_NUMERICSERV
%3 = or i32 %2, %1
%4 = tail call i32 @resolve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0, i32 %3)
%5 = load i32, i32* @AI_NUMERICHOST
%6 = load i32, i32* @AI_NUMERICSERV
%7 = or i32 %6, %5
%8 = tail call i32 @resolve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0, i32 %7)
%9 = tail call i32 @resolve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0, i32 0)
%10 = load i32, i32* @AF_INET
%11 = tail call i32 @resolve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %10, i32 0, i32 0)
%12 = tail call i32 @resolve(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 0, i32 0, i32 0)
%13 = tail call i32 @resolve(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 0, i32 0, i32 0)
%14 = tail call i32 @resolve(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 -1, i32 -1, i32 -1)
ret i32 0
}