#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 /*<<< orphan*/ stdin;
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/);
int main(void) {
  register int ch;
  register int notfirst = 0;
  printf(".TL\n");
  printf("Command Summary for GNU Emacs\n");
  printf(".AU\nRichard M. Stallman\n");
  while ((ch = getchar()) != EOF) {
    if (ch == '\037') {
      if (notfirst)
        printf("\n.DE");
      else
        notfirst = 1;
      printf("\n.SH\n");
      ch = getchar();
      printf(ch == 'F' ? "Function " : "Variable ");
      while ((ch = getchar()) != '\n') {
        if (ch != EOF)
          putchar(ch);
        else {
          ungetc(ch, stdin);
          break;
        }
      }
      printf("\n.DS L\n");
    } else
      putchar(ch);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e55(%rip),%rcx
cmp    (%rcx),%eax
je     125d <main+0x11d>
cmpl   $0x1f,-0x8(%rbp)
jne    1250 <main+0x110>
cmpl   $0x0,-0xc(%rbp)
je     11b8 <main+0x78>
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
jmp    11bf <main+0x7f>
movl   $0x1,-0xc(%rbp)
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xe73(%rip),%rdi
lea    0xe62(%rip),%rax
cmp    $0x46,%ecx
cmove  %rax,%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xa,%eax
je     123f <main+0xff>
mov    -0x8(%rbp),%eax
mov    0x2dd1(%rip),%rcx
cmp    (%rcx),%eax
je     1224 <main+0xe4>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    123a <main+0xfa>
mov    -0x8(%rbp),%edi
mov    0x2dba(%rip),%rax
mov    (%rax),%esi
call   1060 <ungetc@plt>
jmp    123f <main+0xff>
jmp    11f2 <main+0xb2>
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
jmp    1258 <main+0x118>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    117a <main+0x3a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
lea    0xec1(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e53(%rip),%rbx
cmp    (%rbx),%eax
jne    11a2 <main+0x52>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeaa(%rip),%r14
lea    0xe55(%rip),%r13
lea    0xe58(%rip),%rbp
lea    0xe9a(%rip),%r12
xor    %r15d,%r15d
jmp    11e2 <main+0x92>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%rbx),%eax
je     1191 <main+0x41>
cmp    $0x1f,%eax
jne    11d0 <main+0x80>
test   %r15d,%r15d
je     11f8 <main+0xa8>
lea    0xe0d(%rip),%rdi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x46,%eax
mov    %rbp,%rdi
cmove  %r13,%rdi
call   1050 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%eax
je     1249 <main+0xf9>
cmp    (%rbx),%eax
je     1239 <main+0xe9>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    1220 <main+0xd0>
mov    0x2da8(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1070 <ungetc@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    $0x1,%r15d
jmp    11d7 <main+0x87>

LLVM IR (-O0):
@.str = [5 x i8] c".TL\0A\00"
@.str.1 = [31 x i8] c"Command Summary for GNU Emacs\0A\00"
@.str.2 = [25 x i8] c".AU\0ARichard M. Stallman\0A\00"
@EOF = global i32 0
@.str.3 = [5 x i8] c"\0A.DE\00"
@.str.4 = [6 x i8] c"\0A.SH\0A\00"
@.str.5 = [10 x i8] c"Function \00"
@.str.6 = [10 x i8] c"Variable \00"
@stdin = global i32 0
@.str.7 = [8 x i8] c"\0A.DS L\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %48, %0
%8 = call i32 (...) @getchar()
store i32 %8, i32* %2
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %49
11: ; preds = %7
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 31
br i1 %13, label %14, label %45
14: ; preds = %11
%15 = load i32, i32* %3
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %20
19: ; preds = %14
store i32 1, i32* %3
br label %20
20: ; preds = %19, %17
%21 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 (...) @getchar()
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 70
%25 = zext i1 %24 to i64
%26 = select i1 %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0)
%27 = call i32 @printf(i8* %26)
br label %28
28: ; preds = %42, %20
%29 = call i32 (...) @getchar()
store i32 %29, i32* %2
%30 = icmp ne i32 %29, 10
br i1 %30, label %31, label %43
31: ; preds = %28
%32 = load i32, i32* %2
%33 = load i32, i32* @EOF
%34 = icmp ne i32 %32, %33
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = load i32, i32* %2
%37 = call i32 @putchar(i32 %36)
br label %42
38: ; preds = %31
%39 = load i32, i32* %2
%40 = load i32, i32* @stdin
%41 = call i32 @ungetc(i32 %39, i32 %40)
br label %43
42: ; preds = %35
br label %28
43: ; preds = %38, %28
%44 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %48
45: ; preds = %11
%46 = load i32, i32* %2
%47 = call i32 @putchar(i32 %46)
br label %48
48: ; preds = %45, %43
br label %7
49: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.3 = [5 x i8] c"\0A.DE\00"
@.str.5 = [10 x i8] c"Function \00"
@.str.6 = [10 x i8] c"Variable \00"
@stdin = global i32 0
@str = [4 x i8] c".TL\00"
@str.8 = [30 x i8] c"Command Summary for GNU Emacs\00"
@str.9 = [24 x i8] c".AU\0ARichard M. Stallman\00"
@str.10 = [5 x i8] c"\0A.SH\00"
@str.11 = [7 x i8] c"\0A.DS L\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.9, i64 0, i64 0))
%4 = tail call i32 (...) @getchar()
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %43, label %7
7: ; preds = %0, %38
%8 = phi i32 [ %40, %38 ], [ %4, %0 ]
%9 = phi i32 [ %39, %38 ], [ 0, %0 ]
%10 = icmp eq i32 %8, 31
br i1 %10, label %11, label %36
11: ; preds = %7
%12 = icmp eq i32 %9, 0
br i1 %12, label %15, label %13
13: ; preds = %11
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %11, %13
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.10, i64 0, i64 0))
%17 = tail call i32 (...) @getchar()
%18 = icmp eq i32 %17, 70
%19 = select i1 %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0)
%20 = tail call i32 @printf(i8* dereferenceable(1) %19)
%21 = tail call i32 (...) @getchar()
%22 = icmp eq i32 %21, 10
br i1 %22, label %34, label %23
23: ; preds = %15, %27
%24 = phi i32 [ %29, %27 ], [ %21, %15 ]
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = tail call i32 @putchar(i32 %24)
%29 = tail call i32 (...) @getchar()
%30 = icmp eq i32 %29, 10
br i1 %30, label %34, label %23
31: ; preds = %23
%32 = load i32, i32* @stdin
%33 = tail call i32 @ungetc(i32 %24, i32 %32)
br label %34
34: ; preds = %27, %15, %31
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.11, i64 0, i64 0))
br label %38
36: ; preds = %7
%37 = tail call i32 @putchar(i32 %8)
br label %38
38: ; preds = %36, %34
%39 = phi i32 [ 1, %34 ], [ %9, %36 ]
%40 = tail call i32 (...) @getchar()
%41 = load i32, i32* @EOF
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %7
43: ; preds = %38, %0
ret i32 0
}