#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*/ u1db__bin_to_hex(unsigned char *, int, char *);
int /*<<< orphan*/ u1db__random_bytes(unsigned char *, int);
int u1db__generate_hex_uuid(char *uuid) {
  unsigned char buf[16] = {0};
  u1db__random_bytes(buf, 16);
  buf[6] = (buf[6] & 0x0F) | 0x40;
  buf[8] = (buf[8] & 0x3F) | 0x80;
  u1db__bin_to_hex(buf, 16, uuid);
  return 0;
}


x86 assembly (clang, -O0):
<u1db__generate_hex_uuid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
lea    -0x20(%rbp),%rdi
mov    $0x10,%esi
call   1050 <u1db__random_bytes@plt>
movzbl -0x1a(%rbp),%eax
and    $0xf,%eax
or     $0x40,%eax
mov    %al,-0x1a(%rbp)
movzbl -0x18(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x10,%esi
call   1040 <u1db__bin_to_hex@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<u1db__generate_hex_uuid>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x10,%esi
call   1040 <u1db__random_bytes@plt>
mov    0x6(%rsp),%al
mov    0x8(%rsp),%cl
and    $0xf,%al
or     $0x40,%al
mov    %al,0x6(%rsp)
and    $0x3f,%cl
or     $0x80,%cl
mov    %cl,0x8(%rsp)
mov    %r14,%rdi
mov    $0x10,%esi
mov    %rbx,%rdx
call   1030 <u1db__bin_to_hex@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @u1db__generate_hex_uuid(i8* %0) {
%2 = alloca i8*
%3 = alloca [16 x i8]
store i8* %0, i8** %2
%4 = bitcast [16 x i8]* %3 to i8*
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%6 = call i32 @u1db__random_bytes(i8* %5, i32 16)
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 6
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = and i32 %9, 15
%11 = or i32 %10, 64
%12 = trunc i32 %11 to i8
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 6
store i8 %12, i8* %13
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 8
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = and i32 %16, 63
%18 = or i32 %17, 128
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 8
store i8 %19, i8* %20
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%22 = load i8*, i8** %2
%23 = call i32 @u1db__bin_to_hex(i8* %21, i32 16, i8* %22)
ret i32 0
}

LLVM IR (-O2):
define i32 @u1db__generate_hex_uuid(i8* %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = call i32 @u1db__random_bytes(i8* %3, i32 16)
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 6
%6 = load i8, i8* %5
%7 = and i8 %6, 15
%8 = or i8 %7, 64
store i8 %8, i8* %5
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 8
%10 = load i8, i8* %9
%11 = and i8 %10, 63
%12 = or i8 %11, -128
store i8 %12, i8* %9
%13 = call i32 @u1db__bin_to_hex(i8* %3, i32 16, i8* %0)
ret i32 0
}