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


x86 assembly (clang, -O0):
<socket_local_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    0x2e9f(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    116e <socket_local_client+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a8 <socket_local_client+0x78>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <socket_local_client_connect@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    11a2 <socket_local_client+0x72>
mov    -0x1c(%rbp),%edi
call   1030 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a8 <socket_local_client+0x78>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<socket_local_client>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%r12
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
mov    %edx,%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    $0xffffffff,%r15d
test   %eax,%eax
js     117e <socket_local_client+0x4e>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r12,%rsi
mov    %r14d,%edx
mov    %ebp,%ecx
call   1040 <socket_local_client_connect@plt>
test   %rax,%rax
js     1177 <socket_local_client+0x47>
mov    %ebx,%r15d
jmp    117e <socket_local_client+0x4e>
mov    %ebx,%edi
call   1030 <close@plt>
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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