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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *,
             int /*<<< orphan*/ *);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, int /*<<< orphan*/);
void dg_echo(int sockfd, struct sockaddr *cliaddr, socklen_t clilen) {
  int n;
  socklen_t len;
  char msg[1024];
  while (1) {
    len = clilen;
    n = recvfrom(sockfd, msg, sizeof(msg), 0, cliaddr, &len);
    printf("bound name = %s\n", ((struct sockaddr_un *)cliaddr)->sun_path);
    sendto(sockfd, msg, n, 0, cliaddr, len);
  }
}


x86 assembly (clang, -O0):
<dg_echo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    -0x10(%rbp),%r8
mov    $0x400,%edx
xor    %ecx,%ecx
lea    -0x1c(%rbp),%r9
call   1050 <recvfrom@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%r8
mov    -0x1c(%rbp),%r9d
xor    %ecx,%ecx
call   1040 <sendto@plt>
jmp    1145 <dg_echo+0x15>

x86 assembly (clang, -O2):
<dg_echo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x10(%rsp),%r15
lea    0xeab(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14d,0xc(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
lea    0xc(%rsp),%r9
call   1050 <recvfrom@plt>
mov    %eax,%r12d
mov    (%rbx),%rsi
mov    %r13,%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%r9d
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r12d,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1040 <sendto@plt>
jmp    1160 <dg_echo+0x30>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
%struct.sockaddr_un = type { i8* }
@.str = [17 x i8] c"bound name = %s\0A\00"
define void @dg_echo(i32 %0, %struct.sockaddr* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.sockaddr*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [1024 x i8]
store i32 %0, i32* %4
store %struct.sockaddr* %1, %struct.sockaddr** %5
store i32 %2, i32* %6
br label %10
10: ; preds = %3, %10
%11 = load i32, i32* %6
store i32 %11, i32* %8
%12 = load i32, i32* %4
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%14 = load %struct.sockaddr*, %struct.sockaddr** %5
%15 = call i32 @recvfrom(i32 %12, i8* %13, i32 1024, i32 0, %struct.sockaddr* %14, i32* %8)
store i32 %15, i32* %7
%16 = load %struct.sockaddr*, %struct.sockaddr** %5
%17 = bitcast %struct.sockaddr* %16 to %struct.sockaddr_un*
%18 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %17, i32 0, i32 0
%19 = load i8*, i8** %18
%20 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* %4
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%23 = load i32, i32* %7
%24 = load %struct.sockaddr*, %struct.sockaddr** %5
%25 = load i32, i32* %8
%26 = call i32 @sendto(i32 %21, i8* %22, i32 %23, i32 0, %struct.sockaddr* %24, i32 %25)
br label %10
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@.str = [17 x i8] c"bound name = %s\0A\00"
define void @dg_echo(i32 %0, %struct.sockaddr* %1, i32 %2) {
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = bitcast i32* %4 to i8*
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = bitcast %struct.sockaddr* %1 to i8**
br label %9
9: ; preds = %9, %3
store i32 %2, i32* %4
%10 = call i32 @recvfrom(i32 %0, i8* %7, i32 1024, i32 0, %struct.sockaddr* %1, i32* %4)
%11 = load i8*, i8** %8
%12 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* %4
%14 = call i32 @sendto(i32 %0, i8* %7, i32 %10, i32 0, %struct.sockaddr* %1, i32 %13)
br label %9
}