#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 /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ set_it_socket_opts(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ trace(char *);
int it_remote_socket() {
  int sockfd;
  trace("opening socket");
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sockfd < 0) {
    error("ERROR opening socket");
    assert(0);
  }
  set_it_socket_opts(sockfd);
  return sockfd;
}


x86 assembly (clang, -O0):
<it_remote_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea7(%rip),%rdi
call   1050 <trace@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    119d <it_remote_socket+0x4d>
lea    0xe6f(%rip),%rdi
call   1040 <error@plt>
xor    %edi,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%edi
call   1060 <set_it_socket_opts@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<it_remote_socket>:
push   %rbx
lea    0xeae(%rip),%rdi
call   1050 <trace@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    118f <it_remote_socket+0x3f>
lea    0xe7d(%rip),%rdi
call   1040 <error@plt>
xor    %edi,%edi
call   1030 <assert@plt>
mov    %ebx,%edi
call   1060 <set_it_socket_opts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"opening socket\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [21 x i8] c"ERROR opening socket\00"
define i32 @it_remote_socket() {
%1 = alloca i32
%2 = call i32 @trace(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @AF_INET
%4 = load i32, i32* @SOCK_STREAM
%5 = call i32 @socket(i32 %3, i32 %4, i32 0)
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @assert(i32 0)
br label %11
11: ; preds = %8, %0
%12 = load i32, i32* %1
%13 = call i32 @set_it_socket_opts(i32 %12)
%14 = load i32, i32* %1
ret i32 %14
}

LLVM IR (-O2):
@.str = [15 x i8] c"opening socket\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [21 x i8] c"ERROR opening socket\00"
define i32 @it_remote_socket() {
%1 = tail call i32 @trace(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = load i32, i32* @AF_INET
%3 = load i32, i32* @SOCK_STREAM
%4 = tail call i32 @socket(i32 %2, i32 %3, i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @assert(i32 0)
br label %9
9: ; preds = %6, %0
%10 = tail call i32 @set_it_socket_opts(i32 %4)
ret i32 %4
}