#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_llc {
  void **sllc_mac;
  void *sllc_sap;
  void *sllc_ua;
  void *sllc_xid;
  void *sllc_test;
  int /*<<< orphan*/ sllc_arphrd;
  int /*<<< orphan*/ sllc_family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_LLC;
int /*<<< orphan*/ ARPHRD_ETHER;
unsigned int IFHWADDRLEN;
struct sockaddr_llc *malloc(int);
void *rand();
void gen_llc(unsigned long *addr, unsigned long *addrlen) {
  struct sockaddr_llc *llc;
  unsigned int i;
  llc = malloc(sizeof(struct sockaddr_llc));
  if (llc == NULL)
    return;
  llc->sllc_family = AF_LLC;
  llc->sllc_arphrd = ARPHRD_ETHER;
  llc->sllc_test = rand();
  llc->sllc_xid = rand();
  llc->sllc_ua = rand();
  llc->sllc_sap = rand();
  for (i = 0; i < IFHWADDRLEN; i++)
    llc->sllc_mac[i] = rand();
  *addr = (unsigned long)llc;
  *addrlen = sizeof(struct sockaddr_llc);
}


x86 assembly (clang, -O0):
<gen_llc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x30,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114e <gen_llc+0x2e>
jmp    120b <gen_llc+0xeb>
mov    0x2e93(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x2c(%rax)
mov    0x2e7b(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,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)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e01(%rip),%rcx
cmp    (%rcx),%eax
jae    11f5 <gen_llc+0xd5>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x1c(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bd <gen_llc+0x9d>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x30,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_llc>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x30,%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     11c6 <gen_llc+0xa6>
mov    %rax,%r13
mov    0x2e9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2c(%r13)
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%r13)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x20(%r13)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x18(%r13)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x10(%r13)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,0x8(%r13)
mov    0x2e36(%rip),%r12
cmpl   $0x0,(%r12)
je     11bc <gen_llc+0x9c>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
mov    0x0(%r13),%rcx
mov    %rax,(%rcx,%rbx,8)
add    $0x1,%rbx
mov    (%r12),%eax
cmp    %rax,%rbx
jb     11a0 <gen_llc+0x80>
mov    %r13,(%r15)
movq   $0x30,(%r14)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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