#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 create_unix_dgram_socket(char *, int /*<<< orphan*/);
int destroy_unix_socket(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(int /*<<< orphan*/);
int recvfrom_unix_dgram_socket(int, char *, int, int /*<<< orphan*/,
                               int /*<<< orphan*/, int /*<<< orphan*/);
int sendto_unix_dgram_socket(int, char *, int, char *, int /*<<< orphan*/);
int write(int, char *, int);
int main(void) {
  int sfd, ret;
  char *string = "abcdefghijklmnopqrstuvwxyz";
  char buf[26];
  ret = sfd = create_unix_dgram_socket("/tmp/client", 0);
  if (ret < 0) {
    perror(0);
    exit(1);
  }
  ret = sendto_unix_dgram_socket(sfd, string, 26, "/tmp/echosock", 0);
  if (ret < 0) {
    perror(0);
    exit(1);
  }
  ret = recvfrom_unix_dgram_socket(sfd, buf, 26, 0, 0, 0);
  if (ret < 0) {
    perror(0);
    exit(1);
  }
  ret = write(1, buf, 26);
  if (ret < 0) {
    perror(0);
    exit(1);
  }
  ret = destroy_unix_socket(sfd);
  if (ret < 0) {
    perror(0);
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe8a(%rip),%rdi
xor    %esi,%esi
call   1030 <create_unix_dgram_socket@plt>
mov    %eax,-0x8(%rbp)
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11b9 <main+0x49>
xor    %edi,%edi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x1a,%edx
lea    0xe5b(%rip),%rcx
xor    %r8d,%r8d
call   1070 <sendto_unix_dgram_socket@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11f2 <main+0x82>
xor    %edi,%edi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x1a,%edx
xor    %r9d,%r9d
mov    %r9d,%ecx
mov    %r9d,%r8d
call   1050 <recvfrom_unix_dgram_socket@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    122a <main+0xba>
xor    %edi,%edi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    -0x40(%rbp),%rsi
mov    $0x1,%edi
mov    $0x1a,%edx
call   1040 <write@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    125b <main+0xeb>
xor    %edi,%edi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x8(%rbp),%edi
call   1060 <destroy_unix_socket@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1281 <main+0x111>
xor    %edi,%edi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xe9f(%rip),%rdi
xor    %esi,%esi
call   1030 <create_unix_dgram_socket@plt>
test   %eax,%eax
js     11ee <main+0x7e>
mov    %eax,%ebx
lea    0xe70(%rip),%rsi
lea    0xe90(%rip),%rcx
mov    %eax,%edi
mov    $0x1a,%edx
xor    %r8d,%r8d
call   1070 <sendto_unix_dgram_socket@plt>
test   %eax,%eax
js     11ee <main+0x7e>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x1a,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1050 <recvfrom_unix_dgram_socket@plt>
test   %eax,%eax
js     11ee <main+0x7e>
mov    %rsp,%rsi
mov    $0x1,%edi
mov    $0x1a,%edx
call   1040 <write@plt>
test   %eax,%eax
js     11ee <main+0x7e>
mov    %ebx,%edi
call   1060 <destroy_unix_socket@plt>
test   %eax,%eax
js     11ee <main+0x7e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
xor    %edi,%edi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str.1 = [12 x i8] c"/tmp/client\00"
@.str.2 = [14 x i8] c"/tmp/echosock\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [26 x i8]
store i32 0, i32* %1
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8** %4
%6 = call i32 @create_unix_dgram_socket(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 0)
store i32 %6, i32* %2
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 @perror(i32 0)
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = load i32, i32* %2
%14 = load i8*, i8** %4
%15 = call i32 @sendto_unix_dgram_socket(i32 %13, i8* %14, i32 26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 0)
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = call i32 @perror(i32 0)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %12
%22 = load i32, i32* %2
%23 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 0
%24 = call i32 @recvfrom_unix_dgram_socket(i32 %22, i8* %23, i32 26, i32 0, i32 0, i32 0)
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = call i32 @perror(i32 0)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %21
%31 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 0
%32 = call i32 @write(i32 1, i8* %31, i32 26)
store i32 %32, i32* %3
%33 = load i32, i32* %3
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = call i32 @perror(i32 0)
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %30
%39 = load i32, i32* %2
%40 = call i32 @destroy_unix_socket(i32 %39)
store i32 %40, i32* %3
%41 = load i32, i32* %3
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %38
%44 = call i32 @perror(i32 0)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %38
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str.1 = [12 x i8] c"/tmp/client\00"
@.str.2 = [14 x i8] c"/tmp/echosock\00"
define i32 @main() {
%1 = alloca [26 x i8]
%2 = getelementptr inbounds [26 x i8], [26 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @create_unix_dgram_socket(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 0)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @perror(i32 0)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = tail call i32 @sendto_unix_dgram_socket(i32 %3, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 0)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = tail call i32 @perror(i32 0)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %8
%15 = call i32 @recvfrom_unix_dgram_socket(i32 %3, i8* %2, i32 26, i32 0, i32 0, i32 0)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = call i32 @perror(i32 0)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %14
%21 = call i32 @write(i32 1, i8* %2, i32 26)
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i32 @perror(i32 0)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %20
%27 = call i32 @destroy_unix_socket(i32 %3)
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = call i32 @perror(i32 0)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %26
ret i32 0
}