#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*/ copy_uuid(char *, int *, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
char *__fname_from_uuid(int id[4], int swap, char *buf, char sep) {
  int i, j;
  char uuid[16];
  char *c = buf;
  strcpy(c, "UUID-");
  c += strlen(c);
  copy_uuid(uuid, id, swap);
  for (i = 0; i < 4; i++) {
    if (i)
      *c++ = sep;
    for (j = 3; j >= 0; j--) {
      sprintf(c, "%02x", (unsigned char)uuid[j + 4 * i]);
      c += 2;
    }
  }
  return buf;
}


x86 assembly (clang, -O0):
<__fname_from_uuid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %cl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x48(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <copy_uuid@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    1228 <__fname_from_uuid+0xe8>
cmpl   $0x0,-0x20(%rbp)
je     11c8 <__fname_from_uuid+0x88>
mov    -0x19(%rbp),%cl
mov    -0x48(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x48(%rbp)
mov    %cl,(%rax)
movl   $0x3,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     1215 <__fname_from_uuid+0xd5>
mov    -0x48(%rbp),%rdi
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%ecx
shl    $0x2,%ecx
add    %ecx,%eax
cltq
lea    0xe15(%rip),%rsi
movzbl -0x40(%rbp,%rax,1),%edx
call   1060 <sprintf@plt>
mov    -0x48(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    11cf <__fname_from_uuid+0x8f>
jmp    121a <__fname_from_uuid+0xda>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a0 <__fname_from_uuid+0x60>
mov    -0x18(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__fname_from_uuid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %rdi,%r12
lea    0xe9f(%rip),%rsi
mov    %rdx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
movslq %eax,%rbp
lea    (%rbx,%rbp,1),%r13
mov    %rsp,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   1030 <copy_uuid@plt>
movzbl 0x3(%rsp),%edx
lea    0xe74(%rip),%r14
mov    %r13,%rdi
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x2,%rdi
movzbl 0x2(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x4,%rdi
movzbl 0x1(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x6,%rdi
movzbl (%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x9,%rdi
mov    %r15b,0x8(%rbx,%rbp,1)
movzbl 0x7(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0xb,%rdi
movzbl 0x6(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0xd,%rdi
movzbl 0x5(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0xf,%rdi
movzbl 0x4(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x12,%rdi
mov    %r15b,0x11(%rbx,%rbp,1)
movzbl 0xb(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x14,%rdi
movzbl 0xa(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x16,%rdi
movzbl 0x9(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x18,%rdi
movzbl 0x8(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x1b,%rdi
mov    %r15b,0x1a(%rbx,%rbp,1)
movzbl 0xf(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x1d,%rdi
movzbl 0xe(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x1f,%rdi
movzbl 0xd(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x21,%rdi
movzbl 0xc(%rsp),%edx
mov    %r14,%rsi
call   1060 <sprintf@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"UUID-\00"
@.str.1 = [5 x i8] c"%02x\00"
define i8* @__fname_from_uuid(i32* %0, i32 %1, i8* %2, i8 signext %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
%11 = alloca [16 x i8]
%12 = alloca i8*
store i32* %0, i32** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8 %3, i8* %8
%13 = load i8*, i8** %7
store i8* %13, i8** %12
%14 = load i8*, i8** %12
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%16 = load i8*, i8** %12
%17 = call i32 @strlen(i8* %16)
%18 = load i8*, i8** %12
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds i8, i8* %18, i64 %19
store i8* %20, i8** %12
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%22 = load i32*, i32** %5
%23 = load i32, i32* %6
%24 = call i32 @copy_uuid(i8* %21, i32* %22, i32 %23)
store i32 0, i32* %9
br label %25
25: ; preds = %55, %4
%26 = load i32, i32* %9
%27 = icmp slt i32 %26, 4
br i1 %27, label %28, label %58
28: ; preds = %25
%29 = load i32, i32* %9
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i8, i8* %8
%33 = load i8*, i8** %12
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %12
store i8 %32, i8* %33
br label %35
35: ; preds = %31, %28
store i32 3, i32* %10
br label %36
36: ; preds = %51, %35
%37 = load i32, i32* %10
%38 = icmp sge i32 %37, 0
br i1 %38, label %39, label %54
39: ; preds = %36
%40 = load i8*, i8** %12
%41 = load i32, i32* %10
%42 = load i32, i32* %9
%43 = mul nsw i32 4, %42
%44 = add nsw i32 %41, %43
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %47)
%49 = load i8*, i8** %12
%50 = getelementptr inbounds i8, i8* %49, i64 2
store i8* %50, i8** %12
br label %51
51: ; preds = %39
%52 = load i32, i32* %10
%53 = add nsw i32 %52, -1
store i32 %53, i32* %10
br label %36
54: ; preds = %36
br label %55
55: ; preds = %54
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %25
58: ; preds = %25
%59 = load i8*, i8** %7
ret i8* %59
}

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