#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 AF_INET6;
int w_bind_local4(int, unsigned short);
int w_bind_local6(int, unsigned short);
int w_bind_local(int sockfd, int domain, unsigned short port) {
  if (domain == AF_INET) {
    return w_bind_local4(sockfd, port);
  } else if (domain == AF_INET6) {
    return w_bind_local6(sockfd, port);
  }
  return -1;
}


x86 assembly (clang, -O0):
<w_bind_local>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dx,%ax
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %ax,-0xe(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2ea9(%rip),%rcx
cmp    (%rcx),%eax
jne    115b <w_bind_local+0x3b>
mov    -0x8(%rbp),%edi
movzwl -0xe(%rbp),%esi
call   1040 <w_bind_local4@plt>
mov    %eax,-0x4(%rbp)
jmp    118d <w_bind_local+0x6d>
mov    -0xc(%rbp),%eax
mov    0x2e7b(%rip),%rcx
cmp    (%rcx),%eax
jne    1181 <w_bind_local+0x61>
mov    -0x8(%rbp),%edi
movzwl -0xe(%rbp),%esi
call   1030 <w_bind_local6@plt>
mov    %eax,-0x4(%rbp)
jmp    118d <w_bind_local+0x6d>
jmp    1186 <w_bind_local+0x66>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<w_bind_local>:
mov    0x2ec1(%rip),%rax
cmp    %esi,(%rax)
jne    1133 <w_bind_local+0x13>
movzwl %dx,%esi
jmp    1040 <w_bind_local4@plt>
mov    0x2ea6(%rip),%rax
cmp    %esi,(%rax)
jne    1146 <w_bind_local+0x26>
movzwl %dx,%esi
jmp    1030 <w_bind_local6@plt>
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@AF_INET = global i32 0
@AF_INET6 = global i32 0
define i32 @w_bind_local(i32 %0, i32 %1, i16 zeroext %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i16
store i32 %0, i32* %5
store i32 %1, i32* %6
store i16 %2, i16* %7
%8 = load i32, i32* %6
%9 = load i32, i32* @AF_INET
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i32, i32* %5
%13 = load i16, i16* %7
%14 = call i32 @w_bind_local4(i32 %12, i16 zeroext %13)
store i32 %14, i32* %4
br label %25
15: ; preds = %3
%16 = load i32, i32* %6
%17 = load i32, i32* @AF_INET6
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i32, i32* %5
%21 = load i16, i16* %7
%22 = call i32 @w_bind_local6(i32 %20, i16 zeroext %21)
store i32 %22, i32* %4
br label %25
23: ; preds = %15
br label %24
24: ; preds = %23
store i32 -1, i32* %4
br label %25
25: ; preds = %24, %19, %11
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
@AF_INET = global i32 0
@AF_INET6 = global i32 0
define i32 @w_bind_local(i32 %0, i32 %1, i16 zeroext %2) {
%4 = load i32, i32* @AF_INET
%5 = icmp eq i32 %4, %1
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @w_bind_local4(i32 %0, i16 zeroext %2)
br label %13
8: ; preds = %3
%9 = load i32, i32* @AF_INET6
%10 = icmp eq i32 %9, %1
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @w_bind_local6(i32 %0, i16 zeroext %2)
br label %13
13: ; preds = %8, %11, %6
%14 = phi i32 [ %7, %6 ], [ %12, %11 ], [ -1, %8 ]
ret i32 %14
}