#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 /*<<< orphan*/ exit(int);
int getchar();
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/);
int testterm(void) {
  int c;
  c = getchar();
  if (c == EOF) {
    exit(1);
  }
  if (c == '.')
    return (0);
  if (c == '\n' || c == ';')
    ungetc(c, stdin);
  return (1);
}


x86 assembly (clang, -O0):
<testterm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%eax
jne    115e <testterm+0x2e>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpl   $0x2e,-0x8(%rbp)
jne    1174 <testterm+0x44>
movl   $0x0,-0x4(%rbp)
jmp    11a0 <testterm+0x70>
cmpl   $0xa,-0x8(%rbp)
je     1188 <testterm+0x58>
cmpl   $0x3b,-0x8(%rbp)
jne    1199 <testterm+0x69>
mov    -0x8(%rbp),%edi
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
call   1040 <ungetc@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testterm>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    0x2e9f(%rip),%rcx
cmp    (%rcx),%eax
je     116d <testterm+0x3d>
cmp    $0x3b,%eax
je     1154 <testterm+0x24>
cmp    $0x2e,%eax
je     1169 <testterm+0x39>
cmp    $0xa,%eax
jne    1164 <testterm+0x34>
mov    0x2e8d(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1040 <ungetc@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@EOF = global i32 0
@stdin = global i32 0
define i32 @testterm() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @getchar()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 46
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 0, i32* %1
br label %24
13: ; preds = %9
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 10
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 59
br i1 %18, label %19, label %23
19: ; preds = %16, %13
%20 = load i32, i32* %2
%21 = load i32, i32* @stdin
%22 = call i32 @ungetc(i32 %20, i32 %21)
br label %23
23: ; preds = %19, %16
store i32 1, i32* %1
br label %24
24: ; preds = %23, %12
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@EOF = global i32 0
@stdin = global i32 0
define i32 @testterm() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
switch i32 %1, label %10 [
i32 46, label %11
i32 59, label %7
i32 10, label %7
]
7: ; preds = %6, %6
%8 = load i32, i32* @stdin
%9 = tail call i32 @ungetc(i32 %1, i32 %8)
br label %11
10: ; preds = %6
br label %11
11: ; preds = %6, %10, %7
%12 = phi i32 [ 0, %6 ], [ 1, %7 ], [ 1, %10 ]
ret i32 %12
}