#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 /*<<< orphan*/ h2o_hex_encode(char *, int *, int);
void format_uuid_rfc4122(char *dst, uint8_t *octets, uint8_t version) {
  octets[8] = (octets[8] & 0x3f) | 0x80;
  octets[6] = (octets[6] & 0x0f) | (version << 4);
  size_t pos = 0;
  do {
    h2o_hex_encode(&dst[pos], &octets[0], 3 - 0 + 1);
    pos += (3 - 0 + 1) * 2;
  } while (0);
  dst[pos++] = '-';
  do {
    h2o_hex_encode(&dst[pos], &octets[4], 5 - 4 + 1);
    pos += (5 - 4 + 1) * 2;
  } while (0);
  dst[pos++] = '-';
  do {
    h2o_hex_encode(&dst[pos], &octets[6], 7 - 6 + 1);
    pos += (7 - 6 + 1) * 2;
  } while (0);
  dst[pos++] = '-';
  do {
    h2o_hex_encode(&dst[pos], &octets[8], 8 - 8 + 1);
    pos += (8 - 8 + 1) * 2;
  } while (0);
  do {
    h2o_hex_encode(&dst[pos], &octets[9], 9 - 9 + 1);
    pos += (9 - 9 + 1) * 2;
  } while (0);
  dst[pos++] = '-';
  do {
    h2o_hex_encode(&dst[pos], &octets[10], 15 - 10 + 1);
    pos += (15 - 10 + 1) * 2;
  } while (0);
}


x86 assembly (clang, -O0):
<format_uuid_rfc4122>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%ecx
and    $0x3f,%ecx
or     $0x80,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%ecx
and    $0xf,%ecx
mov    -0x14(%rbp),%eax
shl    $0x4,%eax
or     %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x18(%rax)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1030 <h2o_hex_encode@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
movb   $0x2d,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
mov    $0x2,%edx
call   1030 <h2o_hex_encode@plt>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
movb   $0x2d,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x18,%rsi
mov    $0x2,%edx
call   1030 <h2o_hex_encode@plt>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
movb   $0x2d,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x20,%rsi
mov    $0x1,%edx
call   1030 <h2o_hex_encode@plt>
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    1239 <format_uuid_rfc4122+0x129>
mov    -0x8(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x24,%rsi
mov    $0x1,%edx
call   1030 <h2o_hex_encode@plt>
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
movb   $0x2d,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x28,%rsi
mov    $0x6,%edx
call   1030 <h2o_hex_encode@plt>
mov    -0x20(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x20(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_uuid_rfc4122>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x20(%rsi),%r15
mov    0x18(%rsi),%eax
mov    0x20(%rsi),%ecx
and    $0x3f,%ecx
or     $0x80,%ecx
mov    %ecx,0x20(%rsi)
lea    0x18(%rsi),%r12
and    $0xf,%eax
shl    $0x4,%edx
or     %eax,%edx
mov    %edx,0x18(%rsi)
mov    $0x4,%edx
call   1030 <h2o_hex_encode@plt>
movb   $0x2d,0x8(%rbx)
lea    0x9(%rbx),%rdi
lea    0x10(%r14),%rsi
mov    $0x2,%edx
call   1030 <h2o_hex_encode@plt>
movb   $0x2d,0xd(%rbx)
lea    0xe(%rbx),%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1030 <h2o_hex_encode@plt>
movb   $0x2d,0x12(%rbx)
lea    0x13(%rbx),%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <h2o_hex_encode@plt>
lea    0x15(%rbx),%rdi
lea    0x24(%r14),%rsi
mov    $0x1,%edx
call   1030 <h2o_hex_encode@plt>
movb   $0x2d,0x17(%rbx)
add    $0x18,%rbx
add    $0x28,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <h2o_hex_encode@plt>

LLVM IR (-O0):
define void @format_uuid_rfc4122(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i64
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%8 = load i32*, i32** %5
%9 = getelementptr inbounds i32, i32* %8, i64 8
%10 = load i32, i32* %9
%11 = and i32 %10, 63
%12 = or i32 %11, 128
%13 = load i32*, i32** %5
%14 = getelementptr inbounds i32, i32* %13, i64 8
store i32 %12, i32* %14
%15 = load i32*, i32** %5
%16 = getelementptr inbounds i32, i32* %15, i64 6
%17 = load i32, i32* %16
%18 = and i32 %17, 15
%19 = load i32, i32* %6
%20 = shl i32 %19, 4
%21 = or i32 %18, %20
%22 = load i32*, i32** %5
%23 = getelementptr inbounds i32, i32* %22, i64 6
store i32 %21, i32* %23
store i64 0, i64* %7
br label %24
24: ; preds = %3
%25 = load i8*, i8** %4
%26 = load i64, i64* %7
%27 = getelementptr inbounds i8, i8* %25, i64 %26
%28 = load i32*, i32** %5
%29 = getelementptr inbounds i32, i32* %28, i64 0
%30 = call i32 @h2o_hex_encode(i8* %27, i32* %29, i32 4)
%31 = load i64, i64* %7
%32 = add i64 %31, 8
store i64 %32, i64* %7
br label %33
33: ; preds = %24
%34 = load i8*, i8** %4
%35 = load i64, i64* %7
%36 = add i64 %35, 1
store i64 %36, i64* %7
%37 = getelementptr inbounds i8, i8* %34, i64 %35
store i8 45, i8* %37
br label %38
38: ; preds = %33
%39 = load i8*, i8** %4
%40 = load i64, i64* %7
%41 = getelementptr inbounds i8, i8* %39, i64 %40
%42 = load i32*, i32** %5
%43 = getelementptr inbounds i32, i32* %42, i64 4
%44 = call i32 @h2o_hex_encode(i8* %41, i32* %43, i32 2)
%45 = load i64, i64* %7
%46 = add i64 %45, 4
store i64 %46, i64* %7
br label %47
47: ; preds = %38
%48 = load i8*, i8** %4
%49 = load i64, i64* %7
%50 = add i64 %49, 1
store i64 %50, i64* %7
%51 = getelementptr inbounds i8, i8* %48, i64 %49
store i8 45, i8* %51
br label %52
52: ; preds = %47
%53 = load i8*, i8** %4
%54 = load i64, i64* %7
%55 = getelementptr inbounds i8, i8* %53, i64 %54
%56 = load i32*, i32** %5
%57 = getelementptr inbounds i32, i32* %56, i64 6
%58 = call i32 @h2o_hex_encode(i8* %55, i32* %57, i32 2)
%59 = load i64, i64* %7
%60 = add i64 %59, 4
store i64 %60, i64* %7
br label %61
61: ; preds = %52
%62 = load i8*, i8** %4
%63 = load i64, i64* %7
%64 = add i64 %63, 1
store i64 %64, i64* %7
%65 = getelementptr inbounds i8, i8* %62, i64 %63
store i8 45, i8* %65
br label %66
66: ; preds = %61
%67 = load i8*, i8** %4
%68 = load i64, i64* %7
%69 = getelementptr inbounds i8, i8* %67, i64 %68
%70 = load i32*, i32** %5
%71 = getelementptr inbounds i32, i32* %70, i64 8
%72 = call i32 @h2o_hex_encode(i8* %69, i32* %71, i32 1)
%73 = load i64, i64* %7
%74 = add i64 %73, 2
store i64 %74, i64* %7
br label %75
75: ; preds = %66
br label %76
76: ; preds = %75
%77 = load i8*, i8** %4
%78 = load i64, i64* %7
%79 = getelementptr inbounds i8, i8* %77, i64 %78
%80 = load i32*, i32** %5
%81 = getelementptr inbounds i32, i32* %80, i64 9
%82 = call i32 @h2o_hex_encode(i8* %79, i32* %81, i32 1)
%83 = load i64, i64* %7
%84 = add i64 %83, 2
store i64 %84, i64* %7
br label %85
85: ; preds = %76
%86 = load i8*, i8** %4
%87 = load i64, i64* %7
%88 = add i64 %87, 1
store i64 %88, i64* %7
%89 = getelementptr inbounds i8, i8* %86, i64 %87
store i8 45, i8* %89
br label %90
90: ; preds = %85
%91 = load i8*, i8** %4
%92 = load i64, i64* %7
%93 = getelementptr inbounds i8, i8* %91, i64 %92
%94 = load i32*, i32** %5
%95 = getelementptr inbounds i32, i32* %94, i64 10
%96 = call i32 @h2o_hex_encode(i8* %93, i32* %95, i32 6)
%97 = load i64, i64* %7
%98 = add i64 %97, 12
store i64 %98, i64* %7
br label %99
99: ; preds = %90
ret void
}

LLVM IR (-O2):
define void @format_uuid_rfc4122(i8* %0, i32* %1, i32 %2) {
%4 = getelementptr inbounds i32, i32* %1, i64 8
%5 = load i32, i32* %4
%6 = and i32 %5, 63
%7 = or i32 %6, 128
store i32 %7, i32* %4
%8 = getelementptr inbounds i32, i32* %1, i64 6
%9 = load i32, i32* %8
%10 = and i32 %9, 15
%11 = shl i32 %2, 4
%12 = or i32 %10, %11
store i32 %12, i32* %8
%13 = tail call i32 @h2o_hex_encode(i8* %0, i32* %1, i32 4)
%14 = getelementptr inbounds i8, i8* %0, i64 8
store i8 45, i8* %14
%15 = getelementptr inbounds i8, i8* %0, i64 9
%16 = getelementptr inbounds i32, i32* %1, i64 4
%17 = tail call i32 @h2o_hex_encode(i8* %15, i32* %16, i32 2)
%18 = getelementptr inbounds i8, i8* %0, i64 13
store i8 45, i8* %18
%19 = getelementptr inbounds i8, i8* %0, i64 14
%20 = tail call i32 @h2o_hex_encode(i8* %19, i32* %8, i32 2)
%21 = getelementptr inbounds i8, i8* %0, i64 18
store i8 45, i8* %21
%22 = getelementptr inbounds i8, i8* %0, i64 19
%23 = tail call i32 @h2o_hex_encode(i8* %22, i32* %4, i32 1)
%24 = getelementptr inbounds i8, i8* %0, i64 21
%25 = getelementptr inbounds i32, i32* %1, i64 9
%26 = tail call i32 @h2o_hex_encode(i8* %24, i32* %25, i32 1)
%27 = getelementptr inbounds i8, i8* %0, i64 23
store i8 45, i8* %27
%28 = getelementptr inbounds i8, i8* %0, i64 24
%29 = getelementptr inbounds i32, i32* %1, i64 10
%30 = tail call i32 @h2o_hex_encode(i8* %28, i32* %29, i32 6)
ret void
}