#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;
};

/* Variables and functions */
int /*<<< orphan*/ client_close(int);
int client_open(char const *, struct sockaddr_un *);
int client_send_reply(int, char const *, char *, int);
int client_send_msg_reply(const char *path, const char *msg, int msg_len,
                          char *recv, int recv_len) {
  struct sockaddr_un socket_addr;
  int socket;
  int length = 0;
  socket = client_open(path, &socket_addr);
  if (socket > 0) {
    length = client_send_reply(socket, msg, recv, recv_len);
    client_close(socket);
  }
  return length;
}


x86 assembly (clang, -O0):
<client_send_msg_reply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <client_open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    118a <client_send_msg_reply+0x5a>
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1050 <client_send_reply@plt>
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%edi
call   1030 <client_close@plt>
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<client_send_msg_reply>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %rsi,%rbp
mov    %rsp,%rsi
call   1040 <client_open@plt>
test   %eax,%eax
jle    1169 <client_send_msg_reply+0x39>
mov    %eax,%ebx
mov    %eax,%edi
mov    %rbp,%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1050 <client_send_reply@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <client_close@plt>
jmp    116b <client_send_msg_reply+0x3b>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i32 }
define i32 @client_send_msg_reply(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca %struct.sockaddr_un
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
store i32 0, i32* %13
%14 = load i8*, i8** %6
%15 = call i32 @client_open(i8* %14, %struct.sockaddr_un* %11)
store i32 %15, i32* %12
%16 = load i32, i32* %12
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %5
%19 = load i32, i32* %12
%20 = load i8*, i8** %7
%21 = load i8*, i8** %9
%22 = load i32, i32* %10
%23 = call i32 @client_send_reply(i32 %19, i8* %20, i8* %21, i32 %22)
store i32 %23, i32* %13
%24 = load i32, i32* %12
%25 = call i32 @client_close(i32 %24)
br label %26
26: ; preds = %18, %5
%27 = load i32, i32* %13
ret i32 %27
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32 }
define i32 @client_send_msg_reply(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca %struct.sockaddr_un
%7 = bitcast %struct.sockaddr_un* %6 to i8*
%8 = call i32 @client_open(i8* %0, %struct.sockaddr_un* %6)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = call i32 @client_send_reply(i32 %8, i8* %1, i8* %3, i32 %4)
%12 = call i32 @client_close(i32 %8)
br label %13
13: ; preds = %10, %5
%14 = phi i32 [ %11, %10 ], [ 0, %5 ]
ret i32 %14
}