#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 getch();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ ungetch(int);
int main(void) {
  int c;
  while ((c = getch()) != EOF) {
    if (c == '\n')
      ;
    else if (c >= '0' && c <= '9') {
      ungetch(c);
      printf("[%c] is a number\n", getch());
    } else
      printf("[%c] is not a number\n", c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <getch@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e98(%rip),%rcx
cmp    (%rcx),%eax
je     11b6 <main+0x86>
cmpl   $0xa,-0x8(%rbp)
jne    1167 <main+0x37>
jmp    11b1 <main+0x81>
cmpl   $0x30,-0x8(%rbp)
jl     119d <main+0x6d>
cmpl   $0x39,-0x8(%rbp)
jg     119d <main+0x6d>
mov    -0x8(%rbp),%edi
call   1040 <ungetch@plt>
mov    $0x0,%al
call   1050 <getch@plt>
mov    %eax,%esi
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    11ac <main+0x7c>
mov    -0x8(%rbp),%esi
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
jmp    11b1 <main+0x81>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <getch@plt>
mov    0x2ea5(%rip),%rbx
cmp    (%rbx),%eax
jne    114f <main+0x1f>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xeaa(%rip),%r14
lea    0xeb5(%rip),%r15
jmp    1175 <main+0x45>
nop
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getch@plt>
cmp    (%rbx),%eax
je     1147 <main+0x17>
cmp    $0xa,%eax
je     116a <main+0x3a>
lea    -0x30(%rax),%ecx
cmp    $0x9,%ecx
ja     1160 <main+0x30>
mov    %eax,%edi
call   1040 <ungetch@plt>
xor    %eax,%eax
call   1050 <getch@plt>
mov    %r14,%rdi
mov    %eax,%esi
jmp    1165 <main+0x35>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [18 x i8] c"[%c] is a number\0A\00"
@.str.1 = [22 x i8] c"[%c] is not a number\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %26, %0
%4 = call i32 (...) @getch()
store i32 %4, i32* %2
%5 = load i32, i32* @EOF
%6 = icmp ne i32 %4, %5
br i1 %6, label %7, label %27
7: ; preds = %3
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 10
br i1 %9, label %10, label %11
10: ; preds = %7
br label %26
11: ; preds = %7
%12 = load i32, i32* %2
%13 = icmp sge i32 %12, 48
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i32, i32* %2
%16 = icmp sle i32 %15, 57
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i32, i32* %2
%19 = call i32 @ungetch(i32 %18)
%20 = call i32 (...) @getch()
%21 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %25
22: ; preds = %14, %11
%23 = load i32, i32* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %22, %17
br label %26
26: ; preds = %25, %10
br label %3
27: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [18 x i8] c"[%c] is a number\0A\00"
@.str.1 = [22 x i8] c"[%c] is not a number\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @getch()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %20, label %4
4: ; preds = %0, %16
%5 = phi i32 [ %17, %16 ], [ %1, %0 ]
%6 = icmp eq i32 %5, 10
br i1 %6, label %16, label %7
7: ; preds = %4
%8 = add i32 %5, -48
%9 = icmp ult i32 %8, 10
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = tail call i32 @ungetch(i32 %5)
%12 = tail call i32 (...) @getch()
%13 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %16
14: ; preds = %7
%15 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %5)
br label %16
16: ; preds = %10, %14, %4
%17 = tail call i32 (...) @getch()
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %4
20: ; preds = %16, %0
ret i32 0
}