#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*/ strcpy(char *, char *);
char *strdup(char *);
unsigned int strlen(char *);
char toupper(char);
char *upSt(char *s) {
  unsigned i;
  char res[256];
  strcpy(res, s);
  for (i = 0; i < strlen(res); i++)
    res[i] = toupper(res[i]);
  return strdup(res);
}


x86 assembly (clang, -O0):
<upSt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x114(%rbp),%eax
cmp    %ecx,%eax
jae    11b5 <upSt+0x75>
mov    -0xc(%rbp),%eax
movsbl -0x110(%rbp,%rax,1),%edi
ff
call   1040 <toupper@plt>
mov    %al,%cl
mov    -0xc(%rbp),%eax
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <upSt+0x26>
lea    -0x110(%rbp),%rdi
call   1060 <strdup@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<upSt>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
je     118f <upSt+0x4f>
xor    %ebx,%ebx
mov    %rsp,%r14
nopl   0x0(%rax)
movsbl (%rsp,%rbx,1),%edi
call   1040 <toupper@plt>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jb     1170 <upSt+0x30>
mov    %rsp,%rdi
call   1060 <strdup@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define noalias i8* @upSt(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* %0)
%5 = call i32 @strlen(i8* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %1, %7
%8 = phi i64 [ %12, %7 ], [ 0, %1 ]
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = call signext i8 @toupper(i8 signext %10)
store i8 %11, i8* %9
%12 = add nuw nsw i64 %8, 1
%13 = call i32 @strlen(i8* %3)
%14 = zext i32 %13 to i64
%15 = icmp ult i64 %12, %14
br i1 %15, label %7, label %16
16: ; preds = %7, %1
%17 = call i8* @strdup(i8* %3)
ret i8* %17
}