#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 /*<<< orphan*/ scanf(char *, char *);
int main() {
  char c;
  int i = 0;
  do {
    scanf("%c", &c);
    if ((c == 'S' && i == 0) || (c == 'T' && i == 1) || (c == 'O' && i == 2) ||
        (c == 'P' && i == 3)) {
      i++;
    } else {
      i = 0;
    }
    if (c >= 'a' && c <= 'z') {
      printf("%c", c - 32);
    } else {
      printf("%c", c);
    }
  } while (i < 4);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x53,%eax
jne    115d <main+0x3d>
cmpl   $0x0,-0xc(%rbp)
je     11a2 <main+0x82>
movsbl -0x5(%rbp),%eax
cmp    $0x54,%eax
jne    1174 <main+0x54>
cmpl   $0x1,-0xc(%rbp)
je     11a2 <main+0x82>
movsbl -0x5(%rbp),%eax
cmp    $0x4f,%eax
jne    118b <main+0x6b>
cmpl   $0x2,-0xc(%rbp)
je     11a2 <main+0x82>
movsbl -0x5(%rbp),%eax
cmp    $0x50,%eax
jne    11b0 <main+0x90>
cmpl   $0x3,-0xc(%rbp)
jne    11b0 <main+0x90>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b7 <main+0x97>
movl   $0x0,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     11eb <main+0xcb>
movsbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
jg     11eb <main+0xcb>
movsbl -0x5(%rbp),%esi
sub    $0x20,%esi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fd <main+0xdd>
movsbl -0x5(%rbp),%esi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1202 <main+0xe2>
cmpl   $0x4,-0xc(%rbp)
jl     1136 <main+0x16>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %ebp,%ebp
lea    0xecf(%rip),%r14
lea    0xf(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movzbl 0xf(%rsp),%edi
cmp    $0x53,%edi
jne    1159 <main+0x39>
test   %ebp,%ebp
je     1180 <main+0x60>
cmp    $0x54,%dil
jne    1164 <main+0x44>
cmp    $0x1,%ebp
je     1180 <main+0x60>
cmp    $0x4f,%dil
jne    116f <main+0x4f>
cmp    $0x2,%ebp
je     1180 <main+0x60>
cmp    $0x50,%dil
jne    118f <main+0x6f>
cmp    $0x3,%ebp
jne    118f <main+0x6f>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
call   1030 <putchar@plt>
cmp    $0x4,%ebp
jb     1140 <main+0x20>
jmp    11a3 <main+0x83>
movsbl %dil,%eax
lea    -0x61(%rax),%ecx
lea    -0x20(%rax),%edi
cmp    $0x1a,%cl
cmovae %eax,%edi
xor    %ebp,%ebp
jmp    1183 <main+0x63>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\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 = %55, %0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 83
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %33, label %12
12: ; preds = %9, %4
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 84
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 1
br i1 %18, label %33, label %19
19: ; preds = %16, %12
%20 = load i8, i8* %2
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 79
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 2
br i1 %25, label %33, label %26
26: ; preds = %23, %19
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 80
br i1 %29, label %30, label %36
30: ; preds = %26
%31 = load i32, i32* %3
%32 = icmp eq i32 %31, 3
br i1 %32, label %33, label %36
33: ; preds = %30, %23, %16, %9
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %37
36: ; preds = %30, %26
store i32 0, i32* %3
br label %37
37: ; preds = %36, %33
%38 = load i8, i8* %2
%39 = sext i8 %38 to i32
%40 = icmp sge i32 %39, 97
br i1 %40, label %41, label %50
41: ; preds = %37
%42 = load i8, i8* %2
%43 = sext i8 %42 to i32
%44 = icmp sle i32 %43, 122
br i1 %44, label %45, label %50
45: ; preds = %41
%46 = load i8, i8* %2
%47 = sext i8 %46 to i32
%48 = sub nsw i32 %47, 32
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %48)
br label %54
50: ; preds = %41, %37
%51 = load i8, i8* %2
%52 = sext i8 %51 to i32
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %50, %45
br label %55
55: ; preds = %54
%56 = load i32, i32* %3
%57 = icmp slt i32 %56, 4
br i1 %57, label %4, label %58
58: ; preds = %55
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

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