#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 */
typedef int uint8_t;

/* Variables and functions */
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/);
void mvhd_generate_uuid(uint8_t *uuid) {
  srand((unsigned int)time(0));
  for (int n = 0; n < 16; n++) {
    uuid[n] = rand();
  }
  uuid[6] &= 0x0F;
  uuid[6] |= 0x40;
  uuid[8] &= 0x3F;
  uuid[8] |= 0x80;
}


x86 assembly (clang, -O0):
<mvhd_generate_uuid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    117d <mvhd_generate_uuid+0x4d>
mov    $0x0,%al
call   1050 <rand@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <mvhd_generate_uuid+0x21>
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%ecx
and    $0xf,%ecx
mov    %ecx,0x18(%rax)
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%ecx
or     $0x40,%ecx
mov    %ecx,0x18(%rax)
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%ecx
and    $0x3f,%ecx
mov    %ecx,0x20(%rax)
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%ecx
or     $0x80,%ecx
mov    %ecx,0x20(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mvhd_generate_uuid>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x4(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x8(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0xc(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x10(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x14(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x18(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x1c(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x20(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x24(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x28(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x2c(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x30(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x34(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x38(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,0x3c(%rbx)
mov    0x18(%rbx),%eax
mov    0x20(%rbx),%ecx
and    $0xf,%eax
or     $0x40,%eax
mov    %eax,0x18(%rbx)
and    $0x3f,%ecx
or     $0x80,%ecx
mov    %ecx,0x20(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @mvhd_generate_uuid(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = call i64 @time(i32 0)
%5 = trunc i64 %4 to i32
%6 = call i32 @srand(i32 %5)
store i32 0, i32* %3
br label %7
7: ; preds = %16, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 16
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = call i32 (...) @rand()
%12 = load i32*, i32** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
store i32 %11, i32* %15
br label %16
16: ; preds = %10
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %7
19: ; preds = %7
%20 = load i32*, i32** %2
%21 = getelementptr inbounds i32, i32* %20, i64 6
%22 = load i32, i32* %21
%23 = and i32 %22, 15
store i32 %23, i32* %21
%24 = load i32*, i32** %2
%25 = getelementptr inbounds i32, i32* %24, i64 6
%26 = load i32, i32* %25
%27 = or i32 %26, 64
store i32 %27, i32* %25
%28 = load i32*, i32** %2
%29 = getelementptr inbounds i32, i32* %28, i64 8
%30 = load i32, i32* %29
%31 = and i32 %30, 63
store i32 %31, i32* %29
%32 = load i32*, i32** %2
%33 = getelementptr inbounds i32, i32* %32, i64 8
%34 = load i32, i32* %33
%35 = or i32 %34, 128
store i32 %35, i32* %33
ret void
}

LLVM IR (-O2):
define void @mvhd_generate_uuid(i32* nocapture %0) {
%2 = tail call i64 @time(i32 0)
%3 = trunc i64 %2 to i32
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (...) @rand()
store i32 %5, i32* %0
%6 = tail call i32 (...) @rand()
%7 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %6, i32* %7
%8 = tail call i32 (...) @rand()
%9 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %8, i32* %9
%10 = tail call i32 (...) @rand()
%11 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %10, i32* %11
%12 = tail call i32 (...) @rand()
%13 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %12, i32* %13
%14 = tail call i32 (...) @rand()
%15 = getelementptr inbounds i32, i32* %0, i64 5
store i32 %14, i32* %15
%16 = tail call i32 (...) @rand()
%17 = getelementptr inbounds i32, i32* %0, i64 6
store i32 %16, i32* %17
%18 = tail call i32 (...) @rand()
%19 = getelementptr inbounds i32, i32* %0, i64 7
store i32 %18, i32* %19
%20 = tail call i32 (...) @rand()
%21 = getelementptr inbounds i32, i32* %0, i64 8
store i32 %20, i32* %21
%22 = tail call i32 (...) @rand()
%23 = getelementptr inbounds i32, i32* %0, i64 9
store i32 %22, i32* %23
%24 = tail call i32 (...) @rand()
%25 = getelementptr inbounds i32, i32* %0, i64 10
store i32 %24, i32* %25
%26 = tail call i32 (...) @rand()
%27 = getelementptr inbounds i32, i32* %0, i64 11
store i32 %26, i32* %27
%28 = tail call i32 (...) @rand()
%29 = getelementptr inbounds i32, i32* %0, i64 12
store i32 %28, i32* %29
%30 = tail call i32 (...) @rand()
%31 = getelementptr inbounds i32, i32* %0, i64 13
store i32 %30, i32* %31
%32 = tail call i32 (...) @rand()
%33 = getelementptr inbounds i32, i32* %0, i64 14
store i32 %32, i32* %33
%34 = tail call i32 (...) @rand()
%35 = getelementptr inbounds i32, i32* %0, i64 15
store i32 %34, i32* %35
%36 = load i32, i32* %17
%37 = and i32 %36, 15
%38 = or i32 %37, 64
store i32 %38, i32* %17
%39 = load i32, i32* %21
%40 = and i32 %39, 63
%41 = or i32 %40, 128
store i32 %41, i32* %21
ret void
}