#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 */
scalar_t__ generate_uuid(unsigned char *);
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);
int get_uuid_string(char *buf) {
  unsigned char uuid[16];
  if (generate_uuid(uuid) != 0)
    return -1;
  sprintf(
      buf,
      "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
      uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
      uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14],
      uuid[15]);
  buf[36] = '\0';
  return 0;
}


x86 assembly (clang, -O0):
<get_uuid_string>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdi,-0x38(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <generate_uuid@plt>
cmp    $0x0,%rax
je     1157 <get_uuid_string+0x37>
movl   $0xffffffff,-0x2c(%rbp)
jmp    1231 <get_uuid_string+0x111>
mov    -0x38(%rbp),%rdi
mov    -0x50(%rbp),%dl
mov    -0x4f(%rbp),%cl
mov    -0x4e(%rbp),%r8b
mov    -0x4d(%rbp),%r9b
mov    -0x4c(%rbp),%al
mov    -0x4b(%rbp),%sil
mov    %sil,-0x53(%rbp)
mov    -0x4a(%rbp),%sil
mov    %sil,-0x52(%rbp)
mov    -0x49(%rbp),%r13b
mov    -0x48(%rbp),%r12b
mov    -0x47(%rbp),%r15b
mov    -0x46(%rbp),%r14b
mov    -0x45(%rbp),%bl
mov    -0x44(%rbp),%r11b
mov    -0x43(%rbp),%r10b
mov    -0x42(%rbp),%sil
mov    %sil,-0x51(%rbp)
lea    0xe5a(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %al,%eax
mov    %eax,(%rsp)
mov    -0x53(%rbp),%al
movzbl %al,%eax
mov    %eax,0x8(%rsp)
mov    -0x52(%rbp),%al
movzbl %al,%eax
mov    %eax,0x10(%rsp)
mov    -0x51(%rbp),%al
movzbl %r13b,%r13d
mov    %r13d,0x18(%rsp)
movzbl %r12b,%r12d
mov    %r12d,0x20(%rsp)
movzbl %r15b,%r15d
mov    %r15d,0x28(%rsp)
movzbl %r14b,%r14d
mov    %r14d,0x30(%rsp)
movzbl %bl,%ebx
mov    %ebx,0x38(%rsp)
movzbl %r11b,%r11d
mov    %r11d,0x40(%rsp)
movzbl %r10b,%r10d
mov    %r10d,0x48(%rsp)
movzbl %al,%eax
mov    %eax,0x50(%rsp)
movzbl -0x41(%rbp),%eax
mov    %eax,0x58(%rsp)
call   1040 <sprintf@plt>
mov    -0x38(%rbp),%rax
movb   $0x0,0x24(%rax)
movl   $0x0,-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):
<get_uuid_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
call   1030 <generate_uuid@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    11ef <get_uuid_string+0xcf>
movzbl (%rsp),%edx
movzbl 0x1(%rsp),%ecx
movzbl 0x2(%rsp),%r8d
movzbl 0x3(%rsp),%r9d
movzbl 0x4(%rsp),%eax
mov    %rax,0x30(%rsp)
movzbl 0x5(%rsp),%eax
mov    %rax,0x28(%rsp)
movzbl 0x6(%rsp),%eax
mov    %rax,0x20(%rsp)
movzbl 0x7(%rsp),%eax
mov    %rax,0x18(%rsp)
movzbl 0x8(%rsp),%r12d
movzbl 0x9(%rsp),%r13d
movzbl 0xa(%rsp),%eax
movzbl 0xb(%rsp),%ebp
movzbl 0xc(%rsp),%r10d
movzbl 0xd(%rsp),%r11d
movzbl 0xe(%rsp),%r14d
movzbl 0xf(%rsp),%r15d
lea    0xe44(%rip),%rsi
mov    %rbx,%rdi
push   %r15
push   %r14
push   %r11
push   %r10
push   %rbp
push   %rax
push   %r13
push   %r12
push   0x58(%rsp)
push   0x68(%rsp)
push   0x78(%rsp)
push   0x88(%rsp)
call   1040 <sprintf@plt>
add    $0x60,%rsp
movb   $0x0,0x24(%rbx)
xor    %eax,%eax
add    $0x38,%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 @get_uuid_string(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [16 x i8]
store i8* %0, i8** %3
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%6 = call i64 @generate_uuid(i8* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 -1, i32* %2
br label %46
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%12 = load i8, i8* %11
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 1
%14 = load i8, i8* %13
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 2
%16 = load i8, i8* %15
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 3
%18 = load i8, i8* %17
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 4
%20 = load i8, i8* %19
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 5
%22 = load i8, i8* %21
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 6
%24 = load i8, i8* %23
%25 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 7
%26 = load i8, i8* %25
%27 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 8
%28 = load i8, i8* %27
%29 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 9
%30 = load i8, i8* %29
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 10
%32 = load i8, i8* %31
%33 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 11
%34 = load i8, i8* %33
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 12
%36 = load i8, i8* %35
%37 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 13
%38 = load i8, i8* %37
%39 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 14
%40 = load i8, i8* %39
%41 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 15
%42 = load i8, i8* %41
%43 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), 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, i8 zeroext %40, i8 zeroext %42)
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i64 36
store i8 0, i8* %45
store i32 0, i32* %2
br label %46
46: ; preds = %9, %8
%47 = load i32, i32* %2
ret i32 %47
}

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