#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 argc, char **argv) {
  size_t i = 1;
  int c;
  while ((c = getchar()) > EOF) {
    unsigned char j;
    switch (c) {
    case '\t':
      for (j = i; j <= 8; ++j)
        putchar(' ');
      i = 1;
      break;
    case '\n':
      putchar(c);
      i = 1;
      break;
    default:
      putchar(c);
      i = (i % 8) + 1;
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x1,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e99(%rip),%rcx
cmp    (%rcx),%eax
jle    11e6 <main+0xc6>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x9,%eax
je     117c <main+0x5c>
jmp    116b <main+0x4b>
mov    -0x24(%rbp),%eax
sub    $0xa,%eax
je     11b4 <main+0x94>
jmp    11c9 <main+0xa9>
mov    -0x18(%rbp),%rax
mov    %al,-0x1d(%rbp)
movzbl -0x1d(%rbp),%eax
cmp    $0x8,%eax
jg     11a7 <main+0x87>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x1d(%rbp),%al
add    $0x1,%al
mov    %al,-0x1d(%rbp)
jmp    1183 <main+0x63>
movq   $0x1,-0x18(%rbp)
jmp    11e1 <main+0xc1>
mov    -0x1c(%rbp),%edi
call   1030 <putchar@plt>
movq   $0x1,-0x18(%rbp)
jmp    11e1 <main+0xc1>
mov    -0x1c(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%rax
and    $0x7,%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113e <main+0x1e>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb6(%rip),%r14
cmp    (%r14),%eax
jle    11a1 <main+0x81>
mov    $0x1,%ebx
jmp    115a <main+0x3a>
xchg   %ax,%ax
mov    %eax,%edi
call   1030 <putchar@plt>
and    $0x7,%ebx
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
jle    11a1 <main+0x81>
cmp    $0xa,%eax
je     1190 <main+0x70>
cmp    $0x9,%eax
jne    1140 <main+0x20>
add    $0xf7,%bl
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
inc    %bl
jne    1170 <main+0x50>
mov    $0x1,%ebx
jmp    114e <main+0x2e>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebx
jmp    114e <main+0x2e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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