#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 /*<<< orphan*/ printf(char *);
unsigned long random();
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ wfc_util_atoh(char *, int, unsigned char *, int);
void wfc_util_random_mac(unsigned char *mac_addr) {
  unsigned long int rand_mac;
  if (NULL == mac_addr) {
    printf("wfc_util_random_mac : buffer is NULL");
    printf("\n");
    return;
  }
  srandom(time(NULL));
  rand_mac = random();
  wfc_util_atoh("001122", 6, mac_addr, 3);
  mac_addr[3] = (unsigned char)rand_mac;
  mac_addr[4] = (unsigned char)(rand_mac >> 8);
  mac_addr[5] = (unsigned char)(rand_mac >> 16);
  return;
}


x86 assembly (clang, -O0):
<wfc_util_random_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
jne    1185 <wfc_util_random_mac+0x35>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
jmp    11e9 <wfc_util_random_mac+0x99>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
mov    $0x0,%al
call   1070 <random@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdx
lea    0xe7c(%rip),%rdi
mov    $0x6,%esi
mov    $0x3,%ecx
call   1050 <wfc_util_atoh@plt>
mov    -0x10(%rbp),%rax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x10(%rbp),%rax
shr    $0x8,%rax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x10(%rbp),%rax
shr    $0x10,%rax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x5(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wfc_util_random_mac>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     11b0 <wfc_util_random_mac+0x50>
mov    %rdi,%rbp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1040 <srandom@plt>
xor    %eax,%eax
call   1080 <random@plt>
mov    %rax,%rbx
lea    0xe9b(%rip),%rdi
mov    $0x6,%esi
mov    %rbp,%rdx
mov    $0x3,%ecx
call   1060 <wfc_util_atoh@plt>
mov    %bl,0x3(%rbp)
mov    %bh,0x4(%rbp)
shr    $0x10,%rbx
mov    %bl,0x5(%rbp)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe49(%rip),%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"wfc_util_random_mac : buffer is NULL\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [7 x i8] c"001122\00"
define void @wfc_util_random_mac(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp eq i8* null, %4
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %29
9: ; preds = %1
%10 = call i32 @time(i32* null)
%11 = call i32 @srandom(i32 %10)
%12 = call i64 (...) @random()
store i64 %12, i64* %3
%13 = load i8*, i8** %2
%14 = call i32 @wfc_util_atoh(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6, i8* %13, i32 3)
%15 = load i64, i64* %3
%16 = trunc i64 %15 to i8
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i64 3
store i8 %16, i8* %18
%19 = load i64, i64* %3
%20 = lshr i64 %19, 8
%21 = trunc i64 %20 to i8
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 4
store i8 %21, i8* %23
%24 = load i64, i64* %3
%25 = lshr i64 %24, 16
%26 = trunc i64 %25 to i8
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i64 5
store i8 %26, i8* %28
br label %29
29: ; preds = %9, %6
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"wfc_util_random_mac : buffer is NULL\00"
@.str.2 = [7 x i8] c"001122\00"
define void @wfc_util_random_mac(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @putchar(i32 10)
br label %19
6: ; preds = %1
%7 = tail call i32 @time(i32* null)
%8 = tail call i32 @srandom(i32 %7)
%9 = tail call i64 (...) @random()
%10 = tail call i32 @wfc_util_atoh(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6, i8* %0, i32 3)
%11 = trunc i64 %9 to i8
%12 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %11, i8* %12
%13 = lshr i64 %9, 8
%14 = trunc i64 %13 to i8
%15 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %14, i8* %15
%16 = lshr i64 %9, 16
%17 = trunc i64 %16 to i8
%18 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %17, i8* %18
br label %19
19: ; preds = %6, %3
ret void
}