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

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ SOCK_STREAM;
int connect(int, struct sockaddr *, int);
int send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int send_cli_message(char *message) {
  struct sockaddr_un addr_remote;
  int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
  addr_remote.sun_family = AF_UNIX;
  strcpy(addr_remote.sun_path, "/var/run/network_gatekeeper.sock");
  int addrlen = strlen(addr_remote.sun_path) + sizeof(addr_remote.sun_family);
  int result = connect(sockfd, (struct sockaddr *)&addr_remote, addrlen);
  result = send(sockfd, message, strlen(message), 0);
  return 0;
}


x86 assembly (clang, -O0):
<send_cli_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cltq
add    $0x4,%rax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1060 <connect@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_cli_message>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2e86(%rip),%r14
mov    (%r14),%edi
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,%ebp
mov    (%r14),%eax
mov    %eax,0x8(%rsp)
lea    0xe7b(%rip),%rsi
call   1030 <strcpy@plt>
call   1040 <strlen@plt>
lea    0x4(%rax),%edx
mov    %rsp,%rsi
mov    %ebp,%edi
call   1060 <connect@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [33 x i8] c"/var/run/network_gatekeeper.sock\00"
define i32 @send_cli_message(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.sockaddr_un
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i32, i32* @AF_UNIX
%8 = load i32, i32* @SOCK_STREAM
%9 = call i32 @socket(i32 %7, i32 %8, i32 0)
store i32 %9, i32* %4
%10 = load i32, i32* @AF_UNIX
%11 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i32 0, i32 1
store i32 %10, i32* %11
%12 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i32 0, i32 0
%13 = load i8*, i8** %12
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %3, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* %16)
%18 = sext i32 %17 to i64
%19 = add i64 %18, 4
%20 = trunc i64 %19 to i32
store i32 %20, i32* %5
%21 = load i32, i32* %4
%22 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
%23 = load i32, i32* %5
%24 = call i32 @connect(i32 %21, %struct.sockaddr* %22, i32 %23)
store i32 %24, i32* %6
%25 = load i32, i32* %4
%26 = load i8*, i8** %2
%27 = load i8*, i8** %2
%28 = call i32 @strlen(i8* %27)
%29 = call i32 @send(i32 %25, i8* %26, i32 %28, i32 0)
store i32 %29, i32* %6
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i8*, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [33 x i8] c"/var/run/network_gatekeeper.sock\00"
define i32 @send_cli_message(i8* %0) {
%2 = alloca %struct.sockaddr_un
%3 = bitcast %struct.sockaddr_un* %2 to i8*
%4 = load i32, i32* @AF_UNIX
%5 = load i32, i32* @SOCK_STREAM
%6 = tail call i32 @socket(i32 %4, i32 %5, i32 0)
%7 = load i32, i32* @AF_UNIX
%8 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %2, i64 0, i32 1
store i32 %7, i32* %8
%9 = tail call i32 @strcpy(i8* undef, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @strlen(i8* undef)
%11 = add i32 %10, 4
%12 = bitcast %struct.sockaddr_un* %2 to %struct.sockaddr*
%13 = call i32 @connect(i32 %6, %struct.sockaddr* %12, i32 %11)
%14 = call i32 @strlen(i8* %0)
%15 = call i32 @send(i32 %6, i8* %0, i32 %14, i32 0)
ret i32 0
}