#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_10__ TYPE_5__;
typedef struct TYPE_9__ TYPE_4__;
typedef struct TYPE_8__ TYPE_3__;
typedef struct TYPE_7__ TYPE_2__;
typedef struct TYPE_6__ TYPE_1__;

/* Type definitions */
struct TYPE_8__ {
  void *instance;
  void *type;
};
struct TYPE_9__ {
  void *domain;
  TYPE_3__ name;
};
struct TYPE_7__ {
  void *upper;
  void *lower;
  void *type;
};
struct TYPE_6__ {
  void *node;
  void *ref;
};
struct TYPE_10__ {
  TYPE_4__ name;
  TYPE_2__ nameseq;
  TYPE_1__ id;
};
struct sockaddr_tipc {
  TYPE_5__ addr;
  void *scope;
  void *addrtype;
  int /*<<< orphan*/ family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_TIPC;
struct sockaddr_tipc *malloc(int);
void *rand();
void gen_tipc(unsigned long *addr, unsigned long *addrlen) {
  struct sockaddr_tipc *tipc;
  tipc = malloc(sizeof(struct sockaddr_tipc));
  if (tipc == NULL)
    return;
  tipc->family = AF_TIPC;
  tipc->addrtype = rand();
  tipc->scope = rand();
  tipc->addr.id.ref = rand();
  tipc->addr.id.node = rand();
  tipc->addr.nameseq.type = rand();
  tipc->addr.nameseq.lower = rand();
  tipc->addr.nameseq.upper = rand();
  tipc->addr.name.name.type = rand();
  tipc->addr.name.name.instance = rand();
  tipc->addr.name.domain = rand();
  *addr = (unsigned long)tipc;
  *addrlen = sizeof(struct sockaddr_tipc);
}


x86 assembly (clang, -O0):
<gen_tipc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x58,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114e <gen_tipc+0x2e>
jmp    1227 <gen_tipc+0x107>
mov    0x2e93(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x50(%rax)
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x48(%rax)
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x40(%rax)
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x38(%rax)
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,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   $0x58,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_tipc>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x58,%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     11c4 <gen_tipc+0xa4>
mov    %rax,%rbx
mov    0x2ea0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x50(%rbx)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x48(%rbx)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x40(%rbx)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x38(%rbx)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x30(%rbx)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x28(%rbx)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x20(%rbx)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,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   $0x58,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_tipc = type { %struct.TYPE_10__, i8*, i8*, i32 }
%struct.TYPE_10__ = type { %struct.TYPE_9__, %struct.TYPE_7__, %struct.TYPE_6__ }
%struct.TYPE_9__ = type { i8*, %struct.TYPE_8__ }
%struct.TYPE_8__ = type { i8*, i8* }
%struct.TYPE_7__ = type { i8*, i8*, i8* }
%struct.TYPE_6__ = type { i8*, i8* }
@AF_TIPC = global i32 0
define void @gen_tipc(i64* %0, i64* %1) {
%3 = alloca i64*
%4 = alloca i64*
%5 = alloca %struct.sockaddr_tipc*
store i64* %0, i64** %3
store i64* %1, i64** %4
%6 = call %struct.sockaddr_tipc* @malloc(i32 88)
store %struct.sockaddr_tipc* %6, %struct.sockaddr_tipc** %5
%7 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%8 = icmp eq %struct.sockaddr_tipc* %7, null
br i1 %8, label %9, label %10
9: ; preds = %2
br label %66
10: ; preds = %2
%11 = load i32, i32* @AF_TIPC
%12 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%13 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %12, i32 0, i32 3
store i32 %11, i32* %13
%14 = call i8* (...) @rand()
%15 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%16 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %15, i32 0, i32 2
store i8* %14, i8** %16
%17 = call i8* (...) @rand()
%18 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%19 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %18, i32 0, i32 1
store i8* %17, i8** %19
%20 = call i8* (...) @rand()
%21 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%22 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %21, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %22, i32 0, i32 2
%24 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %23, i32 0, i32 1
store i8* %20, i8** %24
%25 = call i8* (...) @rand()
%26 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%27 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %26, i32 0, i32 0
%28 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %27, i32 0, i32 2
%29 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %28, i32 0, i32 0
store i8* %25, i8** %29
%30 = call i8* (...) @rand()
%31 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%32 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %31, i32 0, i32 0
%33 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %32, i32 0, i32 1
%34 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %33, i32 0, i32 2
store i8* %30, i8** %34
%35 = call i8* (...) @rand()
%36 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%37 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %36, i32 0, i32 0
%38 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %37, i32 0, i32 1
%39 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %38, i32 0, i32 1
store i8* %35, i8** %39
%40 = call i8* (...) @rand()
%41 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%42 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %41, i32 0, i32 0
%43 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %42, i32 0, i32 1
%44 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %43, i32 0, i32 0
store i8* %40, i8** %44
%45 = call i8* (...) @rand()
%46 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%47 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %46, i32 0, i32 0
%48 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %47, i32 0, i32 0
%49 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %48, i32 0, i32 1
%50 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %49, i32 0, i32 1
store i8* %45, i8** %50
%51 = call i8* (...) @rand()
%52 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%53 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %52, i32 0, i32 0
%54 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %53, i32 0, i32 0
%55 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %54, i32 0, i32 1
%56 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %55, i32 0, i32 0
store i8* %51, i8** %56
%57 = call i8* (...) @rand()
%58 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%59 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %58, i32 0, i32 0
%60 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %59, i32 0, i32 0
%61 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %60, i32 0, i32 0
store i8* %57, i8** %61
%62 = load %struct.sockaddr_tipc*, %struct.sockaddr_tipc** %5
%63 = ptrtoint %struct.sockaddr_tipc* %62 to i64
%64 = load i64*, i64** %3
store i64 %63, i64* %64
%65 = load i64*, i64** %4
store i64 88, i64* %65
br label %66
66: ; preds = %10, %9
ret void
}

LLVM IR (-O2):
%struct.sockaddr_tipc = type { %struct.TYPE_10__, i8*, i8*, i32 }
%struct.TYPE_10__ = type { %struct.TYPE_9__, %struct.TYPE_7__, %struct.TYPE_6__ }
%struct.TYPE_9__ = type { i8*, %struct.TYPE_8__ }
%struct.TYPE_8__ = type { i8*, i8* }
%struct.TYPE_7__ = type { i8*, i8*, i8* }
%struct.TYPE_6__ = type { i8*, i8* }
@AF_TIPC = global i32 0
define void @gen_tipc(i64* nocapture writeonly %0, i64* nocapture writeonly %1) {
%3 = tail call %struct.sockaddr_tipc* @malloc(i32 88)
%4 = icmp eq %struct.sockaddr_tipc* %3, null
br i1 %4, label %29, label %5
5: ; preds = %2
%6 = load i32, i32* @AF_TIPC
%7 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 3
store i32 %6, i32* %7
%8 = tail call i8* (...) @rand()
%9 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 2
store i8* %8, i8** %9
%10 = tail call i8* (...) @rand()
%11 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 1
store i8* %10, i8** %11
%12 = tail call i8* (...) @rand()
%13 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 0, i32 2, i32 1
store i8* %12, i8** %13
%14 = tail call i8* (...) @rand()
%15 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 0, i32 2, i32 0
store i8* %14, i8** %15
%16 = tail call i8* (...) @rand()
%17 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 0, i32 1, i32 2
store i8* %16, i8** %17
%18 = tail call i8* (...) @rand()
%19 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 0, i32 1, i32 1
store i8* %18, i8** %19
%20 = tail call i8* (...) @rand()
%21 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 0, i32 1, i32 0
store i8* %20, i8** %21
%22 = tail call i8* (...) @rand()
%23 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 0, i32 0, i32 1, i32 1
store i8* %22, i8** %23
%24 = tail call i8* (...) @rand()
%25 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 0, i32 0, i32 1, i32 0
store i8* %24, i8** %25
%26 = tail call i8* (...) @rand()
%27 = getelementptr inbounds %struct.sockaddr_tipc, %struct.sockaddr_tipc* %3, i64 0, i32 0, i32 0, i32 0
store i8* %26, i8** %27
%28 = ptrtoint %struct.sockaddr_tipc* %3 to i64
store i64 %28, i64* %0
store i64 88, i64* %1
br label %29
29: ; preds = %2, %5
ret void
}