#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 /*<<< orphan*/ sun_path;
  int /*<<< orphan*/ sun_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ servaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_LOCAL;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ memset(struct sockaddr_un *, int /*<<< orphan*/, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ str_cli(int /*<<< orphan*/, int);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int main(int argc, char *argv[]) {
  int sockfd;
  struct sockaddr_un servaddr;
  sockfd = socket(AF_LOCAL, SOCK_STREAM, 0);
  memset(&servaddr, 0, sizeof(servaddr));
  servaddr.sun_family = AF_LOCAL;
  strcpy(servaddr.sun_path, "/tmp/unix.str");
  connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
  str_cli(stdin, sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,-0x14(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
lea    0xe58(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   1060 <connect@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
call   1050 <str_cli@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e80(%rip),%r15
mov    (%r15),%edi
mov    0x2e66(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    (%r15),%eax
mov    %eax,0xc(%rsp)
mov    0x8(%rsp),%edi
lea    0xe65(%rip),%rsi
call   1030 <strcpy@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x8,%edx
call   1060 <connect@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
mov    %ebx,%esi
call   1050 <str_cli@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_LOCAL = global i32 0
@SOCK_STREAM = global i32 0
@.str = [14 x i8] c"/tmp/unix.str\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_un
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @AF_LOCAL
%9 = load i32, i32* @SOCK_STREAM
%10 = call i32 @socket(i32 %8, i32 %9, i32 0)
store i32 %10, i32* %6
%11 = call i32 @memset(%struct.sockaddr_un* %7, i32 0, i32 8)
%12 = load i32, i32* @AF_LOCAL
%13 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 1
store i32 %12, i32* %13
%14 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %7, i32 0, i32 0
%15 = load i32, i32* %14
%16 = call i32 @strcpy(i32 %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* %6
%18 = bitcast %struct.sockaddr_un* %7 to %struct.sockaddr*
%19 = call i32 @connect(i32 %17, %struct.sockaddr* %18, i32 8)
%20 = load i32, i32* @stdin
%21 = load i32, i32* %6
%22 = call i32 @str_cli(i32 %20, i32 %21)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_LOCAL = global i32 0
@SOCK_STREAM = global i32 0
@.str = [14 x i8] c"/tmp/unix.str\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_un
%4 = bitcast %struct.sockaddr_un* %3 to i8*
%5 = load i32, i32* @AF_LOCAL
%6 = load i32, i32* @SOCK_STREAM
%7 = tail call i32 @socket(i32 %5, i32 %6, i32 0)
%8 = call i32 @memset(%struct.sockaddr_un* %3, i32 0, i32 8)
%9 = load i32, i32* @AF_LOCAL
%10 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 1
store i32 %9, i32* %10
%11 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i64 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @strcpy(i32 %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%14 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
%15 = call i32 @connect(i32 %7, %struct.sockaddr* %14, i32 8)
%16 = load i32, i32* @stdin
%17 = call i32 @str_cli(i32 %16, i32 %7)
ret i32 0
}