#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_storage {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct rtpp_bindaddrs {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AI_PASSIVE;
struct sockaddr *addr2bindaddr(struct rtpp_bindaddrs *, struct sockaddr *,
                               char const **);
char *gai_strerror(int);
int resolve(struct sockaddr *, int, char const *, char *, int /*<<< orphan*/);
scalar_t__ strcmp(char const *, char *);
const struct sockaddr *host2bindaddr(struct rtpp_bindaddrs *pub,
                                     const char *host, int pf,
                                     const char **ep) {
  int n;
  struct sockaddr_storage ia;
  const struct sockaddr *rval;
  if (host && (strcmp(host, "*") == 0))
    host = NULL;
  if ((n = resolve(((struct sockaddr *)(&ia)), pf, host, "34999",
                   AI_PASSIVE)) != 0) {
    *ep = gai_strerror(n);
    return (NULL);
  }
  rval = addr2bindaddr(pub, ((struct sockaddr *)(&ia)), ep);
  return (rval);
}


x86 assembly (clang, -O0):
<host2bindaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1184 <host2bindaddr+0x44>
mov    -0x18(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1184 <host2bindaddr+0x44>
movq   $0x0,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    0x2e52(%rip),%rax
mov    (%rax),%r8d
lea    0xe62(%rip),%rcx
call   1040 <resolve@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
je     11d0 <host2bindaddr+0x90>
mov    -0x2c(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    11ed <host2bindaddr+0xad>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <addr2bindaddr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<host2bindaddr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %edx,%ebp
mov    %rdi,%r14
test   %rsi,%rsi
je     116f <host2bindaddr+0x2f>
mov    %rsi,%rbx
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
cmove  %rax,%rbx
jmp    1171 <host2bindaddr+0x31>
xor    %ebx,%ebx
mov    0x2e70(%rip),%rax
mov    (%rax),%r8d
lea    0xe80(%rip),%rcx
mov    %rsp,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1040 <resolve@plt>
test   %eax,%eax
je     11a1 <host2bindaddr+0x61>
mov    %eax,%edi
call   1050 <gai_strerror@plt>
mov    %rax,(%r15)
xor    %eax,%eax
jmp    11af <host2bindaddr+0x6f>
mov    %rsp,%rsi
mov    %r14,%rdi
mov    %r15,%rdx
call   1030 <addr2bindaddr@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
%struct.rtpp_bindaddrs = type { i32 }
%struct.sockaddr_storage = type { i32 }
@.str = [2 x i8] c"*\00"
@.str.1 = [6 x i8] c"34999\00"
@AI_PASSIVE = global i32 0
define %struct.sockaddr* @host2bindaddr(%struct.rtpp_bindaddrs* %0, i8* %1, i32 %2, i8** %3) {
%5 = alloca %struct.sockaddr*
%6 = alloca %struct.rtpp_bindaddrs*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
%11 = alloca %struct.sockaddr_storage
%12 = alloca %struct.sockaddr*
store %struct.rtpp_bindaddrs* %0, %struct.rtpp_bindaddrs** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8** %3, i8*** %9
%13 = load i8*, i8** %7
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %20
15: ; preds = %4
%16 = load i8*, i8** %7
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i8* null, i8** %7
br label %20
20: ; preds = %19, %15, %4
%21 = bitcast %struct.sockaddr_storage* %11 to %struct.sockaddr*
%22 = load i32, i32* %8
%23 = load i8*, i8** %7
%24 = load i32, i32* @AI_PASSIVE
%25 = call i32 @resolve(%struct.sockaddr* %21, i32 %22, i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %24)
store i32 %25, i32* %10
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %20
%28 = load i32, i32* %10
%29 = call i8* @gai_strerror(i32 %28)
%30 = load i8**, i8*** %9
store i8* %29, i8** %30
store %struct.sockaddr* null, %struct.sockaddr** %5
br label %37
31: ; preds = %20
%32 = load %struct.rtpp_bindaddrs*, %struct.rtpp_bindaddrs** %6
%33 = bitcast %struct.sockaddr_storage* %11 to %struct.sockaddr*
%34 = load i8**, i8*** %9
%35 = call %struct.sockaddr* @addr2bindaddr(%struct.rtpp_bindaddrs* %32, %struct.sockaddr* %33, i8** %34)
store %struct.sockaddr* %35, %struct.sockaddr** %12
%36 = load %struct.sockaddr*, %struct.sockaddr** %12
store %struct.sockaddr* %36, %struct.sockaddr** %5
br label %37
37: ; preds = %31, %27
%38 = load %struct.sockaddr*, %struct.sockaddr** %5
ret %struct.sockaddr* %38
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
%struct.rtpp_bindaddrs = type { i32 }
%struct.sockaddr_storage = type { i32 }
@.str = [2 x i8] c"*\00"
@.str.1 = [6 x i8] c"34999\00"
@AI_PASSIVE = global i32 0
define %struct.sockaddr* @host2bindaddr(%struct.rtpp_bindaddrs* %0, i8* %1, i32 %2, i8** %3) {
%5 = alloca %struct.sockaddr_storage
%6 = bitcast %struct.sockaddr_storage* %5 to i8*
%7 = icmp eq i8* %1, null
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* null, i8* %1
br label %12
12: ; preds = %8, %4
%13 = phi i8* [ null, %4 ], [ %11, %8 ]
%14 = bitcast %struct.sockaddr_storage* %5 to %struct.sockaddr*
%15 = load i32, i32* @AI_PASSIVE
%16 = call i32 @resolve(%struct.sockaddr* %14, i32 %2, i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %12
%19 = call i8* @gai_strerror(i32 %16)
store i8* %19, i8** %3
br label %22
20: ; preds = %12
%21 = call %struct.sockaddr* @addr2bindaddr(%struct.rtpp_bindaddrs* %0, %struct.sockaddr* %14, i8** %3)
br label %22
22: ; preds = %20, %18
%23 = phi %struct.sockaddr* [ null, %18 ], [ %21, %20 ]
ret %struct.sockaddr* %23
}