#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*/ memcpy(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char const);
int /*<<< orphan*/ strcpy(char *, char *);
const char *toc_make_fake_cap(const unsigned char *const str, const int len) {
  static char buf[sizeof("FFFFFFFF-cccc-dddd-eeee-ffffgggghhhh")];
  const int ar[] = {9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34};
  const int maxlen = 12;
  int i;
  strcpy(buf, "FFFFFFFF-0000-0000-0000-000000000000");
  for (i = 0; (i < len) && (i < maxlen); i++) {
    char b[3];
    sprintf(b, "%02X", str[i]);
    memcpy(buf + ar[i], b, 2);
  }
  return (buf);
}


x86 assembly (clang, -O0):
<toc_make_fake_cap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
movl   $0xc,-0x44(%rbp)
lea    0x2eee(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x4c(%rbp)
jge    1190 <toc_make_fake_cap+0x60>
cmpl   $0xc,-0x48(%rbp)
setl   %al
mov    %al,-0x4c(%rbp)
mov    -0x4c(%rbp),%al
test   $0x1,%al
jne    11a0 <toc_make_fake_cap+0x70>
jmp    11eb <toc_make_fake_cap+0xbb>
lea    -0x4b(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x48(%rbp),%rcx
lea    0xea2(%rip),%rsi
movzbl (%rax,%rcx,1),%edx
call   1050 <sprintf@plt>
movslq -0x48(%rbp),%rax
movslq -0x40(%rbp,%rax,4),%rax
lea    0x2e84(%rip),%rdi
add    %rax,%rdi
lea    -0x4b(%rbp),%rsi
mov    $0x2,%edx
call   1040 <memcpy@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1175 <toc_make_fake_cap+0x45>
lea    0x2e5e(%rip),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toc_make_fake_cap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x2f09(%rip),%rdi
lea    0xee2(%rip),%rsi
call   1030 <strcpy@plt>
test   %ebp,%ebp
jle    11c7 <toc_make_fake_cap+0x97>
add    $0xffffffff,%ebp
cmp    $0xb,%ebp
mov    $0xb,%eax
cmovb  %ebp,%eax
lea    0x4(,%rax,4),%r13
xor    %ebp,%ebp
lea    0xedf(%rip),%r15
lea    0x5(%rsp),%r12
lea    0xe7e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx),%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <sprintf@plt>
movslq 0x0(%rbp,%r14,1),%rdi
lea    0x2ea6(%rip),%rax
add    %rax,%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1040 <memcpy@plt>
add    $0x4,%rbp
add    $0x1,%rbx
cmp    %rbp,%r13
jne    1190 <toc_make_fake_cap+0x60>
lea    0x2e82(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@toc_make_fake_cap.buf = internal global [37 x i8] zeroinitializer
@__const.toc_make_fake_cap.ar = [12 x i32] [i32 9, i32 11, i32 14, i32 16, i32 19, i32 21, i32 24, i32 26, i32 28, i32 30, i32 32, i32 34]
@.str = [37 x i8] c"FFFFFFFF-0000-0000-0000-000000000000\00"
@.str.1 = [5 x i8] c"%02X\00"
define i8* @toc_make_fake_cap(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [12 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca [3 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = bitcast [12 x i32]* %5 to i8*
store i32 12, i32* %6
%10 = call i32 @strcpy(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @toc_make_fake_cap.buf, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %11
11: ; preds = %36, %2
%12 = load i32, i32* %7
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 12
br label %18
18: ; preds = %15, %11
%19 = phi i1 [ false, %11 ], [ %17, %15 ]
br i1 %19, label %20, label %39
20: ; preds = %18
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%22 = load i8*, i8** %3
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %26)
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @toc_make_fake_cap.buf, i64 0, i64 0), i64 %32
%34 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%35 = call i32 @memcpy(i8* %33, i8* %34, i32 2)
br label %36
36: ; preds = %20
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %11
39: ; preds = %18
ret i8* getelementptr inbounds ([37 x i8], [37 x i8]* @toc_make_fake_cap.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@toc_make_fake_cap.buf = internal global [37 x i8] zeroinitializer
@__const.toc_make_fake_cap.ar = [12 x i32] [i32 9, i32 11, i32 14, i32 16, i32 19, i32 21, i32 24, i32 26, i32 28, i32 30, i32 32, i32 34]
@.str = [37 x i8] c"FFFFFFFF-0000-0000-0000-000000000000\00"
@.str.1 = [5 x i8] c"%02X\00"
define i8* @toc_make_fake_cap(i8* nocapture %0, i32 %1) {
%3 = alloca [3 x i8]
%4 = tail call i32 @strcpy(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @toc_make_fake_cap.buf, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %24
6: ; preds = %2
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%8 = add nsw i32 %1, -1
%9 = call i32 @llvm.umin.i32(i32 %8, i32 11)
%10 = add nuw nsw i32 %9, 1
%11 = zext i32 %10 to i64
br label %12
12: ; preds = %6, %12
%13 = phi i64 [ 0, %6 ], [ %22, %12 ]
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %15)
%17 = getelementptr inbounds [12 x i32], [12 x i32]* @__const.toc_make_fake_cap.ar, i64 0, i64 %13
%18 = load i32, i32* %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [37 x i8], [37 x i8]* @toc_make_fake_cap.buf, i64 0, i64 %19
%21 = call i32 @memcpy(i8* %20, i8* %7, i32 2)
%22 = add nuw nsw i64 %13, 1
%23 = icmp eq i64 %22, %11
br i1 %23, label %24, label %12
24: ; preds = %12, %2
ret i8* getelementptr inbounds ([37 x i8], [37 x i8]* @toc_make_fake_cap.buf, i64 0, i64 0)
}