#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ s_addr;
};
struct sockaddr_in {
  void *sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ bind(int, struct sockaddr_in *, int);
void *htons(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  struct sockaddr_in addr;
  int s1, s2;
  s1 = socket(AF_INET, SOCK_STREAM, 0);
  addr.sin_family = AF_INET;
  addr.sin_port = htons(700);
  addr.sin_addr.s_addr = 0;
  bind(s1, &addr, sizeof(addr));
  s2 = socket(AF_INET, SOCK_STREAM, 0);
  bind(s2, &addr, sizeof(addr));
  addr.sin_port = htons(701);
  bind(s2, &addr, sizeof(addr));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0x2bc,%edi
call   1030 <htons@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x18,%edx
call   1040 <bind@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x18,%edx
call   1040 <bind@plt>
mov    $0x2bd,%edi
call   1030 <htons@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x18,%edx
call   1040 <bind@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2ea7(%rip),%rbx
mov    (%rbx),%edi
mov    0x2e8e(%rip),%r15
mov    (%r15),%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    %eax,%ebp
mov    (%rbx),%eax
mov    %eax,0x10(%rsp)
mov    $0x2bc,%edi
call   1030 <htons@plt>
mov    %rax,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%r14
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x18,%edx
call   1040 <bind@plt>
mov    (%rbx),%edi
mov    (%r15),%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x18,%edx
call   1040 <bind@plt>
mov    $0x2bd,%edi
call   1030 <htons@plt>
mov    %rax,(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x18,%edx
call   1040 <bind@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca i32
%3 = alloca i32
%4 = load i32, i32* @AF_INET
%5 = load i32, i32* @SOCK_STREAM
%6 = call i32 @socket(i32 %4, i32 %5, i32 0)
store i32 %6, i32* %2
%7 = load i32, i32* @AF_INET
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 2
store i32 %7, i32* %8
%9 = call i8* @htons(i32 700)
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 0
store i8* %9, i8** %10
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 1
%12 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 0
store i64 0, i64* %12
%13 = load i32, i32* %2
%14 = call i32 @bind(i32 %13, %struct.sockaddr_in* %1, i32 24)
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = call i32 @socket(i32 %15, i32 %16, i32 0)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = call i32 @bind(i32 %18, %struct.sockaddr_in* %1, i32 24)
%20 = call i8* @htons(i32 701)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i32 0, i32 0
store i8* %20, i8** %21
%22 = load i32, i32* %3
%23 = call i32 @bind(i32 %22, %struct.sockaddr_in* %1, i32 24)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = bitcast %struct.sockaddr_in* %1 to i8*
%3 = load i32, i32* @AF_INET
%4 = load i32, i32* @SOCK_STREAM
%5 = tail call i32 @socket(i32 %3, i32 %4, i32 0)
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %6, i32* %7
%8 = tail call i8* @htons(i32 700)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i8* %8, i8** %9
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i64 0, i64* %10
%11 = call i32 @bind(i32 %5, %struct.sockaddr_in* %1, i32 24)
%12 = load i32, i32* @AF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = call i32 @socket(i32 %12, i32 %13, i32 0)
%15 = call i32 @bind(i32 %14, %struct.sockaddr_in* %1, i32 24)
%16 = call i8* @htons(i32 701)
store i8* %16, i8** %9
%17 = call i32 @bind(i32 %14, %struct.sockaddr_in* %1, i32 24)
ret i32 0
}