#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*/ __ploop_err(int /*<<< orphan*/, char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ prl_uuid2str(unsigned char *, char *, int);
int uuid_new(unsigned char *);
int ploop_uuid_generate(char *uuid, int len) {
  int ret;
  unsigned char uu[16];
  ret = uuid_new(uu);
  if (ret) {
    __ploop_err(errno, "Can't generate uuid");
    return ret;
  }
  prl_uuid2str(uu, uuid, len);
  return 0;
}


x86 assembly (clang, -O0):
<ploop_uuid_generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <uuid_new@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1175 <ploop_uuid_generate+0x45>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
call   1050 <__ploop_err@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118c <ploop_uuid_generate+0x5c>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <prl_uuid2str@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ploop_uuid_generate>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %rdi,%rbp
mov    %rsp,%rdi
call   1030 <uuid_new@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1163 <ploop_uuid_generate+0x33>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
call   1050 <__ploop_err@plt>
jmp    1171 <ploop_uuid_generate+0x41>
mov    %rsp,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1040 <prl_uuid2str@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i32 0
@.str = [20 x i8] c"Can't generate uuid\00"
define i32 @ploop_uuid_generate(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [16 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%9 = call i32 @uuid_new(i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @errno
%14 = call i32 @__ploop_err(i32 %13, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %6
store i32 %15, i32* %3
br label %21
16: ; preds = %2
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%18 = load i8*, i8** %4
%19 = load i32, i32* %5
%20 = call i32 @prl_uuid2str(i8* %17, i8* %18, i32 %19)
store i32 0, i32* %3
br label %21
21: ; preds = %16, %12
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [20 x i8] c"Can't generate uuid\00"
define i32 @ploop_uuid_generate(i8* %0, i32 %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = call i32 @uuid_new(i8* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* @errno
%9 = call i32 @__ploop_err(i32 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %2
%11 = call i32 @prl_uuid2str(i8* %4, i8* %0, i32 %1)
br label %12
12: ; preds = %10, %7
ret i32 %5
}