#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 *lij_id;
  void *lij_type;
  void **pub;
  void **prv;
};
struct sockaddr_atmsvc {
  TYPE_1__ sas_addr;
  int /*<<< orphan*/ sas_family;
};

/* Variables and functions */
unsigned int ATM_E164_LEN;
unsigned int ATM_ESA_LEN;
int /*<<< orphan*/ PF_ATMSVC;
struct sockaddr_atmsvc *malloc(int);
void *rand();
void gen_atmsvc(unsigned long *addr, unsigned long *addrlen) {
  struct sockaddr_atmsvc *atmsvc;
  unsigned int i;
  atmsvc = malloc(sizeof(struct sockaddr_atmsvc));
  if (atmsvc == NULL)
    return;
  atmsvc->sas_family = PF_ATMSVC;
  for (i = 0; i < ATM_ESA_LEN; i++)
    atmsvc->sas_addr.prv[i] = rand();
  for (i = 0; i < ATM_E164_LEN; i++)
    atmsvc->sas_addr.pub[i] = rand();
  atmsvc->sas_addr.lij_type = rand();
  atmsvc->sas_addr.lij_id = rand();
  *addr = (unsigned long)atmsvc;
  *addrlen = sizeof(struct sockaddr_atmsvc);
}


x86 assembly (clang, -O0):
<gen_atmsvc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x28,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114e <gen_atmsvc+0x2e>
jmp    1217 <gen_atmsvc+0xf7>
mov    0x2e7b(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x20(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e69(%rip),%rcx
cmp    (%rcx),%eax
jae    119e <gen_atmsvc+0x7e>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    -0x1c(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1165 <gen_atmsvc+0x45>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e41(%rip),%rcx
cmp    (%rcx),%eax
jae    11de <gen_atmsvc+0xbe>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x1c(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a5 <gen_atmsvc+0x85>
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   $0x28,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_atmsvc>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x28,%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     11dc <gen_atmsvc+0xbc>
mov    %rax,%r13
mov    0x2e84(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%r13)
mov    0x2e7f(%rip),%r12
cmpl   $0x0,(%r12)
je     118c <gen_atmsvc+0x6c>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <rand@plt>
mov    0x18(%r13),%rcx
mov    %rax,(%rcx,%rbx,8)
add    $0x1,%rbx
mov    (%r12),%eax
cmp    %rax,%rbx
jb     1170 <gen_atmsvc+0x50>
mov    0x2e5d(%rip),%r12
cmpl   $0x0,(%r12)
je     11bc <gen_atmsvc+0x9c>
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <rand@plt>
mov    0x10(%r13),%rcx
mov    %rax,(%rcx,%rbx,8)
add    $0x1,%rbx
mov    (%r12),%eax
cmp    %rax,%rbx
jb     11a0 <gen_atmsvc+0x80>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x8(%r13)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x0(%r13)
mov    %r13,(%r15)
movq   $0x28,(%r14)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.sockaddr_atmsvc = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i8*, i8*, i8**, i8** }
@PF_ATMSVC = global i32 0
@ATM_ESA_LEN = global i32 0
@ATM_E164_LEN = global i32 0
define void @gen_atmsvc(i64* nocapture writeonly %0, i64* nocapture writeonly %1) {
%3 = tail call %struct.sockaddr_atmsvc* @malloc(i32 40)
%4 = icmp eq %struct.sockaddr_atmsvc* %3, null
br i1 %4, label %41, label %5
5: ; preds = %2
%6 = load i32, i32* @PF_ATMSVC
%7 = getelementptr inbounds %struct.sockaddr_atmsvc, %struct.sockaddr_atmsvc* %3, i64 0, i32 1
store i32 %6, i32* %7
%8 = load i32, i32* @ATM_ESA_LEN
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = getelementptr inbounds %struct.sockaddr_atmsvc, %struct.sockaddr_atmsvc* %3, i64 0, i32 0, i32 3
br label %17
12: ; preds = %17, %5
%13 = load i32, i32* @ATM_E164_LEN
%14 = icmp eq i32 %13, 0
br i1 %14, label %35, label %15
15: ; preds = %12
%16 = getelementptr inbounds %struct.sockaddr_atmsvc, %struct.sockaddr_atmsvc* %3, i64 0, i32 0, i32 2
br label %26
17: ; preds = %10, %17
%18 = phi i64 [ 0, %10 ], [ %22, %17 ]
%19 = tail call i8* (...) @rand()
%20 = load i8**, i8*** %11
%21 = getelementptr inbounds i8*, i8** %20, i64 %18
store i8* %19, i8** %21
%22 = add nuw nsw i64 %18, 1
%23 = load i32, i32* @ATM_ESA_LEN
%24 = zext i32 %23 to i64
%25 = icmp ult i64 %22, %24
br i1 %25, label %17, label %12
26: ; preds = %15, %26
%27 = phi i64 [ 0, %15 ], [ %31, %26 ]
%28 = tail call i8* (...) @rand()
%29 = load i8**, i8*** %16
%30 = getelementptr inbounds i8*, i8** %29, i64 %27
store i8* %28, i8** %30
%31 = add nuw nsw i64 %27, 1
%32 = load i32, i32* @ATM_E164_LEN
%33 = zext i32 %32 to i64
%34 = icmp ult i64 %31, %33
br i1 %34, label %26, label %35
35: ; preds = %26, %12
%36 = tail call i8* (...) @rand()
%37 = getelementptr inbounds %struct.sockaddr_atmsvc, %struct.sockaddr_atmsvc* %3, i64 0, i32 0, i32 1
store i8* %36, i8** %37
%38 = tail call i8* (...) @rand()
%39 = getelementptr inbounds %struct.sockaddr_atmsvc, %struct.sockaddr_atmsvc* %3, i64 0, i32 0, i32 0
store i8* %38, i8** %39
%40 = ptrtoint %struct.sockaddr_atmsvc* %3 to i64
store i64 %40, i64* %0
store i64 40, i64* %1
br label %41
41: ; preds = %2, %35
ret void
}