#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 random_generate();
void mk_guid(uint8_t *guid) {
  int n;
  for (n = 0; n < 16; n++)
    guid[n] = random_generate();
  guid[6] &= 0x0F;
  guid[6] |= 0x40;
  guid[8] &= 0x3F;
  guid[8] |= 0x80;
}


x86 assembly (clang, -O0):
<mk_guid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    114f <mk_guid+0x3f>
mov    $0x0,%al
call   1030 <random_generate@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    1123 <mk_guid+0x13>
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):
<mk_guid>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x4(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x8(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0xc(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x10(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x14(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x18(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x1c(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x20(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x24(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x28(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x2c(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x30(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x34(%rbx)
xor    %eax,%eax
call   1030 <random_generate@plt>
mov    %eax,0x38(%rbx)
xor    %eax,%eax
call   1030 <random_generate@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 @mk_guid(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %4
4: ; preds = %13, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 16
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = call i32 (...) @random_generate()
%9 = load i32*, i32** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %9, i64 %11
store i32 %8, i32* %12
br label %13
13: ; preds = %7
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %4
16: ; preds = %4
%17 = load i32*, i32** %2
%18 = getelementptr inbounds i32, i32* %17, i64 6
%19 = load i32, i32* %18
%20 = and i32 %19, 15
store i32 %20, i32* %18
%21 = load i32*, i32** %2
%22 = getelementptr inbounds i32, i32* %21, i64 6
%23 = load i32, i32* %22
%24 = or i32 %23, 64
store i32 %24, i32* %22
%25 = load i32*, i32** %2
%26 = getelementptr inbounds i32, i32* %25, i64 8
%27 = load i32, i32* %26
%28 = and i32 %27, 63
store i32 %28, i32* %26
%29 = load i32*, i32** %2
%30 = getelementptr inbounds i32, i32* %29, i64 8
%31 = load i32, i32* %30
%32 = or i32 %31, 128
store i32 %32, i32* %30
ret void
}

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