#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(void) {
  int c;
  int pos;
  int spaces;
  pos = 0;
  while ((c = getchar()) != EOF) {
    if (c == '\n') {
      putchar(c);
      pos = 0;
    } else if (c == '\t') {
      spaces = 8 - (pos % 8);
      while (spaces-- != 0) {
        putchar(' ');
        ++pos;
      }
    } else {
      putchar(c);
      ++pos;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2ea1(%rip),%rcx
cmp    (%rcx),%eax
je     11d8 <main+0xb8>
cmpl   $0xa,-0x8(%rbp)
jne    116d <main+0x4d>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x0,-0xc(%rbp)
jmp    11d3 <main+0xb3>
cmpl   $0x9,-0x8(%rbp)
jne    11bd <main+0x9d>
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    $0x8,%eax
sub    %edx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x0,%eax
je     11b8 <main+0x98>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118c <main+0x6c>
jmp    11ce <main+0xae>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d3 <main+0xb3>
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb3(%rip),%r14
cmp    (%r14),%eax
jne    1147 <main+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
jmp    1166 <main+0x46>
nopl   0x0(%rax,%rax,1)
mov    %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
je     113a <main+0x1a>
cmp    $0x9,%eax
je     1180 <main+0x60>
cmp    $0xa,%eax
jne    1150 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
jmp    115a <main+0x3a>
xchg   %ax,%ax
lea    0x7(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffff8,%eax
mov    %ebx,%r15d
sub    %eax,%r15d
neg    %eax
mov    %ebx,%ecx
add    $0x8,%ebx
lea    (%rcx,%rax,1),%ebp
add    $0xfffffff8,%ebp
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
inc    %ebp
jne    11a0 <main+0x80>
sub    %r15d,%ebx
jmp    115a <main+0x3a>

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

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