#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 */

/* Variables and functions */
int rand();
int /*<<< orphan*/ sprintf(char *, char *, int);
char *mac_rand() {
  char addr_part[3] = {0};
  static char addr[18] = {0};
  int i = 0;
  while (i < 14) {
    sprintf(addr_part, "%02X", (rand() % 254));
    addr[i++] = addr_part[0];
    addr[i++] = addr_part[1];
    addr[i++] = ':';
  }
  sprintf(addr_part, "%02X", (rand() % 254));
  addr[i++] = addr_part[0];
  addr[i++] = addr_part[1];
  return (addr);
}


x86 assembly (clang, -O0):
<mac_rand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x3(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <memset@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xe,-0x8(%rbp)
jge    11d4 <mac_rand+0xa4>
lea    -0x3(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    -0x10(%rbp),%rdi
mov    $0xfe,%ecx
cltd
idiv   %ecx
lea    0xe85(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x3(%rbp),%dl
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
movslq %eax,%rcx
lea    0x2eb8(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x2(%rbp),%dl
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
movslq %eax,%rcx
lea    0x2e9d(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
movslq %eax,%rcx
lea    0x2e85(%rip),%rax
movb   $0x3a,(%rax,%rcx,1)
jmp    114f <mac_rand+0x1f>
lea    -0x3(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    -0x18(%rbp),%rdi
mov    $0xfe,%ecx
cltd
idiv   %ecx
lea    0xe0a(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x3(%rbp),%dl
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
movslq %eax,%rcx
lea    0x2e3d(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x2(%rbp),%dl
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
movslq %eax,%rcx
lea    0x2e22(%rip),%rax
mov    %dl,(%rax,%rcx,1)
lea    0x2e18(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mac_rand>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xe(%rsp)
movw   $0x0,0xc(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0xffffffff81020409,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x7,%ecx
add    %edx,%ecx
mov    %ecx,%esi
shl    $0x8,%esi
mov    %ecx,%edx
sub    %esi,%edx
add    %ecx,%edx
add    %eax,%edx
lea    0xe97(%rip),%r14
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <sprintf@plt>
movzwl 0xc(%rsp),%eax
mov    %ax,0x2ebb(%rip)
lea    0x2eb4(%rip),%r15
movb   $0x3a,0x2eaf(%rip)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0xffffffff81020409,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x7,%ecx
add    %edx,%ecx
mov    %ecx,%esi
shl    $0x8,%esi
mov    %ecx,%edx
sub    %esi,%edx
add    %ecx,%edx
add    %eax,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <sprintf@plt>
movzwl 0xc(%rsp),%eax
mov    %ax,0x2e6c(%rip)
movb   $0x3a,0x2e67(%rip)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0xffffffff81020409,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x7,%ecx
add    %edx,%ecx
mov    %ecx,%esi
shl    $0x8,%esi
mov    %ecx,%edx
sub    %esi,%edx
add    %ecx,%edx
add    %eax,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <sprintf@plt>
movzwl 0xc(%rsp),%eax
mov    %ax,0x2e24(%rip)
movb   $0x3a,0x2e1f(%rip)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0xffffffff81020409,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x7,%ecx
add    %edx,%ecx
mov    %ecx,%esi
shl    $0x8,%esi
mov    %ecx,%edx
sub    %esi,%edx
add    %ecx,%edx
add    %eax,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <sprintf@plt>
movzwl 0xc(%rsp),%eax
mov    %ax,0x2ddc(%rip)
movb   $0x3a,0x2dd7(%rip)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0xffffffff81020409,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x7,%ecx
add    %edx,%ecx
mov    %ecx,%esi
shl    $0x8,%esi
mov    %ecx,%edx
sub    %esi,%edx
add    %ecx,%edx
add    %eax,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <sprintf@plt>
movzwl 0xc(%rsp),%eax
mov    %ax,0x2d94(%rip)
movb   $0x3a,0x2d8f(%rip)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0xffffffff81020409,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x7,%ecx
add    %edx,%ecx
mov    %ecx,%esi
shl    $0x8,%esi
mov    %ecx,%edx
sub    %esi,%edx
add    %ecx,%edx
add    %eax,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <sprintf@plt>
movzwl 0xc(%rsp),%eax
mov    %ax,0x2d4c(%rip)
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@mac_rand.addr = internal global [18 x i8] zeroinitializer
@.str = [5 x i8] c"%02X\00"
define i8* @mac_rand() {
%1 = alloca [3 x i8]
%2 = alloca i32
%3 = bitcast [3 x i8]* %1 to i8*
store i32 0, i32* %2
br label %4
4: ; preds = %7, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 14
br i1 %6, label %7, label %28
7: ; preds = %4
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 254
%11 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%13 = load i8, i8* %12
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds [18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 %16
store i8 %13, i8* %17
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 1
%19 = load i8, i8* %18
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds [18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 %22
store i8 %19, i8* %23
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
%26 = sext i32 %24 to i64
%27 = getelementptr inbounds [18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 %26
store i8 58, i8* %27
br label %4
28: ; preds = %4
%29 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%30 = call i32 (...) @rand()
%31 = srem i32 %30, 254
%32 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%34 = load i8, i8* %33
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
store i32 %36, i32* %2
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds [18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 %37
store i8 %34, i8* %38
%39 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 1
%40 = load i8, i8* %39
%41 = load i32, i32* %2
%42 = add nsw i32 %41, 1
store i32 %42, i32* %2
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds [18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 %43
store i8 %40, i8* %44
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 0)
}

LLVM IR (-O2):
@mac_rand.addr = internal global [18 x i8] zeroinitializer
@.str = [5 x i8] c"%02X\00"
define i8* @mac_rand() {
%1 = alloca [3 x i8]
%2 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 1
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 254
%6 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i8, i8* %2
store i8 %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 0)
%8 = load i8, i8* %3
store i8 %8, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 1)
store i8 58, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 2)
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 254
%11 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i8, i8* %2
store i8 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 3)
%13 = load i8, i8* %3
store i8 %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 4)
store i8 58, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 5)
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 254
%16 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i8, i8* %2
store i8 %17, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 6)
%18 = load i8, i8* %3
store i8 %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 7)
store i8 58, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 8)
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 254
%21 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i8, i8* %2
store i8 %22, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 9)
%23 = load i8, i8* %3
store i8 %23, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 10)
store i8 58, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 11)
%24 = tail call i32 (...) @rand()
%25 = srem i32 %24, 254
%26 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i8, i8* %2
store i8 %27, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 12)
%28 = load i8, i8* %3
store i8 %28, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 13)
store i8 58, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 14)
%29 = tail call i32 (...) @rand()
%30 = srem i32 %29, 254
%31 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i8, i8* %2
store i8 %32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 15)
%33 = load i8, i8* %3
store i8 %33, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 16)
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_rand.addr, i64 0, i64 0)
}