#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 */
char *CalculateMD5ForSeed(char const *, int);
char toupper(char);
char *CalculateGUID(const char *key) {
  int i;
  char *tmp, *hash;
  tmp = CalculateMD5ForSeed(key, 0x00b684a3);
  hash = CalculateMD5ForSeed(tmp, 0x00051a56);
  for (i = 0; hash[i]; i++)
    hash[i] = toupper(hash[i]);
  return hash;
}


x86 assembly (clang, -O0):
<CalculateGUID>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xb684a3,%esi
call   1040 <CalculateMD5ForSeed@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x51a56,%esi
call   1040 <CalculateMD5ForSeed@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1195 <CalculateGUID+0x75>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1157 <CalculateGUID+0x37>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalculateGUID>:
push   %r14
push   %rbx
push   %rax
mov    $0xb684a3,%esi
call   1040 <CalculateMD5ForSeed@plt>
mov    %rax,%rdi
mov    $0x51a56,%esi
call   1040 <CalculateMD5ForSeed@plt>
mov    %rax,%r14
mov    (%rax),%al
test   %al,%al
je     1166 <CalculateGUID+0x46>
mov    %r14,%rbx
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <CalculateGUID+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @CalculateGUID(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @CalculateMD5ForSeed(i8* %6, i32 11961507)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = call i8* @CalculateMD5ForSeed(i8* %8, i32 334422)
store i8* %9, i8** %5
store i32 0, i32* %3
br label %10
10: ; preds = %28, %1
%11 = load i8*, i8** %5
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %31
17: ; preds = %10
%18 = load i8*, i8** %5
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = call signext i8 @toupper(i8 signext %22)
%24 = load i8*, i8** %5
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
store i8 %23, i8* %27
br label %28
28: ; preds = %17
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %10
31: ; preds = %10
%32 = load i8*, i8** %5
ret i8* %32
}

LLVM IR (-O2):
define i8* @CalculateGUID(i8* %0) {
%2 = tail call i8* @CalculateMD5ForSeed(i8* %0, i32 11961507)
%3 = tail call i8* @CalculateMD5ForSeed(i8* %2, i32 334422)
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %1, %6
%7 = phi i64 [ %11, %6 ], [ 0, %1 ]
%8 = phi i8 [ %13, %6 ], [ %4, %1 ]
%9 = phi i8* [ %12, %6 ], [ %3, %1 ]
%10 = tail call signext i8 @toupper(i8 signext %8)
store i8 %10, i8* %9
%11 = add nuw i64 %7, 1
%12 = getelementptr inbounds i8, i8* %3, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %6
15: ; preds = %6, %1
ret i8* %3
}