#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 /*<<< orphan*/ AF_INET;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(void) {
  int sock1, sock2;
  if ((sock1 = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
    return (EXIT_FAILURE);
  if ((sock2 = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
    return (EXIT_FAILURE);
  close(sock1);
  close(sock2);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%edi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
call   1040 <socket@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    116c <main+0x4c>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <main+0xa5>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
call   1040 <socket@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    11a9 <main+0x89>
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <main+0xa5>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    -0xc(%rbp),%edi
call   1030 <close@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2eb9(%rip),%r14
mov    (%r14),%edi
mov    0x2e97(%rip),%r15
mov    (%r15),%esi
mov    0x2e9d(%rip),%r12
mov    (%r12),%edx
call   1040 <socket@plt>
mov    0x2e75(%rip),%rbp
test   %eax,%eax
js     1185 <main+0x65>
mov    %eax,%ebx
mov    (%r14),%edi
mov    (%r15),%esi
mov    (%r12),%edx
call   1040 <socket@plt>
test   %eax,%eax
js     1185 <main+0x65>
mov    %eax,%r14d
mov    %ebx,%edi
call   1030 <close@plt>
mov    %r14d,%edi
call   1030 <close@plt>
mov    0x2e3b(%rip),%rbp
mov    0x0(%rbp),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @AF_INET
%5 = load i32, i32* @SOCK_STREAM
%6 = load i32, i32* @IPPROTO_TCP
%7 = call i32 @socket(i32 %4, i32 %5, i32 %6)
store i32 %7, i32* %2
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = load i32, i32* @EXIT_FAILURE
store i32 %10, i32* %1
br label %25
11: ; preds = %0
%12 = load i32, i32* @AF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = load i32, i32* @IPPROTO_TCP
%15 = call i32 @socket(i32 %12, i32 %13, i32 %14)
store i32 %15, i32* %3
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %1
br label %25
19: ; preds = %11
%20 = load i32, i32* %2
%21 = call i32 @close(i32 %20)
%22 = load i32, i32* %3
%23 = call i32 @close(i32 %22)
%24 = load i32, i32* @EXIT_SUCCESS
store i32 %24, i32* %1
br label %25
25: ; preds = %19, %17, %9
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = load i32, i32* @AF_INET
%2 = load i32, i32* @SOCK_STREAM
%3 = load i32, i32* @IPPROTO_TCP
%4 = tail call i32 @socket(i32 %1, i32 %2, i32 %3)
%5 = icmp slt i32 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %0
%7 = load i32, i32* @AF_INET
%8 = load i32, i32* @SOCK_STREAM
%9 = load i32, i32* @IPPROTO_TCP
%10 = tail call i32 @socket(i32 %7, i32 %8, i32 %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %6
%13 = tail call i32 @close(i32 %4)
%14 = tail call i32 @close(i32 %10)
br label %15
15: ; preds = %6, %0, %12
%16 = phi i32* [ @EXIT_SUCCESS, %12 ], [ @EXIT_FAILURE, %0 ], [ @EXIT_FAILURE, %6 ]
%17 = load i32, i32* %16
ret i32 %17
}