#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int toupper(char);
int main() {
  char frase[75];
  int i, tam;
  gets(frase);
  while (strcmp(frase, "the end!")) {
    tam = strlen(frase);
    for (i = 0; i < tam; ++i) {
      if (i == (tam - 1)) {
        printf("%c\n", toupper(frase[i]));
      } else
        printf("%c", toupper(frase[i]));
    }
    gets(frase);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
call   1070 <gets@plt>
lea    -0x50(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1210 <main+0xc0>
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x58(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x58(%rbp),%eax
jge    1202 <main+0xb2>
mov    -0x54(%rbp),%eax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11d3 <main+0x83>
movslq -0x54(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%edi
call   1030 <toupper@plt>
mov    %eax,%esi
lea    0xe40(%rip),%rdi
call   1050 <printf@plt>
jmp    11ef <main+0x9f>
movslq -0x54(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%edi
call   1030 <toupper@plt>
mov    %eax,%esi
lea    0xe23(%rip),%rdi
call   1050 <printf@plt>
jmp    11f4 <main+0xa4>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1195 <main+0x45>
lea    -0x50(%rbp),%rdi
call   1070 <gets@plt>
jmp    1168 <main+0x18>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     122b <main+0xdb>
lea    0x10(%rsp),%rbx
jmp    11b1 <main+0x61>
nopw   0x0(%rax,%rax,1)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
mov    %rbx,%rdi
lea    0xe59(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     122b <main+0xdb>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
lea    0xe47(%rip),%rcx
lea    0xe44(%rip),%rbp
jle    1190 <main+0x40>
lea    -0x1(%rax),%edx
mov    %eax,%eax
mov    %rax,0x8(%rsp)
mov    %rdx,%r14
lea    (%rsp,%rdx,1),%r15
add    $0x10,%r15
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %r12,%r14
lea    0x10(%rsp,%r12,1),%rax
cmove  %r15,%rax
mov    %rbp,%rbx
cmove  %rcx,%rbx
movsbl (%rax),%edi
mov    %rcx,%r13
call   1030 <toupper@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r13,%rcx
add    $0x1,%r12
cmp    %r12,0x8(%rsp)
jne    11f0 <main+0xa0>
jmp    1190 <main+0x40>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"the end!\00"
@.str.1 = [4 x i8] c"%c\0A\00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [75 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = getelementptr inbounds [75 x i8], [75 x i8]* %2, i64 0, i64 0
%6 = call i32 @gets(i8* %5)
br label %7
7: ; preds = %41, %0
%8 = getelementptr inbounds [75 x i8], [75 x i8]* %2, i64 0, i64 0
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %44
11: ; preds = %7
%12 = getelementptr inbounds [75 x i8], [75 x i8]* %2, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %4
store i32 0, i32* %3
br label %14
14: ; preds = %38, %11
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %41
18: ; preds = %14
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, 1
%22 = icmp eq i32 %19, %21
br i1 %22, label %23, label %30
23: ; preds = %18
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [75 x i8], [75 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = call i32 @toupper(i8 signext %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %37
30: ; preds = %18
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [75 x i8], [75 x i8]* %2, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = call i32 @toupper(i8 signext %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %30, %23
br label %38
38: ; preds = %37
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %14
41: ; preds = %14
%42 = getelementptr inbounds [75 x i8], [75 x i8]* %2, i64 0, i64 0
%43 = call i32 @gets(i8* %42)
br label %7
44: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"the end!\00"
@.str.1 = [4 x i8] c"%c\0A\00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca [75 x i8]
%2 = getelementptr inbounds [75 x i8], [75 x i8]* %1, i64 0, i64 0
%3 = call i32 @gets(i8* %2)
%4 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %29, label %6
6: ; preds = %0, %25
%7 = call i32 @strlen(i8* %2)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = add nsw i32 %7, -1
%11 = zext i32 %10 to i64
%12 = zext i32 %7 to i64
%13 = getelementptr inbounds [75 x i8], [75 x i8]* %1, i64 0, i64 %11
br label %14
14: ; preds = %9, %14
%15 = phi i64 [ 0, %9 ], [ %23, %14 ]
%16 = icmp eq i64 %15, %11
%17 = getelementptr inbounds [75 x i8], [75 x i8]* %1, i64 0, i64 %15
%18 = select i1 %16, i8* %13, i8* %17
%19 = select i1 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%20 = load i8, i8* %18
%21 = call i32 @toupper(i8 signext %20)
%22 = call i32 @printf(i8* %19, i32 %21)
%23 = add nuw nsw i64 %15, 1
%24 = icmp eq i64 %23, %12
br i1 %24, label %25, label %14
25: ; preds = %14, %6
%26 = call i32 @gets(i8* %2)
%27 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %6
29: ; preds = %25, %0
ret i32 0
}