#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int);
int trypticdigest() {
  int i;
  int j;
  j = 0;
  while ((i = getchar()) != EOF) {
    if (i != 'P' && j == 'R') {
      putchar(j);
      printf("\n");
      j = i;
    } else if (j == 'K') {
      putchar(j);
      printf("\n");
      j = i;
    } else if (j != 0) {
      putchar(j);
      j = i;
    } else {
      j = i;
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<trypticdigest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e98(%rip),%rcx
cmp    (%rcx),%eax
je     11e6 <trypticdigest+0xb6>
cmpl   $0x50,-0x4(%rbp)
je     118b <trypticdigest+0x5b>
cmpl   $0x52,-0x8(%rbp)
jne    118b <trypticdigest+0x5b>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11e1 <trypticdigest+0xb1>
cmpl   $0x4b,-0x8(%rbp)
jne    11b4 <trypticdigest+0x84>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11dc <trypticdigest+0xac>
cmpl   $0x0,-0x8(%rbp)
je     11d1 <trypticdigest+0xa1>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11d7 <trypticdigest+0xa7>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11dc <trypticdigest+0xac>
jmp    11e1 <trypticdigest+0xb1>
jmp    113f <trypticdigest+0xf>
lea    0xe13(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trypticdigest>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb7(%rip),%rbx
cmp    (%rbx),%eax
jne    1148 <trypticdigest+0x28>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %ebp,%ebp
jmp    116f <trypticdigest+0x4f>
nopl   0x0(%rax)
mov    $0x52,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
je     1135 <trypticdigest+0x15>
mov    %ebp,%edi
mov    %eax,%ebp
cmp    $0x52,%edi
jne    117d <trypticdigest+0x5d>
cmp    $0x50,%ebp
jne    1150 <trypticdigest+0x30>
test   %edi,%edi
je     1164 <trypticdigest+0x44>
cmp    $0x4b,%edi
jne    115f <trypticdigest+0x3f>
mov    $0x4b,%edi
jmp    1155 <trypticdigest+0x35>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [2 x i8] c"\0A\00"
define i32 @trypticdigest() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %37, %0
%4 = call i32 (...) @getchar()
store i32 %4, i32* %1
%5 = load i32, i32* @EOF
%6 = icmp ne i32 %4, %5
br i1 %6, label %7, label %38
7: ; preds = %3
%8 = load i32, i32* %1
%9 = icmp ne i32 %8, 80
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 82
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i32, i32* %2
%15 = call i32 @putchar(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* %1
store i32 %17, i32* %2
br label %37
18: ; preds = %10, %7
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 75
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* %2
%23 = call i32 @putchar(i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* %1
store i32 %25, i32* %2
br label %36
26: ; preds = %18
%27 = load i32, i32* %2
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* %2
%31 = call i32 @putchar(i32 %30)
%32 = load i32, i32* %1
store i32 %32, i32* %2
br label %35
33: ; preds = %26
%34 = load i32, i32* %1
store i32 %34, i32* %2
br label %35
35: ; preds = %33, %29
br label %36
36: ; preds = %35, %21
br label %37
37: ; preds = %36, %13
br label %3
38: ; preds = %3
%39 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @trypticdigest() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %23, label %4
4: ; preds = %0, %19
%5 = phi i32 [ %20, %19 ], [ %1, %0 ]
%6 = phi i32 [ %5, %19 ], [ 0, %0 ]
%7 = icmp ne i32 %5, 80
%8 = icmp eq i32 %6, 82
%9 = and i1 %8, %7
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = tail call i32 @putchar(i32 82)
%12 = tail call i32 @putchar(i32 10)
br label %19
13: ; preds = %4
switch i32 %6, label %17 [
i32 75, label %14
i32 0, label %19
]
14: ; preds = %13
%15 = tail call i32 @putchar(i32 75)
%16 = tail call i32 @putchar(i32 10)
br label %19
17: ; preds = %13
%18 = tail call i32 @putchar(i32 %6)
br label %19
19: ; preds = %13, %14, %17, %10
%20 = tail call i32 (...) @getchar()
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %4
23: ; preds = %19, %0
%24 = tail call i32 @putchar(i32 10)
ret i32 0
}