main(c) {
  c = 0;
  char s;
  while ((s = getchar()) != 10) {
    putchar(s);
    c += (s == 'K' || s == 'G' || s == 'L' || s == 'F') ? 1 : 0;
  };
  return !printf("%d", c);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11c8 <main+0x98>
movsbl -0x9(%rbp),%edi
mov    $0x0,%al
call   1030 <putchar@plt>
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0x4b,%ecx
mov    %al,-0xa(%rbp)
je     11ad <main+0x7d>
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0x47,%ecx
mov    %al,-0xa(%rbp)
je     11ad <main+0x7d>
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0x4c,%ecx
mov    %al,-0xa(%rbp)
je     11ad <main+0x7d>
movsbl -0x9(%rbp),%eax
cmp    $0x46,%eax
sete   %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%dl
xor    %eax,%eax
mov    $0x1,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1149 <main+0x19>
mov    -0x8(%rbp),%esi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
shl    $0x18,%ebp
cmp    $0xa000000,%ebp
jne    1168 <main+0x38>
lea    0xeaf(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe95(%rip),%r14
xor    %ebx,%ebx
jmp    1196 <main+0x66>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    %eax,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
shl    $0x18,%ebp
cmp    $0xa000000,%ebp
je     114a <main+0x1a>
mov    %ebp,%edi
sar    $0x18,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
add    $0xba000000,%ebp
shr    $0x18,%ebp
mov    $0x0,%eax
cmp    $0x6,%bpl
ja     1180 <main+0x50>
movsbq %bpl,%rax
mov    (%r14,%rax,4),%eax
jmp    1180 <main+0x50>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %2
store i32 %0, i32* %3
store i32 0, i32* %3
br label %5
5: ; preds = %29, %1
%6 = call i32 (...) @getchar()
%7 = trunc i32 %6 to i8
store i8 %7, i8* %4
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 10
br i1 %9, label %10, label %35
10: ; preds = %5
%11 = load i8, i8* %4
%12 = sext i8 %11 to i32
%13 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %12)
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 75
br i1 %16, label %29, label %17
17: ; preds = %10
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 71
br i1 %20, label %29, label %21
21: ; preds = %17
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 76
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i8, i8* %4
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 70
br label %29
29: ; preds = %25, %21, %17, %10
%30 = phi i1 [ true, %21 ], [ true, %17 ], [ true, %10 ], [ %28, %25 ]
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 1, i32 0
%33 = load i32, i32* %3
%34 = add nsw i32 %33, %32
store i32 %34, i32* %3
br label %5
35: ; preds = %5
%36 = load i32, i32* %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = icmp ne i32 %37, 0
%39 = xor i1 %38, true
%40 = zext i1 %39 to i32
ret i32 %40
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@switch.table.main = [7 x i32] [i32 1, i32 1, i32 0, i32 0, i32 0, i32 1, i32 1]
define i32 @main(i32 %0) {
%2 = tail call i32 (...) @getchar()
%3 = shl i32 %2, 24
%4 = icmp eq i32 %3, 167772160
br i1 %4, label %24, label %5
5: ; preds = %1, %18
%6 = phi i32 [ %22, %18 ], [ %3, %1 ]
%7 = phi i32 [ %20, %18 ], [ 0, %1 ]
%8 = ashr exact i32 %6, 24
%9 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %8)
%10 = add i32 %6, -1174405120
%11 = lshr exact i32 %10, 24
%12 = trunc i32 %11 to i8
%13 = icmp ult i8 %12, 7
br i1 %13, label %14, label %18
14: ; preds = %5
%15 = sext i8 %12 to i64
%16 = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.main, i64 0, i64 %15
%17 = load i32, i32* %16
br label %18
18: ; preds = %5, %14
%19 = phi i32 [ %17, %14 ], [ 0, %5 ]
%20 = add nuw nsw i32 %19, %7
%21 = tail call i32 (...) @getchar()
%22 = shl i32 %21, 24
%23 = icmp eq i32 %22, 167772160
br i1 %23, label %24, label %5
24: ; preds = %18, %1
%25 = phi i32 [ 0, %1 ], [ %20, %18 ]
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = icmp eq i32 %26, 0
%28 = zext i1 %27 to i32
ret i32 %28
}