#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_LOCAL;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ socket_local_client_connect(int, char const *);
int socket_local_client(const char *name) {
  int s;
  if (name == NULL)
    return -1;
  s = socket(AF_LOCAL, SOCK_STREAM, 0);
  if (s < 0)
    return -2;
  if (socket_local_client_connect(s, name) < 0) {
    close(s);
    return -3;
  }
  return s;
}


x86 assembly (clang, -O0):
<socket_local_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1153 <socket_local_client+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b5 <socket_local_client+0x85>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
mov    0x2e75(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1185 <socket_local_client+0x55>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11b5 <socket_local_client+0x85>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <socket_local_client_connect@plt>
cmp    $0x0,%rax
jge    11af <socket_local_client+0x7f>
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    11b5 <socket_local_client+0x85>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<socket_local_client>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1178 <socket_local_client+0x48>
mov    %rdi,%r14
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <socket@plt>
test   %eax,%eax
js     117f <socket_local_client+0x4f>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <socket_local_client_connect@plt>
test   %rax,%rax
jns    1184 <socket_local_client+0x54>
mov    %ebx,%edi
call   1030 <close@plt>
mov    $0xfffffffd,%ebx
jmp    1184 <socket_local_client+0x54>
mov    $0xffffffff,%ebx
jmp    1184 <socket_local_client+0x54>
mov    $0xfffffffe,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@AF_LOCAL = global i32 0
@SOCK_STREAM = global i32 0
define i32 @socket_local_client(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = load i32, i32* @AF_LOCAL
%5 = load i32, i32* @SOCK_STREAM
%6 = tail call i32 @socket(i32 %4, i32 %5, i32 0)
%7 = icmp slt i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = tail call i64 @socket_local_client_connect(i32 %6, i8* %0)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @close(i32 %6)
br label %13
13: ; preds = %8, %3, %1, %11
%14 = phi i32 [ -3, %11 ], [ -1, %1 ], [ -2, %3 ], [ %6, %8 ]
ret i32 %14
}