#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*/ initString(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char toupper(char);
void toUpperCase(char src[20], char dst[20]) {
  int len = strlen(src);
  int i;
  initString(dst);
  if (len <= 0) {
    strcpy(dst, "<empty>");
  } else {
    for (i = 0; i < len; i++)
      dst[i] = toupper(src[i]);
    dst[i] = '\0';
  }
}


x86 assembly (clang, -O0):
<toUpperCase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <initString@plt>
cmpl   $0x0,-0x14(%rbp)
jg     1184 <toUpperCase+0x44>
mov    -0x10(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11cf <toUpperCase+0x8f>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c3 <toUpperCase+0x83>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <toupper@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118b <toUpperCase+0x4b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toUpperCase>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1060 <initString@plt>
test   %ebp,%ebp
jle    1197 <toUpperCase+0x57>
mov    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r15,%rbx,1),%edi
call   1040 <toupper@plt>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <toUpperCase+0x30>
movb   $0x0,(%r14,%rbp,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe62(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"<empty>\00"
define void @toUpperCase(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %5
%9 = load i8*, i8** %4
%10 = call i32 @initString(i8* %9)
%11 = load i32, i32* %5
%12 = icmp sle i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %40
16: ; preds = %2
store i32 0, i32* %6
br label %17
17: ; preds = %32, %16
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %35
21: ; preds = %17
%22 = load i8*, i8** %3
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = call signext i8 @toupper(i8 signext %26)
%28 = load i8*, i8** %4
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 %27, i8* %31
br label %32
32: ; preds = %21
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %17
35: ; preds = %17
%36 = load i8*, i8** %4
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %35, %13
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"<empty>\00"
define void @toUpperCase(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @initString(i8* %1)
%5 = icmp slt i32 %3, 1
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = zext i32 %3 to i64
br label %10
8: ; preds = %2
%9 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %20
10: ; preds = %6, %10
%11 = phi i64 [ 0, %6 ], [ %16, %10 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = tail call signext i8 @toupper(i8 signext %13)
%15 = getelementptr inbounds i8, i8* %1, i64 %11
store i8 %14, i8* %15
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %7
br i1 %17, label %18, label %10
18: ; preds = %10
%19 = getelementptr inbounds i8, i8* %1, i64 %7
store i8 0, i8* %19
br label %20
20: ; preds = %18, %8
ret void
}