#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*/ free(unsigned char *);
unsigned char *generate_bytestream(int);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char, unsigned char,
                           unsigned char, unsigned char, unsigned char,
                           unsigned char, unsigned char, unsigned char,
                           unsigned char, unsigned char, unsigned char,
                           unsigned char, unsigned char, unsigned char,
                           unsigned char, unsigned char);
char *generate_uuid() {
  unsigned char *stream = generate_bytestream(16);
  stream[6] = 0x40 | (stream[6] & 0xf);
  stream[8] = 0x80 | (stream[8] & 0x3f);
  char *uuid = malloc(sizeof(char) * 37);
  sprintf(
      uuid,
      "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
      stream[0], stream[1], stream[2], stream[3], stream[4], stream[5],
      stream[6], stream[7], stream[8], stream[9], stream[10], stream[11],
      stream[12], stream[13], stream[14], stream[15]);
  free(stream);
  uuid[36] = '\0';
  return uuid;
}


x86 assembly (clang, -O0):
<generate_uuid>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    $0x10,%edi
call   1060 <generate_bytestream@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movzbl 0x6(%rax),%eax
and    $0xf,%eax
or     $0x40,%eax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x30(%rbp),%rax
movzbl 0x8(%rax),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %cl,0x8(%rax)
mov    $0x25,%edi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%dl
mov    -0x30(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x30(%rbp),%rax
mov    0x2(%rax),%r8b
mov    -0x30(%rbp),%rax
mov    0x3(%rax),%r9b
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%al
mov    -0x30(%rbp),%rsi
mov    0x5(%rsi),%sil
mov    %sil,-0x43(%rbp)
mov    -0x30(%rbp),%rsi
mov    0x6(%rsi),%sil
mov    %sil,-0x42(%rbp)
mov    -0x30(%rbp),%rsi
mov    0x7(%rsi),%sil
mov    %sil,-0x41(%rbp)
mov    -0x30(%rbp),%rsi
mov    0x8(%rsi),%r13b
mov    -0x30(%rbp),%rsi
mov    0x9(%rsi),%r12b
mov    -0x30(%rbp),%rsi
mov    0xa(%rsi),%r15b
mov    -0x30(%rbp),%rsi
mov    0xb(%rsi),%r14b
mov    -0x30(%rbp),%rsi
mov    0xc(%rsi),%bl
mov    -0x30(%rbp),%rsi
mov    0xd(%rsi),%r11b
mov    -0x30(%rbp),%rsi
mov    0xe(%rsi),%r10b
mov    -0x30(%rbp),%rsi
mov    %rsi,-0x40(%rbp)
lea    0xdce(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %al,%eax
mov    %eax,(%rsp)
mov    -0x43(%rbp),%al
movzbl %al,%eax
mov    %eax,0x8(%rsp)
mov    -0x42(%rbp),%al
movzbl %al,%eax
mov    %eax,0x10(%rsp)
mov    -0x41(%rbp),%al
movzbl %al,%eax
mov    %eax,0x18(%rsp)
mov    -0x40(%rbp),%rax
movzbl %r13b,%r13d
mov    %r13d,0x20(%rsp)
movzbl %r12b,%r12d
mov    %r12d,0x28(%rsp)
movzbl %r15b,%r15d
mov    %r15d,0x30(%rsp)
movzbl %r14b,%r14d
mov    %r14d,0x38(%rsp)
movzbl %bl,%ebx
mov    %ebx,0x40(%rsp)
movzbl %r11b,%r11d
mov    %r11d,0x48(%rsp)
movzbl %r10b,%r10d
mov    %r10d,0x50(%rsp)
movzbl 0xf(%rax),%eax
mov    %eax,0x58(%rsp)
call   1050 <sprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
movb   $0x0,0x24(%rax)
mov    -0x38(%rbp),%rax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_uuid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x10,%edi
call   1060 <generate_bytestream@plt>
mov    %rax,%rbx
mov    0x6(%rax),%bpl
mov    0x8(%rax),%r12b
and    $0xf,%bpl
or     $0x40,%bpl
mov    %bpl,0x6(%rax)
and    $0x3f,%r12b
or     $0x80,%r12b
mov    %r12b,0x8(%rax)
mov    $0x25,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
movzbl (%rbx),%edx
movzbl 0x1(%rbx),%ecx
movzbl 0x2(%rbx),%r8d
movzbl 0x3(%rbx),%r9d
movzbl 0x4(%rbx),%eax
mov    %rax,0x20(%rsp)
movzbl 0x5(%rbx),%eax
mov    %rax,0x18(%rsp)
movzbl 0x7(%rbx),%eax
mov    %rax,0x10(%rsp)
movzbl 0x9(%rbx),%eax
mov    %rax,0x8(%rsp)
movzbl 0xa(%rbx),%eax
mov    %rax,(%rsp)
movzbl 0xb(%rbx),%r11d
movzbl 0xc(%rbx),%r15d
movzbl 0xd(%rbx),%r13d
movzbl 0xe(%rbx),%eax
movzbl 0xf(%rbx),%r10d
movzbl %r12b,%r12d
movzbl %bpl,%ebp
lea    0xe14(%rip),%rsi
mov    %r14,%rdi
push   %r10
push   %rax
push   %r13
push   %r15
push   %r11
push   0x28(%rsp)
push   0x38(%rsp)
push   %r12
push   0x50(%rsp)
push   %rbp
push   0x68(%rsp)
push   0x78(%rsp)
call   1050 <sprintf@plt>
add    $0x60,%rsp
mov    %rbx,%rdi
call   1030 <free@plt>
movb   $0x0,0x24(%r14)
mov    %r14,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [69 x i8] c"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\00"
define i8* @generate_uuid() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i8* @generate_bytestream(i32 16)
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = getelementptr inbounds i8, i8* %4, i64 6
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = and i32 %7, 15
%9 = or i32 64, %8
%10 = trunc i32 %9 to i8
%11 = load i8*, i8** %1
%12 = getelementptr inbounds i8, i8* %11, i64 6
store i8 %10, i8* %12
%13 = load i8*, i8** %1
%14 = getelementptr inbounds i8, i8* %13, i64 8
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = and i32 %16, 63
%18 = or i32 128, %17
%19 = trunc i32 %18 to i8
%20 = load i8*, i8** %1
%21 = getelementptr inbounds i8, i8* %20, i64 8
store i8 %19, i8* %21
%22 = call i8* @malloc(i32 37)
store i8* %22, i8** %2
%23 = load i8*, i8** %2
%24 = load i8*, i8** %1
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = load i8*, i8** %1
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = load i8*, i8** %1
%31 = getelementptr inbounds i8, i8* %30, i64 2
%32 = load i8, i8* %31
%33 = load i8*, i8** %1
%34 = getelementptr inbounds i8, i8* %33, i64 3
%35 = load i8, i8* %34
%36 = load i8*, i8** %1
%37 = getelementptr inbounds i8, i8* %36, i64 4
%38 = load i8, i8* %37
%39 = load i8*, i8** %1
%40 = getelementptr inbounds i8, i8* %39, i64 5
%41 = load i8, i8* %40
%42 = load i8*, i8** %1
%43 = getelementptr inbounds i8, i8* %42, i64 6
%44 = load i8, i8* %43
%45 = load i8*, i8** %1
%46 = getelementptr inbounds i8, i8* %45, i64 7
%47 = load i8, i8* %46
%48 = load i8*, i8** %1
%49 = getelementptr inbounds i8, i8* %48, i64 8
%50 = load i8, i8* %49
%51 = load i8*, i8** %1
%52 = getelementptr inbounds i8, i8* %51, i64 9
%53 = load i8, i8* %52
%54 = load i8*, i8** %1
%55 = getelementptr inbounds i8, i8* %54, i64 10
%56 = load i8, i8* %55
%57 = load i8*, i8** %1
%58 = getelementptr inbounds i8, i8* %57, i64 11
%59 = load i8, i8* %58
%60 = load i8*, i8** %1
%61 = getelementptr inbounds i8, i8* %60, i64 12
%62 = load i8, i8* %61
%63 = load i8*, i8** %1
%64 = getelementptr inbounds i8, i8* %63, i64 13
%65 = load i8, i8* %64
%66 = load i8*, i8** %1
%67 = getelementptr inbounds i8, i8* %66, i64 14
%68 = load i8, i8* %67
%69 = load i8*, i8** %1
%70 = getelementptr inbounds i8, i8* %69, i64 15
%71 = load i8, i8* %70
%72 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i8 zeroext %26, i8 zeroext %29, i8 zeroext %32, i8 zeroext %35, i8 zeroext %38, i8 zeroext %41, i8 zeroext %44, i8 zeroext %47, i8 zeroext %50, i8 zeroext %53, i8 zeroext %56, i8 zeroext %59, i8 zeroext %62, i8 zeroext %65, i8 zeroext %68, i8 zeroext %71)
%73 = load i8*, i8** %1
%74 = call i32 @free(i8* %73)
%75 = load i8*, i8** %2
%76 = getelementptr inbounds i8, i8* %75, i64 36
store i8 0, i8* %76
%77 = load i8*, i8** %2
ret i8* %77
}

LLVM IR (-O2):
@.str = [69 x i8] c"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\00"
define noalias i8* @generate_uuid() {
%1 = tail call i8* @generate_bytestream(i32 16)
%2 = getelementptr inbounds i8, i8* %1, i64 6
%3 = load i8, i8* %2
%4 = and i8 %3, 15
%5 = or i8 %4, 64
store i8 %5, i8* %2
%6 = getelementptr inbounds i8, i8* %1, i64 8
%7 = load i8, i8* %6
%8 = and i8 %7, 63
%9 = or i8 %8, -128
store i8 %9, i8* %6
%10 = tail call dereferenceable_or_null(37) i8* @malloc(i32 37)
%11 = load i8, i8* %1
%12 = getelementptr inbounds i8, i8* %1, i64 1
%13 = load i8, i8* %12
%14 = getelementptr inbounds i8, i8* %1, i64 2
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %1, i64 3
%17 = load i8, i8* %16
%18 = getelementptr inbounds i8, i8* %1, i64 4
%19 = load i8, i8* %18
%20 = getelementptr inbounds i8, i8* %1, i64 5
%21 = load i8, i8* %20
%22 = getelementptr inbounds i8, i8* %1, i64 7
%23 = load i8, i8* %22
%24 = getelementptr inbounds i8, i8* %1, i64 9
%25 = load i8, i8* %24
%26 = getelementptr inbounds i8, i8* %1, i64 10
%27 = load i8, i8* %26
%28 = getelementptr inbounds i8, i8* %1, i64 11
%29 = load i8, i8* %28
%30 = getelementptr inbounds i8, i8* %1, i64 12
%31 = load i8, i8* %30
%32 = getelementptr inbounds i8, i8* %1, i64 13
%33 = load i8, i8* %32
%34 = getelementptr inbounds i8, i8* %1, i64 14
%35 = load i8, i8* %34
%36 = getelementptr inbounds i8, i8* %1, i64 15
%37 = load i8, i8* %36
%38 = tail call i32 @sprintf(i8* dereferenceable(1) %10, i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i8 zeroext %11, i8 zeroext %13, i8 zeroext %15, i8 zeroext %17, i8 zeroext %19, i8 zeroext %21, i8 zeroext %5, i8 zeroext %23, i8 zeroext %9, i8 zeroext %25, i8 zeroext %27, i8 zeroext %29, i8 zeroext %31, i8 zeroext %33, i8 zeroext %35, i8 zeroext %37)
%39 = tail call i32 @free(i8* %1)
%40 = getelementptr inbounds i8, i8* %10, i64 36
store i8 0, i8* %40
ret i8* %10
}