#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*/ free(char *);
int mstrlen(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char **);
int main() {
  char *buffer;
  int i = 0;
  do {
    scanf("%ms", &buffer);
    if (buffer[0] == 'S' && buffer[1] == 'T' && buffer[2] == 'O' &&
        buffer[3] == 'P')
      break;
    for (i = 0; i <= mstrlen(buffer); i++) {
      if ((buffer[i] >= 97) && (buffer[i] <= 122))
        buffer[i] -= 32;
    }
    printf("%s ", buffer);
    free(buffer);
  } while (1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xea3(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x53,%eax
jne    11ae <main+0x6e>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x54,%eax
jne    11ae <main+0x6e>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x4f,%eax
jne    11ae <main+0x6e>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x50,%eax
jne    11ae <main+0x6e>
jmp    1248 <main+0x108>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <mstrlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jg     1220 <main+0xe0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x61,%eax
jl     120d <main+0xcd>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7a,%eax
jg     120d <main+0xcd>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
sub    $0x20,%edx
mov    %dl,(%rax,%rcx,1)
jmp    1212 <main+0xd2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b5 <main+0x75>
mov    -0x10(%rbp),%rsi
lea    0xdd9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%al
test   $0x1,%al
jne    1156 <main+0x16>
jmp    1248 <main+0x108>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb1(%rip),%r14
mov    %rsp,%r15
lea    0xeab(%rip),%r12
jmp    1175 <main+0x35>
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rsi
mov    %r12,%rdi
call   1040 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%rdi
cmpb   $0x53,(%rdi)
jne    11a0 <main+0x60>
cmpb   $0x54,0x1(%rdi)
jne    11a0 <main+0x60>
cmpb   $0x4f,0x2(%rdi)
jne    11a0 <main+0x60>
cmpb   $0x50,0x3(%rdi)
je     11ed <main+0xad>
nopl   0x0(%rax,%rax,1)
call   1060 <mstrlen@plt>
test   %eax,%eax
js     1160 <main+0x20>
mov    $0xffffffffffffffff,%rbx
jmp    11d0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1060 <mstrlen@plt>
cltq
add    $0x1,%rbx
cmp    %rax,%rbx
jge    1160 <main+0x20>
mov    (%rsp),%rdi
movzbl 0x1(%rdi,%rbx,1),%eax
lea    -0x61(%rax),%ecx
cmp    $0x19,%cl
ja     11c0 <main+0x80>
add    $0xe0,%al
mov    %al,0x1(%rdi,%rbx,1)
mov    (%rsp),%rdi
jmp    11c0 <main+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ms\00"
@.str.1 = [4 x i8] c"%s \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %70, %0
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2)
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 83
br i1 %10, label %11, label %30
11: ; preds = %4
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 84
br i1 %16, label %17, label %30
17: ; preds = %11
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 79
br i1 %22, label %23, label %30
23: ; preds = %17
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i64 3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 80
br i1 %28, label %29, label %30
29: ; preds = %23
br label %71
30: ; preds = %23, %17, %11, %4
store i32 0, i32* %3
br label %31
31: ; preds = %62, %30
%32 = load i32, i32* %3
%33 = load i8*, i8** %2
%34 = call i32 @mstrlen(i8* %33)
%35 = icmp sle i32 %32, %34
br i1 %35, label %36, label %65
36: ; preds = %31
%37 = load i8*, i8** %2
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp sge i32 %42, 97
br i1 %43, label %44, label %61
44: ; preds = %36
%45 = load i8*, i8** %2
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp sle i32 %50, 122
br i1 %51, label %52, label %61
52: ; preds = %44
%53 = load i8*, i8** %2
%54 = load i32, i32* %3
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = sub nsw i32 %58, 32
%60 = trunc i32 %59 to i8
store i8 %60, i8* %56
br label %61
61: ; preds = %52, %44, %36
br label %62
62: ; preds = %61
%63 = load i32, i32* %3
%64 = add nsw i32 %63, 1
store i32 %64, i32* %3
br label %31
65: ; preds = %31
%66 = load i8*, i8** %2
%67 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %66)
%68 = load i8*, i8** %2
%69 = call i32 @free(i8* %68)
br label %70
70: ; preds = %65
br i1 true, label %4, label %71
71: ; preds = %70, %29
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ms\00"
@.str.1 = [4 x i8] c"%s \00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
br label %3
3: ; preds = %39, %0
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %1)
%5 = load i8*, i8** %1
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 83
br i1 %7, label %8, label %20
8: ; preds = %3
%9 = getelementptr inbounds i8, i8* %5, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 84
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %5, i64 2
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 79
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %5, i64 3
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 80
br i1 %19, label %44, label %20
20: ; preds = %16, %12, %8, %3
%21 = call i32 @mstrlen(i8* %5)
%22 = icmp slt i32 %21, 0
br i1 %22, label %39, label %23
23: ; preds = %20, %33
%24 = phi i64 [ %35, %33 ], [ 0, %20 ]
%25 = load i8*, i8** %1
%26 = getelementptr inbounds i8, i8* %25, i64 %24
%27 = load i8, i8* %26
%28 = add i8 %27, -97
%29 = icmp ult i8 %28, 26
br i1 %29, label %30, label %33
30: ; preds = %23
%31 = add nsw i8 %27, -32
store i8 %31, i8* %26
%32 = load i8*, i8** %1
br label %33
33: ; preds = %23, %30
%34 = phi i8* [ %25, %23 ], [ %32, %30 ]
%35 = add nuw nsw i64 %24, 1
%36 = call i32 @mstrlen(i8* %34)
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %24, %37
br i1 %38, label %23, label %39
39: ; preds = %33, %20
%40 = load i8*, i8** %1
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %40)
%42 = load i8*, i8** %1
%43 = call i32 @free(i8* %42)
br label %3
44: ; preds = %16
ret i32 0
}