#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 */
char EOF;
char getch();
scalar_t__ isdigit(char);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ ungetch(char);
int main() {
  char c;
  while ((c = getch()) != EOF) {
    if (isdigit(c)) {
      putchar(c);
      while (isdigit(c = getch())) {
        putchar(c);
      }
      if (c != EOF) {
        ungetch(c);
      }
    } else {
      putchar(c);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <getch@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e85(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11e6 <main+0xa6>
movsbl -0x5(%rbp),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     11d8 <main+0x98>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1060 <getch@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     11b4 <main+0x74>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    118a <main+0x4a>
movsbl -0x5(%rbp),%eax
mov    0x2e29(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11d3 <main+0x93>
movsbl -0x5(%rbp),%edi
call   1050 <ungetch@plt>
jmp    11e1 <main+0xa1>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    114f <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   1060 <getch@plt>
mov    0x2e95(%rip),%r15
jmp    1167 <main+0x27>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1060 <getch@plt>
cmp    (%r15),%al
je     11bf <main+0x7f>
movsbl %al,%ebx
mov    %ebx,%edi
call   1040 <isdigit@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1030 <putchar@plt>
test   %r14,%r14
je     1160 <main+0x20>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1060 <getch@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     11b0 <main+0x70>
movsbl %bl,%edi
call   1030 <putchar@plt>
jmp    1190 <main+0x50>
cmp    (%r15),%bl
je     1160 <main+0x20>
movsbl %bl,%edi
call   1050 <ungetch@plt>
jmp    1160 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %36, %0
%4 = call signext i8 (...) @getch()
store i8 %4, i8* %2
%5 = sext i8 %4 to i32
%6 = load i8, i8* @EOF
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %5, %7
br i1 %8, label %9, label %37
9: ; preds = %3
%10 = load i8, i8* %2
%11 = call i64 @isdigit(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %9
%14 = load i8, i8* %2
%15 = call i32 @putchar(i8 signext %14)
br label %16
16: ; preds = %20, %13
%17 = call signext i8 (...) @getch()
store i8 %17, i8* %2
%18 = call i64 @isdigit(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i8, i8* %2
%22 = call i32 @putchar(i8 signext %21)
br label %16
23: ; preds = %16
%24 = load i8, i8* %2
%25 = sext i8 %24 to i32
%26 = load i8, i8* @EOF
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %25, %27
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = load i8, i8* %2
%31 = call i32 @ungetch(i8 signext %30)
br label %32
32: ; preds = %29, %23
br label %36
33: ; preds = %9
%34 = load i8, i8* %2
%35 = call i32 @putchar(i8 signext %34)
br label %36
36: ; preds = %33, %32
br label %3
37: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @main() {
%1 = tail call signext i8 (...) @getch()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %29, label %4
4: ; preds = %0, %25
%5 = phi i8 [ %26, %25 ], [ %1, %0 ]
%6 = tail call i64 @isdigit(i8 signext %5)
%7 = icmp eq i64 %6, 0
%8 = tail call i32 @putchar(i8 signext %5)
br i1 %7, label %25, label %9
9: ; preds = %4
%10 = tail call signext i8 (...) @getch()
%11 = tail call i64 @isdigit(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %9, %13
%14 = phi i8 [ %16, %13 ], [ %10, %9 ]
%15 = tail call i32 @putchar(i8 signext %14)
%16 = tail call signext i8 (...) @getch()
%17 = tail call i64 @isdigit(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %13
19: ; preds = %13, %9
%20 = phi i8 [ %10, %9 ], [ %16, %13 ]
%21 = load i8, i8* @EOF
%22 = icmp eq i8 %20, %21
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = tail call i32 @ungetch(i8 signext %20)
br label %25
25: ; preds = %4, %19, %23
%26 = tail call signext i8 (...) @getch()
%27 = load i8, i8* @EOF
%28 = icmp eq i8 %26, %27
br i1 %28, label %29, label %4
29: ; preds = %25, %0
ret i32 0
}