#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*/ AF_UNIX;
int SOCK_CLOEXEC;
int SOCK_NONBLOCK;
int errno;
int /*<<< orphan*/ fd_inc_sndbuf(int, int);
int socket(int /*<<< orphan*/, int, int /*<<< orphan*/);
int create_log_socket(int type) {
  int fd;
  fd = socket(AF_UNIX, type | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
  if (fd < 0)
    return -errno;
  fd_inc_sndbuf(fd, (8 * 1024 * 1024));
  return fd;
}


x86 assembly (clang, -O0):
<create_log_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2eae(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    0x2eb2(%rip),%rax
or     (%rax),%esi
mov    0x2e89(%rip),%rax
or     (%rax),%esi
xor    %edx,%edx
call   1040 <socket@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1170 <create_log_socket+0x50>
xor    %eax,%eax
mov    0x2e62(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1183 <create_log_socket+0x63>
mov    -0xc(%rbp),%edi
mov    $0x800000,%esi
call   1030 <fd_inc_sndbuf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_log_socket>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%esi
mov    0x2eb4(%rip),%rax
mov    0x2ebd(%rip),%rcx
or     (%rcx),%esi
mov    (%rax),%edi
mov    0x2e92(%rip),%rax
or     (%rax),%esi
xor    %ebx,%ebx
xor    %edx,%edx
call   1040 <socket@plt>
test   %eax,%eax
js     115f <create_log_socket+0x3f>
mov    %eax,%ebp
mov    %eax,%edi
mov    $0x800000,%esi
call   1030 <fd_inc_sndbuf@plt>
mov    %ebp,%ebx
jmp    1168 <create_log_socket+0x48>
mov    0x2e62(%rip),%rax
sub    (%rax),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@AF_UNIX = global i32 0
@SOCK_CLOEXEC = global i32 0
@SOCK_NONBLOCK = global i32 0
@errno = global i32 0
define i32 @create_log_socket(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* @AF_UNIX
%6 = load i32, i32* %3
%7 = load i32, i32* @SOCK_CLOEXEC
%8 = or i32 %6, %7
%9 = load i32, i32* @SOCK_NONBLOCK
%10 = or i32 %8, %9
%11 = call i32 @socket(i32 %5, i32 %10, i32 0)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = load i32, i32* @errno
%16 = sub nsw i32 0, %15
store i32 %16, i32* %2
br label %21
17: ; preds = %1
%18 = load i32, i32* %4
%19 = call i32 @fd_inc_sndbuf(i32 %18, i32 8388608)
%20 = load i32, i32* %4
store i32 %20, i32* %2
br label %21
21: ; preds = %17, %14
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@AF_UNIX = global i32 0
@SOCK_CLOEXEC = global i32 0
@SOCK_NONBLOCK = global i32 0
@errno = global i32 0
define i32 @create_log_socket(i32 %0) {
%2 = load i32, i32* @AF_UNIX
%3 = load i32, i32* @SOCK_CLOEXEC
%4 = or i32 %3, %0
%5 = load i32, i32* @SOCK_NONBLOCK
%6 = or i32 %4, %5
%7 = tail call i32 @socket(i32 %2, i32 %6, i32 0)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @errno
%11 = sub nsw i32 0, %10
br label %14
12: ; preds = %1
%13 = tail call i32 @fd_inc_sndbuf(i32 %7, i32 8388608)
br label %14
14: ; preds = %12, %9
%15 = phi i32 [ %11, %9 ], [ %7, %12 ]
ret i32 %15
}