#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 /*<<< orphan*/ member_0;
};

/* Variables and functions */
struct sockaddr_un *tow_unix_socket_address_alloc_copy(struct sockaddr_un *);
int tow_unix_socket_address_init(struct sockaddr_un *, char const *);
struct sockaddr_un *tow_unix_socket_address_alloc(char const *path) {
  struct sockaddr_un socket_address = {0};
  int result = tow_unix_socket_address_init(&socket_address, path);
  if (result == -1)
    return NULL;
  return tow_unix_socket_address_alloc_copy(&socket_address);
}


x86 assembly (clang, -O0):
<tow_unix_socket_address_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdi
call   1050 <tow_unix_socket_address_init@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1173 <tow_unix_socket_address_alloc+0x43>
movq   $0x0,-0x8(%rbp)
jmp    1180 <tow_unix_socket_address_alloc+0x50>
lea    -0x18(%rbp),%rdi
call   1030 <tow_unix_socket_address_alloc_copy@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tow_unix_socket_address_alloc>:
push   %rax
mov    %rdi,%rsi
movl   $0x0,(%rsp)
mov    %rsp,%rdi
call   1040 <tow_unix_socket_address_init@plt>
cmp    $0xffffffff,%eax
je     1142 <tow_unix_socket_address_alloc+0x22>
mov    %rsp,%rdi
call   1030 <tow_unix_socket_address_alloc_copy@plt>
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i32 }
define %struct.sockaddr_un* @tow_unix_socket_address_alloc(i8* %0) {
%2 = alloca %struct.sockaddr_un*
%3 = alloca i8*
%4 = alloca %struct.sockaddr_un
%5 = alloca i32
store i8* %0, i8** %3
%6 = bitcast %struct.sockaddr_un* %4 to i8*
%7 = load i8*, i8** %3
%8 = call i32 @tow_unix_socket_address_init(%struct.sockaddr_un* %4, i8* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %12
11: ; preds = %1
store %struct.sockaddr_un* null, %struct.sockaddr_un** %2
br label %14
12: ; preds = %1
%13 = call %struct.sockaddr_un* @tow_unix_socket_address_alloc_copy(%struct.sockaddr_un* %4)
store %struct.sockaddr_un* %13, %struct.sockaddr_un** %2
br label %14
14: ; preds = %12, %11
%15 = load %struct.sockaddr_un*, %struct.sockaddr_un** %2
ret %struct.sockaddr_un* %15
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32 }
define %struct.sockaddr_un* @tow_unix_socket_address_alloc(i8* %0) {
%2 = alloca %struct.sockaddr_un
%3 = bitcast %struct.sockaddr_un* %2 to i8*
%4 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %2, i64 0, i32 0
store i32 0, i32* %4
%5 = call i32 @tow_unix_socket_address_init(%struct.sockaddr_un* %2, i8* %0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call %struct.sockaddr_un* @tow_unix_socket_address_alloc_copy(%struct.sockaddr_un* %2)
br label %9
9: ; preds = %1, %7
%10 = phi %struct.sockaddr_un* [ %8, %7 ], [ null, %1 ]
ret %struct.sockaddr_un* %10
}