#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  char sentence[100];
  char stop[5] = "STOP";
  int counter, check;
  printf("Write sentences and press Enter:\n");
  while (1) {
    check = 0;
    fgets(sentence, 100, stdin);
    for (counter = 0; sentence[counter] != '\0'; counter++) {
      if (sentence[counter] >= 'a' && sentence[counter] <= 'z')
        sentence[counter] = sentence[counter] - ('a' - 'A');
      if (sentence[counter] == stop[check] && check < 4)
        check++;
      else if (check < 4)
        check = 0;
    }
    printf("%s", sentence);
    if (check == 4)
      break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x75(%rbp)
mov    0xec3(%rip),%al
mov    %al,-0x71(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x80(%rbp)
lea    -0x70(%rbp),%rdi
mov    0x2e84(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1040 <fgets@plt>
movl   $0x0,-0x7c(%rbp)
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     121e <main+0xfe>
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x61,%eax
jl     11c3 <main+0xa3>
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x7a,%eax
jg     11c3 <main+0xa3>
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
sub    $0x20,%eax
mov    %al,%cl
movslq -0x7c(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
movslq -0x80(%rbp),%rcx
movsbl -0x75(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11f5 <main+0xd5>
cmpl   $0x4,-0x80(%rbp)
jge    11f5 <main+0xd5>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    120b <main+0xeb>
cmpl   $0x4,-0x80(%rbp)
jge    1206 <main+0xe6>
movl   $0x0,-0x80(%rbp)
jmp    120b <main+0xeb>
jmp    1210 <main+0xf0>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1177 <main+0x57>
lea    -0x70(%rbp),%rsi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x4,-0x80(%rbp)
jne    123f <main+0x11f>
jmp    1244 <main+0x124>
jmp    1152 <main+0x32>
xor    %eax,%eax
add    $0x80,%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    0xec3(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e97(%rip),%r12
mov    %rsp,%r13
lea    0xeaa(%rip),%r14
xor    %ebp,%ebp
lea    0xe9c(%rip),%rbx
jmp    1183 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x4,%r15d
je     11e4 <main+0xb4>
mov    (%r12),%edx
mov    %r13,%rdi
mov    $0x64,%esi
call   1050 <fgets@plt>
mov    (%rsp),%al
mov    $0x0,%r15d
test   %al,%al
je     1170 <main+0x40>
xor    %r15d,%r15d
lea    0x1(%rsp),%rcx
jmp    11d5 <main+0xa5>
nopl   0x0(%rax,%rax,1)
movslq %r15d,%rdx
lea    0x1(%rdx),%r15d
cmp    $0x4,%edx
mov    %edx,%esi
cmovl  %ebp,%esi
cmovge %esi,%r15d
cmp    (%rdx,%rbx,1),%al
cmovne %esi,%r15d
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
je     1170 <main+0x40>
lea    -0x61(%rax),%edx
cmp    $0x19,%dl
ja     11b0 <main+0x80>
add    $0xe0,%al
mov    %al,-0x1(%rcx)
jmp    11b0 <main+0x80>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.stop = [5 x i8] c"STOP\00"
@.str = [34 x i8] c"Write sentences and press Enter:\0A\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [5 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [5 x i8]* %3 to i8*
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %0, %77
store i32 0, i32* %5
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 100, i32 %10)
store i32 0, i32* %4
br label %12
12: ; preds = %68, %8
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %71
19: ; preds = %12
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp sge i32 %24, 97
br i1 %25, label %26, label %44
26: ; preds = %19
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp sle i32 %31, 122
br i1 %32, label %33, label %44
33: ; preds = %26
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = sub nsw i32 %38, 32
%40 = trunc i32 %39 to i8
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %42
store i8 %40, i8* %43
br label %44
44: ; preds = %33, %26, %19
%45 = load i32, i32* %4
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %49, %54
br i1 %55, label %56, label %62
56: ; preds = %44
%57 = load i32, i32* %5
%58 = icmp slt i32 %57, 4
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i32, i32* %5
%61 = add nsw i32 %60, 1
store i32 %61, i32* %5
br label %67
62: ; preds = %56, %44
%63 = load i32, i32* %5
%64 = icmp slt i32 %63, 4
br i1 %64, label %65, label %66
65: ; preds = %62
store i32 0, i32* %5
br label %66
66: ; preds = %65, %62
br label %67
67: ; preds = %66, %59
br label %68
68: ; preds = %67
%69 = load i32, i32* %4
%70 = add nsw i32 %69, 1
store i32 %70, i32* %4
br label %12
71: ; preds = %12
%72 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %72)
%74 = load i32, i32* %5
%75 = icmp eq i32 %74, 4
br i1 %75, label %76, label %77
76: ; preds = %71
br label %78
77: ; preds = %71
br label %8
78: ; preds = %76
ret i32 0
}

LLVM IR (-O2):
@__const.main.stop = [5 x i8] c"STOP\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@str = [33 x i8] c"Write sentences and press Enter:\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %33, %0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %2, i32 100, i32 %5)
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
br i1 %8, label %33, label %9
9: ; preds = %4, %18
%10 = phi i64 [ %29, %18 ], [ 0, %4 ]
%11 = phi i8 [ %31, %18 ], [ %7, %4 ]
%12 = phi i8* [ %30, %18 ], [ %2, %4 ]
%13 = phi i32 [ %28, %18 ], [ 0, %4 ]
%14 = add i8 %11, -97
%15 = icmp ult i8 %14, 26
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = add nsw i8 %11, -32
store i8 %17, i8* %12
br label %18
18: ; preds = %16, %9
%19 = phi i8 [ %17, %16 ], [ %11, %9 ]
%20 = sext i32 %13 to i64
%21 = getelementptr inbounds [5 x i8], [5 x i8]* @__const.main.stop, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %19, %22
%24 = icmp slt i32 %13, 4
%25 = select i1 %23, i1 %24, i1 false
%26 = add nsw i32 %13, 1
%27 = select i1 %24, i32 0, i32 %13
%28 = select i1 %25, i32 %26, i32 %27
%29 = add nuw i64 %10, 1
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %33, label %9
33: ; preds = %18, %4
%34 = phi i32 [ 0, %4 ], [ %28, %18 ]
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%36 = icmp eq i32 %34, 4
br i1 %36, label %37, label %4
37: ; preds = %33
ret i32 0
}