#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*/
snprintf(char *, size_t, char *, unsigned char const, unsigned char const,
         unsigned char const, unsigned char const, unsigned char const,
         unsigned char const, unsigned char const, unsigned char const,
         unsigned char const, unsigned char const, unsigned char const,
         unsigned char const, unsigned char const, unsigned char const,
         unsigned char const, unsigned char const);
int vdp_uuid2str(const unsigned char *p, char *dst, size_t size) {
  if (dst && size > 40) {
    snprintf(dst, size,
             "%02x%02x%02x%02x-%02x%02x-%02x%02x"
             "-%02x%02x-%02x%02x%02x%02x%02x%02x",
             p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10],
             p[11], p[12], p[13], p[14], p[15]);
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<vdp_uuid2str>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdi,-0x38(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %rdx,-0x48(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     126c <vdp_uuid2str+0x15c>
cmpq   $0x28,-0x48(%rbp)
jbe    126c <vdp_uuid2str+0x15c>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    (%rax),%cl
mov    -0x38(%rbp),%rax
mov    0x1(%rax),%r8b
mov    -0x38(%rbp),%rax
mov    0x2(%rax),%r9b
mov    -0x38(%rbp),%rax
mov    0x3(%rax),%al
mov    -0x38(%rbp),%rdx
mov    0x4(%rdx),%dl
mov    %dl,-0x54(%rbp)
mov    -0x38(%rbp),%rdx
mov    0x5(%rdx),%dl
mov    %dl,-0x53(%rbp)
mov    -0x38(%rbp),%rdx
mov    0x6(%rdx),%dl
mov    %dl,-0x52(%rbp)
mov    -0x38(%rbp),%rdx
mov    0x7(%rdx),%dl
mov    %dl,-0x51(%rbp)
mov    -0x38(%rbp),%rdx
mov    0x8(%rdx),%r13b
mov    -0x38(%rbp),%rdx
mov    0x9(%rdx),%r12b
mov    -0x38(%rbp),%rdx
mov    0xa(%rdx),%r15b
mov    -0x38(%rbp),%rdx
mov    0xb(%rdx),%r14b
mov    -0x38(%rbp),%rdx
mov    0xc(%rdx),%bl
mov    -0x38(%rbp),%rdx
mov    0xd(%rdx),%r11b
mov    -0x38(%rbp),%rdx
mov    0xe(%rdx),%r10b
mov    -0x38(%rbp),%rdx
mov    %rdx,-0x50(%rbp)
lea    0xe27(%rip),%rdx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %al,%eax
mov    %eax,(%rsp)
mov    -0x54(%rbp),%al
movzbl %al,%eax
mov    %eax,0x8(%rsp)
mov    -0x53(%rbp),%al
movzbl %al,%eax
mov    %eax,0x10(%rsp)
mov    -0x52(%rbp),%al
movzbl %al,%eax
mov    %eax,0x18(%rsp)
mov    -0x51(%rbp),%al
movzbl %al,%eax
mov    %eax,0x20(%rsp)
mov    -0x50(%rbp),%rax
movzbl %r13b,%r13d
mov    %r13d,0x28(%rsp)
movzbl %r12b,%r12d
mov    %r12d,0x30(%rsp)
movzbl %r15b,%r15d
mov    %r15d,0x38(%rsp)
movzbl %r14b,%r14d
mov    %r14d,0x40(%rsp)
movzbl %bl,%ebx
mov    %ebx,0x48(%rsp)
movzbl %r11b,%r11d
mov    %r11d,0x50(%rsp)
movzbl %r10b,%r10d
mov    %r10d,0x58(%rsp)
movzbl 0xf(%rax),%eax
mov    %eax,0x60(%rsp)
call   1030 <snprintf@plt>
movl   $0x0,-0x2c(%rbp)
jmp    1273 <vdp_uuid2str+0x163>
movl   $0xffffffff,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<vdp_uuid2str>:
mov    $0xffffffff,%eax
test   %rsi,%rsi
je     11e5 <vdp_uuid2str+0xd5>
cmp    $0x29,%rdx
jb     11e5 <vdp_uuid2str+0xd5>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movzbl (%rdi),%ecx
movzbl 0x1(%rdi),%r8d
movzbl 0x2(%rdi),%r9d
movzbl 0x3(%rdi),%eax
mov    %rax,0x20(%rsp)
movzbl 0x4(%rdi),%eax
mov    %rax,0x18(%rsp)
movzbl 0x5(%rdi),%eax
mov    %rax,0x10(%rsp)
movzbl 0x6(%rdi),%eax
mov    %rax,0x8(%rsp)
movzbl 0x7(%rdi),%eax
mov    %rax,(%rsp)
movzbl 0x8(%rdi),%r13d
movzbl 0x9(%rdi),%r12d
movzbl 0xa(%rdi),%ebp
movzbl 0xb(%rdi),%eax
movzbl 0xc(%rdi),%r10d
movzbl 0xd(%rdi),%r11d
movzbl 0xe(%rdi),%ebx
movzbl 0xf(%rdi),%r14d
sub    $0x8,%rsp
lea    0xe61(%rip),%r15
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %r15,%rdx
push   %r14
push   %rbx
push   %r11
push   %r10
push   %rax
push   %rbp
push   %r12
push   %r13
push   0x48(%rsp)
push   0x58(%rsp)
push   0x68(%rsp)
push   0x78(%rsp)
push   0x88(%rsp)
call   1030 <snprintf@plt>
add    $0x70,%rsp
xor    %eax,%eax
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 i32 @vdp_uuid2str(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%8 = load i8*, i8** %6
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %65
10: ; preds = %3
%11 = load i64, i64* %7
%12 = icmp ugt i64 %11, 40
br i1 %12, label %13, label %65
13: ; preds = %10
%14 = load i8*, i8** %6
%15 = load i64, i64* %7
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 2
%24 = load i8, i8* %23
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i64 3
%27 = load i8, i8* %26
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i64 4
%30 = load i8, i8* %29
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i64 5
%33 = load i8, i8* %32
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i64 6
%36 = load i8, i8* %35
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i64 7
%39 = load i8, i8* %38
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 8
%42 = load i8, i8* %41
%43 = load i8*, i8** %5
%44 = getelementptr inbounds i8, i8* %43, i64 9
%45 = load i8, i8* %44
%46 = load i8*, i8** %5
%47 = getelementptr inbounds i8, i8* %46, i64 10
%48 = load i8, i8* %47
%49 = load i8*, i8** %5
%50 = getelementptr inbounds i8, i8* %49, i64 11
%51 = load i8, i8* %50
%52 = load i8*, i8** %5
%53 = getelementptr inbounds i8, i8* %52, i64 12
%54 = load i8, i8* %53
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i64 13
%57 = load i8, i8* %56
%58 = load i8*, i8** %5
%59 = getelementptr inbounds i8, i8* %58, i64 14
%60 = load i8, i8* %59
%61 = load i8*, i8** %5
%62 = getelementptr inbounds i8, i8* %61, i64 15
%63 = load i8, i8* %62
%64 = call i32 @snprintf(i8* %14, i64 %15, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i8 zeroext %18, i8 zeroext %21, i8 zeroext %24, i8 zeroext %27, i8 zeroext %30, i8 zeroext %33, i8 zeroext %36, i8 zeroext %39, i8 zeroext %42, i8 zeroext %45, i8 zeroext %48, i8 zeroext %51, i8 zeroext %54, i8 zeroext %57, i8 zeroext %60, i8 zeroext %63)
store i32 0, i32* %4
br label %66
65: ; preds = %10, %3
store i32 -1, i32* %4
br label %66
66: ; preds = %65, %13
%67 = load i32, i32* %4
ret i32 %67
}

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 i32 @vdp_uuid2str(i8* nocapture %0, i8* %1, i64 %2) {
%4 = icmp ne i8* %1, null
%5 = icmp ugt i64 %2, 40
%6 = and i1 %4, %5
br i1 %6, label %7, label %40
7: ; preds = %3
%8 = load i8, i8* %0
%9 = getelementptr inbounds i8, i8* %0, i64 1
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %0, i64 2
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %0, i64 3
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %0, i64 4
%16 = load i8, i8* %15
%17 = getelementptr inbounds i8, i8* %0, i64 5
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %0, i64 6
%20 = load i8, i8* %19
%21 = getelementptr inbounds i8, i8* %0, i64 7
%22 = load i8, i8* %21
%23 = getelementptr inbounds i8, i8* %0, i64 8
%24 = load i8, i8* %23
%25 = getelementptr inbounds i8, i8* %0, i64 9
%26 = load i8, i8* %25
%27 = getelementptr inbounds i8, i8* %0, i64 10
%28 = load i8, i8* %27
%29 = getelementptr inbounds i8, i8* %0, i64 11
%30 = load i8, i8* %29
%31 = getelementptr inbounds i8, i8* %0, i64 12
%32 = load i8, i8* %31
%33 = getelementptr inbounds i8, i8* %0, i64 13
%34 = load i8, i8* %33
%35 = getelementptr inbounds i8, i8* %0, i64 14
%36 = load i8, i8* %35
%37 = getelementptr inbounds i8, i8* %0, i64 15
%38 = load i8, i8* %37
%39 = tail call i32 @snprintf(i8* %1, i64 %2, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i8 zeroext %8, i8 zeroext %10, i8 zeroext %12, i8 zeroext %14, i8 zeroext %16, i8 zeroext %18, i8 zeroext %20, i8 zeroext %22, i8 zeroext %24, i8 zeroext %26, i8 zeroext %28, i8 zeroext %30, i8 zeroext %32, i8 zeroext %34, i8 zeroext %36, i8 zeroext %38)
br label %40
40: ; preds = %3, %7
%41 = phi i32 [ 0, %7 ], [ -1, %3 ]
ret i32 %41
}