#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*/ printf(char *, int, char *);
int strlen(char *);
char tolower(char);
char toupper(char);
int main(int argc, char *argv[]) {
  int i;
  char var1[] = "este texto esta em letras minusculas";
  char var2[] = "MAS ESTE ESTAVA EM MAIUSCULAS";
  for (i = 0; i < strlen(var1); i++) {
    var1[i] = toupper(var1[i]);
  }
  printf("\nTamanho = %d \n%s\n", strlen(var1), var1);
  for (i = 0; i < strlen(var2); i++) {
    var2[i] = tolower(var2[i]);
  }
  printf("\nTamanho = %d \n%s\n", strlen(var2), var2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x25,%edx
call   1060 <memcpy@plt>
mov    0xeae(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xea8(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xea6(%rip),%eax
mov    %eax,-0x48(%rbp)
mov    0xea0(%rip),%ax
mov    %ax,-0x44(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x64(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
cmp    %ecx,%eax
jge    11f9 <main+0xa9>
movslq -0x14(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%edi
call   1030 <toupper@plt>
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b7 <main+0x67>
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
lea    -0x40(%rbp),%rdx
lea    0xe3f(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
cmp    %ecx,%eax
jge    125d <main+0x10d>
movslq -0x14(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%edi
call   1070 <tolower@plt>
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    121b <main+0xcb>
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
lea    -0x60(%rbp),%rdx
lea    0xddb(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movabs $0x73616c75637375,%rax
mov    %rax,0x3d(%rsp)
movups 0xec9(%rip),%xmm0
movups %xmm0,0xe(%rsp)
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x20(%rsp),%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11c1 <main+0x81>
xor    %ebx,%ebx
lea    0x20(%rsp),%r14
nopw   0x0(%rax,%rax,1)
movsbl 0x20(%rsp,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %al,0x20(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11a0 <main+0x60>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xe79(%rip),%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1050 <printf@plt>
mov    %rsp,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    120f <main+0xcf>
xor    %ebx,%ebx
mov    %rsp,%r14
movsbl (%rsp,%rbx,1),%edi
call   1060 <tolower@plt>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11f0 <main+0xb0>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xe2d(%rip),%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.var1 = [37 x i8] c"este texto esta em letras minusculas\00"
@__const.main.var2 = [30 x i8] c"MAS ESTE ESTAVA EM MAIUSCULAS\00"
@.str = [19 x i8] c"\0ATamanho = %d \0A%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [37 x i8]
%8 = alloca [30 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [37 x i8]* %7 to i8*
%10 = bitcast [30 x i8]* %8 to i8*
store i32 0, i32* %6
br label %11
11: ; preds = %25, %2
%12 = load i32, i32* %6
%13 = getelementptr inbounds [37 x i8], [37 x i8]* %7, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %28
16: ; preds = %11
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [37 x i8], [37 x i8]* %7, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = call signext i8 @toupper(i8 signext %20)
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [37 x i8], [37 x i8]* %7, i64 0, i64 %23
store i8 %21, i8* %24
br label %25
25: ; preds = %16
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %11
28: ; preds = %11
%29 = getelementptr inbounds [37 x i8], [37 x i8]* %7, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = getelementptr inbounds [37 x i8], [37 x i8]* %7, i64 0, i64 0
%32 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %30, i8* %31)
store i32 0, i32* %6
br label %33
33: ; preds = %47, %28
%34 = load i32, i32* %6
%35 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%36 = call i32 @strlen(i8* %35)
%37 = icmp slt i32 %34, %36
br i1 %37, label %38, label %50
38: ; preds = %33
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = call signext i8 @tolower(i8 signext %42)
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 %45
store i8 %43, i8* %46
br label %47
47: ; preds = %38
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %33
50: ; preds = %33
%51 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%52 = call i32 @strlen(i8* %51)
%53 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%54 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %52, i8* %53)
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@__const.main.var1 = [37 x i8] c"este texto esta em letras minusculas\00"
@__const.main.var2 = [30 x i8] c"MAS ESTE ESTAVA EM MAIUSCULAS\00"
@.str = [19 x i8] c"\0ATamanho = %d \0A%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [37 x i8]
%4 = alloca [30 x i8]
%5 = getelementptr inbounds [37 x i8], [37 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%7 = call i32 @strlen(i8* %5)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %2, %9
%10 = phi i64 [ %14, %9 ], [ 0, %2 ]
%11 = getelementptr inbounds [37 x i8], [37 x i8]* %3, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = call signext i8 @toupper(i8 signext %12)
store i8 %13, i8* %11
%14 = add nuw nsw i64 %10, 1
%15 = call i32 @strlen(i8* %5)
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %9, label %18
18: ; preds = %9, %2
%19 = call i32 @strlen(i8* %5)
%20 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %19, i8* %5)
%21 = call i32 @strlen(i8* %6)
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %18, %23
%24 = phi i64 [ %28, %23 ], [ 0, %18 ]
%25 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call signext i8 @tolower(i8 signext %26)
store i8 %27, i8* %25
%28 = add nuw nsw i64 %24, 1
%29 = call i32 @strlen(i8* %6)
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %23, label %32
32: ; preds = %23, %18
%33 = call i32 @strlen(i8* %6)
%34 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %33, i8* %6)
ret i32 0
}