#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*/ putchar(int);
int main() {
  int pos = 0;
  int spaces = 0;
  int ch;
  do {
    ch = getchar();
    pos += ch == '\t' ? 2 : 1;
    if (ch == ' ') {
      spaces++;
      if (pos % 2 == 0) {
        putchar('\t');
        spaces = 0;
      }
    } else {
      int i;
      for (i = 0; i < spaces; i++) {
        putchar(' ');
      }
      spaces = 0;
      if (ch == '\n') {
        pos = 0;
      }
      if (ch != EOF) {
        putchar(ch);
      }
    }
  } while (ch != EOF);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edx
mov    $0x1,%eax
mov    $0x2,%ecx
cmp    $0x9,%edx
cmove  %ecx,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x20,-0x10(%rbp)
jne    119d <main+0x7d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1198 <main+0x78>
mov    $0x9,%edi
call   1030 <putchar@plt>
movl   $0x0,-0xc(%rbp)
jmp    11ff <main+0xdf>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c8 <main+0xa8>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a4 <main+0x84>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0x10(%rbp)
jne    11e0 <main+0xc0>
movl   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2dfe(%rip),%rcx
cmp    (%rcx),%eax
je     11fa <main+0xda>
mov    -0x10(%rbp),%edi
call   1030 <putchar@plt>
jmp    11ff <main+0xdf>
jmp    1204 <main+0xe4>
mov    -0x10(%rbp),%eax
mov    0x2dda(%rip),%rcx
cmp    (%rcx),%eax
jne    113d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2eba(%rip),%r14
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    114c <main+0x2c>
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <putchar@plt>
xor    %ebp,%ebp
cmp    (%r14),%ebx
je     11b1 <main+0x91>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
xor    %eax,%eax
cmp    $0x9,%ebx
sete   %al
add    %eax,%r15d
add    $0x1,%r15d
cmp    $0x20,%ebx
jne    1180 <main+0x60>
mov    $0x9,%edi
test   $0x1,%r15b
je     1140 <main+0x20>
add    $0x1,%ebp
jmp    1147 <main+0x27>
nopl   0x0(%rax)
test   %ebp,%ebp
jle    119f <main+0x7f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1190 <main+0x70>
xor    %ebp,%ebp
cmp    $0xa,%ebx
cmove  %ebp,%r15d
mov    %ebx,%edi
cmp    (%r14),%ebx
jne    1140 <main+0x20>
jmp    1147 <main+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %48, %0
%7 = call i32 (...) @getchar()
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 9
%10 = zext i1 %9 to i64
%11 = select i1 %9, i32 2, i32 1
%12 = load i32, i32* %2
%13 = add nsw i32 %12, %11
store i32 %13, i32* %2
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 32
br i1 %15, label %16, label %25
16: ; preds = %6
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
%19 = load i32, i32* %2
%20 = srem i32 %19, 2
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = call i32 @putchar(i32 9)
store i32 0, i32* %3
br label %24
24: ; preds = %22, %16
br label %47
25: ; preds = %6
store i32 0, i32* %5
br label %26
26: ; preds = %32, %25
%27 = load i32, i32* %5
%28 = load i32, i32* %3
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = call i32 @putchar(i32 32)
br label %32
32: ; preds = %30
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %26
35: ; preds = %26
store i32 0, i32* %3
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 10
br i1 %37, label %38, label %39
38: ; preds = %35
store i32 0, i32* %2
br label %39
39: ; preds = %38, %35
%40 = load i32, i32* %4
%41 = load i32, i32* @EOF
%42 = icmp ne i32 %40, %41
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i32, i32* %4
%45 = call i32 @putchar(i32 %44)
br label %46
46: ; preds = %43, %39
br label %47
47: ; preds = %46, %24
br label %48
48: ; preds = %47
%49 = load i32, i32* %4
%50 = load i32, i32* @EOF
%51 = icmp ne i32 %49, %50
br i1 %51, label %6, label %52
52: ; preds = %48
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @main() {
br label %1
1: ; preds = %29, %0
%2 = phi i32 [ 0, %0 ], [ %30, %29 ]
%3 = phi i32 [ 0, %0 ], [ %31, %29 ]
%4 = tail call i32 (...) @getchar()
%5 = icmp eq i32 %4, 9
%6 = select i1 %5, i32 2, i32 1
%7 = add nsw i32 %6, %3
%8 = icmp eq i32 %4, 32
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = icmp sgt i32 %2, 0
br i1 %10, label %15, label %20
11: ; preds = %1
%12 = add nsw i32 %2, 1
%13 = and i32 %7, 1
%14 = icmp eq i32 %13, 0
br i1 %14, label %25, label %29
15: ; preds = %9, %15
%16 = phi i32 [ %18, %15 ], [ 0, %9 ]
%17 = tail call i32 @putchar(i32 32)
%18 = add nuw nsw i32 %16, 1
%19 = icmp eq i32 %18, %2
br i1 %19, label %20, label %15
20: ; preds = %15, %9
%21 = icmp eq i32 %4, 10
%22 = select i1 %21, i32 0, i32 %7
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %4, %23
br i1 %24, label %29, label %25
25: ; preds = %20, %11
%26 = phi i32 [ 9, %11 ], [ %4, %20 ]
%27 = phi i32 [ %7, %11 ], [ %22, %20 ]
%28 = tail call i32 @putchar(i32 %26)
br label %29
29: ; preds = %25, %20, %11
%30 = phi i32 [ %12, %11 ], [ 0, %20 ], [ 0, %25 ]
%31 = phi i32 [ %7, %11 ], [ %22, %20 ], [ %27, %25 ]
%32 = load i32, i32* @EOF
%33 = icmp eq i32 %4, %32
br i1 %33, label %34, label %1
34: ; preds = %29
ret i32 0
}