#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*/ assert(struct sockaddr_un const *);
struct sockaddr_un *malloc(int);
int /*<<< orphan*/ memcpy(struct sockaddr_un *, struct sockaddr_un const *,
                          int);
struct sockaddr_un *
tow_unix_socket_address_alloc_copy(struct sockaddr_un const *socket_address) {
  assert(socket_address);
  struct sockaddr_un *copy = malloc(sizeof(struct sockaddr_un));
  if (!copy)
    return NULL;
  memcpy(copy, socket_address, sizeof(struct sockaddr_un));
  return copy;
}


x86 assembly (clang, -O0):
<tow_unix_socket_address_alloc_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <assert@plt>
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116b <tow_unix_socket_address_alloc_copy+0x3b>
movq   $0x0,-0x8(%rbp)
jmp    1185 <tow_unix_socket_address_alloc_copy+0x55>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tow_unix_socket_address_alloc_copy>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <assert@plt>
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     115e <tow_unix_socket_address_alloc_copy+0x2e>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.sockaddr_un = type { i32 }
define %struct.sockaddr_un* @tow_unix_socket_address_alloc_copy(%struct.sockaddr_un* %0) {
%2 = tail call i32 @assert(%struct.sockaddr_un* %0)
%3 = tail call %struct.sockaddr_un* @malloc(i32 4)
%4 = icmp eq %struct.sockaddr_un* %3, null
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 @memcpy(%struct.sockaddr_un* %3, %struct.sockaddr_un* %0, i32 4)
br label %7
7: ; preds = %1, %5
ret %struct.sockaddr_un* %3
}