#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 */
scalar_t__ islower(char);
int /*<<< orphan*/ strcpy(char *, char const *);
char toupper(char);
char *stringToUpper(char *myString, const char *source) {
  strcpy(myString, source);
  while (*myString != '\0') {
    if (islower(*myString)) {
      *myString = toupper(*myString);
    }
    myString++;
  }
  return myString;
}


x86 assembly (clang, -O0):
<stringToUpper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1198 <stringToUpper+0x68>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     1187 <stringToUpper+0x57>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <toupper@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    114d <stringToUpper+0x1d>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringToUpper>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strcpy@plt>
mov    (%rbx),%al
jmp    1148 <stringToUpper+0x18>
nopl   (%rax)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1165 <stringToUpper+0x35>
movsbl %al,%edi
call   1040 <islower@plt>
test   %rax,%rax
je     1140 <stringToUpper+0x10>
movsbl (%rbx),%edi
call   1050 <toupper@plt>
mov    %al,(%rbx)
jmp    1140 <stringToUpper+0x10>
mov    %rbx,%rax
pop    %rbx
ret

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

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