#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*/ close(int);
int /*<<< orphan*/ printf(char *, char *);
int uds_accept(int, int /*<<< orphan*/ *);
int uds_open(char *);
int uds_read(int, char *, int);
int main(void) {
  int socket_fd;
  int connection_fd;
  char buffer[256];
  int nbytes;
  socket_fd = uds_open(".lguest_control");
  connection_fd = uds_accept(socket_fd, NULL);
  nbytes = uds_read(connection_fd, buffer, 256);
  printf("got message of %s\n", buffer);
  close(connection_fd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    0xe9e(%rip),%rdi
call   1050 <uds_open@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <uds_accept@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x100,%edx
call   1070 <uds_read@plt>
mov    %eax,-0x114(%rbp)
lea    -0x110(%rbp),%rsi
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
lea    0xe9f(%rip),%rdi
call   1050 <uds_open@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1060 <uds_accept@plt>
mov    %eax,%ebx
mov    %rsp,%r14
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x100,%edx
call   1070 <uds_read@plt>
lea    0xe86(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    %ebx,%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c".lguest_control\00"
@.str.1 = [19 x i8] c"got message of %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = call i32 @uds_open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = call i32 @uds_accept(i32 %6, i32* null)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%10 = call i32 @uds_read(i32 %8, i8* %9, i32 256)
store i32 %10, i32* %4
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i32, i32* %2
%14 = call i32 @close(i32 %13)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c".lguest_control\00"
@.str.1 = [19 x i8] c"got message of %s\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @uds_open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @uds_accept(i32 %3, i32* null)
%5 = call i32 @uds_read(i32 %4, i8* %2, i32 256)
%6 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = call i32 @close(i32 %4)
ret i32 0
}