#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 i, c, cursor = 0, expansion = 0;
  while ((c = getchar()) != EOF) {
    switch (c) {
    case '\t':
      expansion = 4 - (cursor % 4);
      for (i = 0; i < expansion; ++i) {
        putchar(' ');
      }
      break;
    case '\n':
      putchar(c);
      cursor = 0;
      break;
    default:
      putchar(c);
      ++cursor;
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%eax
je     11ea <main+0xca>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x9,%eax
je     117b <main+0x5b>
jmp    116a <main+0x4a>
mov    -0x18(%rbp),%eax
sub    $0xa,%eax
je     11c0 <main+0xa0>
jmp    11d4 <main+0xb4>
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    $0x4,%eax
sub    %edx,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bb <main+0x9b>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1197 <main+0x77>
jmp    11e5 <main+0xc5>
mov    -0xc(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x0,-0x10(%rbp)
jmp    11e5 <main+0xc5>
mov    -0xc(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb6(%rip),%r14
cmp    (%r14),%eax
jne    113e <main+0x1e>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebx,%ebx
jmp    1166 <main+0x46>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
je     1137 <main+0x17>
cmp    $0xa,%eax
je     11a0 <main+0x80>
cmp    $0x9,%eax
jne    1150 <main+0x30>
lea    0x3(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffffc,%eax
neg    %eax
lea    (%rbx,%rax,1),%ebp
add    $0xfffffffc,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
inc    %ebp
jne    1190 <main+0x70>
jmp    115a <main+0x3a>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%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
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %34, %0
%7 = call i32 (...) @getchar()
store i32 %7, i32* %3
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %35
10: ; preds = %6
%11 = load i32, i32* %3
switch i32 %11, label %29 [
i32 9, label %12
i32 10, label %26
]
12: ; preds = %10
%13 = load i32, i32* %4
%14 = srem i32 %13, 4
%15 = sub nsw i32 4, %14
store i32 %15, i32* %5
store i32 0, i32* %2
br label %16
16: ; preds = %22, %12
%17 = load i32, i32* %2
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = call i32 @putchar(i32 32)
br label %22
22: ; preds = %20
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %16
25: ; preds = %16
br label %34
26: ; preds = %10
%27 = load i32, i32* %3
%28 = call i32 @putchar(i32 %27)
store i32 0, i32* %4
br label %34
29: ; preds = %10
%30 = load i32, i32* %3
%31 = call i32 @putchar(i32 %30)
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %34
34: ; preds = %29, %26, %25
br label %6
35: ; preds = %6
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 %25, label %4
4: ; preds = %0, %20
%5 = phi i32 [ %22, %20 ], [ %1, %0 ]
%6 = phi i32 [ %21, %20 ], [ 0, %0 ]
switch i32 %5, label %17 [
i32 9, label %7
i32 10, label %15
]
7: ; preds = %4
%8 = srem i32 %6, 4
%9 = sub nsw i32 4, %8
br label %10
10: ; preds = %7, %10
%11 = phi i32 [ %13, %10 ], [ 0, %7 ]
%12 = tail call i32 @putchar(i32 32)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, %9
br i1 %14, label %20, label %10
15: ; preds = %4
%16 = tail call i32 @putchar(i32 10)
br label %20
17: ; preds = %4
%18 = tail call i32 @putchar(i32 %5)
%19 = add nsw i32 %6, 1
br label %20
20: ; preds = %10, %17, %15
%21 = phi i32 [ %19, %17 ], [ 0, %15 ], [ %6, %10 ]
%22 = tail call i32 (...) @getchar()
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %4
25: ; preds = %20, %0
ret i32 0
}