#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 */
struct sockaddr_un {
  int dummy;
};
struct sockaddr {
  int dummy;
};

/* Variables and functions */
scalar_t__ connect(int, struct sockaddr *, int);
int get_sockaddr_un_size(struct sockaddr_un *);
int /*<<< orphan*/ perror(char *);
bool connect_unix_stream_socket(int sock, struct sockaddr_un *sock_st) {
  int len = get_sockaddr_un_size(sock_st);
  if (connect(sock, (struct sockaddr *)sock_st, len) < 0) {
    perror("Error - connect_unix_stream_socket() - connect::");
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<connect_unix_stream_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <get_sockaddr_un_size@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <connect@plt>
cmp    $0x0,%rax
jge    117c <connect_unix_stream_socket+0x4c>
lea    0xe95(%rip),%rdi
call   1030 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1183 <connect_unix_stream_socket+0x53>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connect_unix_stream_socket>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1050 <get_sockaddr_un_size@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <connect@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
js     1160 <connect_unix_stream_socket+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe99(%rip),%rdi
call   1030 <perror@plt>
xor    %eax,%eax
jmp    1159 <connect_unix_stream_socket+0x29>

LLVM IR (-O0):
%struct.sockaddr_un = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [49 x i8] c"Error - connect_unix_stream_socket() - connect::\00"
define i32 @connect_unix_stream_socket(i32 %0, %struct.sockaddr_un* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sockaddr_un*
%6 = alloca i32
store i32 %0, i32* %4
store %struct.sockaddr_un* %1, %struct.sockaddr_un** %5
%7 = load %struct.sockaddr_un*, %struct.sockaddr_un** %5
%8 = call i32 @get_sockaddr_un_size(%struct.sockaddr_un* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %4
%10 = load %struct.sockaddr_un*, %struct.sockaddr_un** %5
%11 = bitcast %struct.sockaddr_un* %10 to %struct.sockaddr*
%12 = load i32, i32* %6
%13 = call i64 @connect(i32 %9, %struct.sockaddr* %11, i32 %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %18
17: ; preds = %2
store i32 1, i32* %3
br label %18
18: ; preds = %17, %15
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [49 x i8] c"Error - connect_unix_stream_socket() - connect::\00"
define i32 @connect_unix_stream_socket(i32 %0, %struct.sockaddr_un* %1) {
%3 = tail call i32 @get_sockaddr_un_size(%struct.sockaddr_un* %1)
%4 = bitcast %struct.sockaddr_un* %1 to %struct.sockaddr*
%5 = tail call i64 @connect(i32 %0, %struct.sockaddr* %4, i32 %3)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %2, %7
%10 = phi i32 [ 0, %7 ], [ 1, %2 ]
ret i32 %10
}