#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 *strcpy(char *, char *);
scalar_t__ strlen(char *);
char toupper(char);
char *UPCASE_STRING(char *Result, char *S_) {
  char S[256];
  short I, FORLIM;
  strcpy(S, S_);
  FORLIM = (short)strlen(S);
  for (I = 0; I < FORLIM; I++)
    S[I] = toupper(S[I]);
  return strcpy(Result, S);
}


x86 assembly (clang, -O0):
<UPCASE_STRING>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    %ax,-0x114(%rbp)
movw   $0x0,-0x112(%rbp)
movswl -0x112(%rbp),%eax
movswl -0x114(%rbp),%ecx
cmp    %ecx,%eax
jge    11c2 <UPCASE_STRING+0x92>
movswq -0x112(%rbp),%rax
ff
movsbl -0x110(%rbp,%rax,1),%edi
ff
call   1040 <toupper@plt>
mov    %al,%cl
movswq -0x112(%rbp),%rax
ff
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x112(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x112(%rbp)
jmp    116f <UPCASE_STRING+0x3f>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UPCASE_STRING>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
shl    $0x10,%ecx
test   %ecx,%ecx
jle    118b <UPCASE_STRING+0x5b>
movswl %ax,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movswq %bx,%rbp
movsbl (%rsp,%rbp,1),%edi
call   1040 <toupper@plt>
mov    %al,(%rsp,%rbp,1)
add    $0x1,%ebx
movswl %bx,%eax
cmp    %eax,%r15d
jg     1170 <UPCASE_STRING+0x40>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @UPCASE_STRING(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [256 x i8]
%6 = alloca i16
%7 = alloca i16
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%9 = load i8*, i8** %4
%10 = call i8* @strcpy(i8* %8, i8* %9)
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%12 = call i64 @strlen(i8* %11)
%13 = trunc i64 %12 to i16
store i16 %13, i16* %7
store i16 0, i16* %6
br label %14
14: ; preds = %29, %2
%15 = load i16, i16* %6
%16 = sext i16 %15 to i32
%17 = load i16, i16* %7
%18 = sext i16 %17 to i32
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %32
20: ; preds = %14
%21 = load i16, i16* %6
%22 = sext i16 %21 to i64
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = call signext i8 @toupper(i8 signext %24)
%26 = load i16, i16* %6
%27 = sext i16 %26 to i64
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %27
store i8 %25, i8* %28
br label %29
29: ; preds = %20
%30 = load i16, i16* %6
%31 = add i16 %30, 1
store i16 %31, i16* %6
br label %14
32: ; preds = %14
%33 = load i8*, i8** %3
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%35 = call i8* @strcpy(i8* %33, i8* %34)
ret i8* %35
}

LLVM IR (-O2):
define i8* @UPCASE_STRING(i8* returned %0, i8* nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i8* @strcpy(i8* %4, i8* dereferenceable(1) %1)
%6 = call i64 @strlen(i8* %4)
%7 = trunc i64 %6 to i32
%8 = shl i32 %7, 16
%9 = ashr exact i32 %8, 16
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %20
11: ; preds = %2, %11
%12 = phi i16 [ %17, %11 ], [ 0, %2 ]
%13 = sext i16 %12 to i64
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = call signext i8 @toupper(i8 signext %15)
store i8 %16, i8* %14
%17 = add i16 %12, 1
%18 = sext i16 %17 to i32
%19 = icmp sgt i32 %9, %18
br i1 %19, label %11, label %20
20: ; preds = %11, %2
%21 = call i8* @strcpy(i8* dereferenceable(1) %0, i8* %4)
ret i8* %0
}