#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  void *vci;
  void *vpi;
  void *itf;
};
struct sockaddr_atmpvc {
  TYPE_1__ sap_addr;
  int /*<<< orphan*/ sap_family;
};

/* Variables and functions */
int /*<<< orphan*/ PF_ATMPVC;
struct sockaddr_atmpvc *malloc(int);
void *rand();
void atmpvc_gen_sockaddr(unsigned long *addr, unsigned long *addrlen) {
  struct sockaddr_atmpvc *atmpvc;
  atmpvc = malloc(sizeof(struct sockaddr_atmpvc));
  if (atmpvc == NULL)
    return;
  atmpvc->sap_family = PF_ATMPVC;
  atmpvc->sap_addr.itf = rand();
  atmpvc->sap_addr.vpi = rand();
  atmpvc->sap_addr.vci = rand();
  *addr = (unsigned long)atmpvc;
  *addrlen = sizeof(struct sockaddr_atmpvc);
}


x86 assembly (clang, -O0):
<atmpvc_gen_sockaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x20,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114e <atmpvc_gen_sockaddr+0x2e>
jmp    11a9 <atmpvc_gen_sockaddr+0x89>
mov    0x2e9b(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x20,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atmpvc_gen_sockaddr>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x20,%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     1173 <atmpvc_gen_sockaddr+0x53>
mov    %rax,%rbx
mov    0x2eac(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rbx)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x10(%rbx)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x8(%rbx)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,(%rbx)
mov    %rbx,(%r15)
movq   $0x20,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_atmpvc = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i8*, i8*, i8* }
@PF_ATMPVC = global i32 0
define void @atmpvc_gen_sockaddr(i64* %0, i64* %1) {
%3 = alloca i64*
%4 = alloca i64*
%5 = alloca %struct.sockaddr_atmpvc*
store i64* %0, i64** %3
store i64* %1, i64** %4
%6 = call %struct.sockaddr_atmpvc* @malloc(i32 32)
store %struct.sockaddr_atmpvc* %6, %struct.sockaddr_atmpvc** %5
%7 = load %struct.sockaddr_atmpvc*, %struct.sockaddr_atmpvc** %5
%8 = icmp eq %struct.sockaddr_atmpvc* %7, null
br i1 %8, label %9, label %10
9: ; preds = %2
br label %30
10: ; preds = %2
%11 = load i32, i32* @PF_ATMPVC
%12 = load %struct.sockaddr_atmpvc*, %struct.sockaddr_atmpvc** %5
%13 = getelementptr inbounds %struct.sockaddr_atmpvc, %struct.sockaddr_atmpvc* %12, i32 0, i32 1
store i32 %11, i32* %13
%14 = call i8* (...) @rand()
%15 = load %struct.sockaddr_atmpvc*, %struct.sockaddr_atmpvc** %5
%16 = getelementptr inbounds %struct.sockaddr_atmpvc, %struct.sockaddr_atmpvc* %15, i32 0, i32 0
%17 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %16, i32 0, i32 2
store i8* %14, i8** %17
%18 = call i8* (...) @rand()
%19 = load %struct.sockaddr_atmpvc*, %struct.sockaddr_atmpvc** %5
%20 = getelementptr inbounds %struct.sockaddr_atmpvc, %struct.sockaddr_atmpvc* %19, i32 0, i32 0
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i32 0, i32 1
store i8* %18, i8** %21
%22 = call i8* (...) @rand()
%23 = load %struct.sockaddr_atmpvc*, %struct.sockaddr_atmpvc** %5
%24 = getelementptr inbounds %struct.sockaddr_atmpvc, %struct.sockaddr_atmpvc* %23, i32 0, i32 0
%25 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %24, i32 0, i32 0
store i8* %22, i8** %25
%26 = load %struct.sockaddr_atmpvc*, %struct.sockaddr_atmpvc** %5
%27 = ptrtoint %struct.sockaddr_atmpvc* %26 to i64
%28 = load i64*, i64** %3
store i64 %27, i64* %28
%29 = load i64*, i64** %4
store i64 32, i64* %29
br label %30
30: ; preds = %10, %9
ret void
}

LLVM IR (-O2):
%struct.sockaddr_atmpvc = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i8*, i8*, i8* }
@PF_ATMPVC = global i32 0
define void @atmpvc_gen_sockaddr(i64* nocapture writeonly %0, i64* nocapture writeonly %1) {
%3 = tail call %struct.sockaddr_atmpvc* @malloc(i32 32)
%4 = icmp eq %struct.sockaddr_atmpvc* %3, null
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = load i32, i32* @PF_ATMPVC
%7 = getelementptr inbounds %struct.sockaddr_atmpvc, %struct.sockaddr_atmpvc* %3, i64 0, i32 1
store i32 %6, i32* %7
%8 = tail call i8* (...) @rand()
%9 = getelementptr inbounds %struct.sockaddr_atmpvc, %struct.sockaddr_atmpvc* %3, i64 0, i32 0, i32 2
store i8* %8, i8** %9
%10 = tail call i8* (...) @rand()
%11 = getelementptr inbounds %struct.sockaddr_atmpvc, %struct.sockaddr_atmpvc* %3, i64 0, i32 0, i32 1
store i8* %10, i8** %11
%12 = tail call i8* (...) @rand()
%13 = getelementptr inbounds %struct.sockaddr_atmpvc, %struct.sockaddr_atmpvc* %3, i64 0, i32 0, i32 0
store i8* %12, i8** %13
%14 = ptrtoint %struct.sockaddr_atmpvc* %3 to i64
store i64 %14, i64* %0
store i64 32, i64* %1
br label %15
15: ; preds = %2, %5
ret void
}