#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int main(int argc, char *argv[]) {
  FILE *in, *out;
  in = fopen("output.dat", "r");
  if (in == NULL) {
    perror("output.dat");
    return 1;
  }
  out = fopen("input.dat", "w");
  if (out == NULL) {
    perror("input.dat");
    return 1;
  }
  char ch;
  int nb;
  int nt;
  int pos;
  nb = 0;
  nt = 0;
  for (pos = 0; (ch = fgetc(in)) != EOF; pos++) {
    if (ch == ' ') {
      if (pos % 8 != 0) {
        nb++;
      } else {
        nb = 0;
        nt++;
      }
    } else {
      while (nt > 0) {
        fputc('\t', out);
        nt--;
      }
      if (ch == '\t') {
        nb = 0;
      } else {
        while (nb > 0) {
          fputc(' ', out);
          nb--;
        }
      }
      fputc(ch, out);
      if (ch == '\n') {
        pos = 0;
      } else if (ch == '\t') {
        pos = pos + (8 - pos % 8) - 1;
      }
    }
  }
  fclose(in);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a0 <main+0x50>
lea    0xe71(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1356 <main+0x206>
lea    0xe66(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11da <main+0x8a>
lea    0xe44(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1356 <main+0x206>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2de3(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     133d <main+0x1ed>
movsbl -0x21(%rbp),%eax
cmp    $0x20,%eax
jne    1254 <main+0x104>
mov    -0x30(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     123f <main+0xef>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    124f <main+0xff>
movl   $0x0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    132a <main+0x1da>
jmp    1259 <main+0x109>
cmpl   $0x0,-0x2c(%rbp)
jle    127f <main+0x12f>
mov    -0x20(%rbp),%rsi
mov    $0x9,%edi
call   1050 <fputc@plt>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    1259 <main+0x109>
movsbl -0x21(%rbp),%eax
cmp    $0x9,%eax
jne    1298 <main+0x148>
movl   $0x0,-0x28(%rbp)
jmp    12c8 <main+0x178>
jmp    129d <main+0x14d>
cmpl   $0x0,-0x28(%rbp)
jle    12c3 <main+0x173>
mov    -0x20(%rbp),%rsi
mov    $0x20,%edi
call   1050 <fputc@plt>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    129d <main+0x14d>
jmp    12c8 <main+0x178>
mov    -0x21(%rbp),%al
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
movsbl -0x21(%rbp),%eax
cmp    $0xa,%eax
jne    12f0 <main+0x1a0>
movl   $0x0,-0x30(%rbp)
jmp    1325 <main+0x1d5>
movsbl -0x21(%rbp),%eax
cmp    $0x9,%eax
jne    1320 <main+0x1d0>
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x34(%rbp),%eax
mov    $0x8,%ecx
sub    %edx,%ecx
add    %ecx,%eax
sub    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1325 <main+0x1d5>
jmp    132a <main+0x1da>
jmp    132f <main+0x1df>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11ef <main+0x9f>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     12cf <main+0x17f>
lea    0xe8b(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     12d8 <main+0x188>
mov    %rax,%rbx
mov    (%rsp),%rdi
call   1040 <fgetc@plt>
mov    %eax,%r13d
mov    0x2e3b(%rip),%rax
cmp    (%rax),%r13b
jne    11d4 <main+0x84>
mov    (%rsp),%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r12d,%r12d
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    1202 <main+0xb2>
xchg   %ax,%ax
mov    %eax,%r12d
add    $0x1,%r12d
mov    (%rsp),%rdi
call   1040 <fgetc@plt>
mov    %eax,%r13d
mov    %r14d,%r15d
mov    0x2deb(%rip),%rax
cmp    (%rax),%r13b
je     11b2 <main+0x62>
cmp    $0x20,%r13b
jne    1220 <main+0xd0>
test   $0x7,%r12b
je     1279 <main+0x129>
add    $0x1,%r15d
mov    %r15d,%r14d
jmp    11e3 <main+0x93>
nopw   0x0(%rax,%rax,1)
test   %ebp,%ebp
jle    1247 <main+0xf7>
add    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x9,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1230 <main+0xe0>
xor    %ebp,%ebp
xor    %r14d,%r14d
cmp    $0x9,%r13b
je     1290 <main+0x140>
test   %r15d,%r15d
jle    1284 <main+0x134>
add    $0x1,%r15d
nopl   0x0(%rax)
mov    $0x20,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
add    $0xffffffff,%r15d
cmp    $0x1,%r15d
ja     1260 <main+0x110>
jmp    1290 <main+0x140>
add    $0x1,%ebp
xor    %r14d,%r14d
jmp    11e3 <main+0x93>
mov    %r15d,%r14d
nopw   0x0(%rax,%rax,1)
movsbl %r13b,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
mov    %r12d,%eax
cmp    $0xa,%r13b
mov    $0x0,%ecx
cmove  %ecx,%eax
je     11e0 <main+0x90>
cmp    $0x9,%r13b
jne    11e0 <main+0x90>
lea    0x7(%r12),%eax
test   %r12d,%r12d
cmovns %r12d,%eax
or     $0x7,%eax
jmp    11e0 <main+0x90>
lea    0xd2a(%rip),%rdi
jmp    12df <main+0x18f>
lea    0xd2e(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%eax
jmp    11c5 <main+0x75>

LLVM IR (-O0):
@.str = [11 x i8] c"output.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"input.dat\00"
@.str.3 = [2 x i8] c"w\00"
@EOF = global i8 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %6
%13 = load i32*, i32** %6
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %100
17: ; preds = %2
%18 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %18, i32** %7
%19 = load i32*, i32** %7
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %100
23: ; preds = %17
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %24
24: ; preds = %92, %23
%25 = load i32*, i32** %6
%26 = call signext i8 @fgetc(i32* %25)
store i8 %26, i8* %8
%27 = sext i8 %26 to i32
%28 = load i8, i8* @EOF
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %27, %29
br i1 %30, label %31, label %95
31: ; preds = %24
%32 = load i8, i8* %8
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 32
br i1 %34, label %35, label %46
35: ; preds = %31
%36 = load i32, i32* %11
%37 = srem i32 %36, 8
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %45
42: ; preds = %35
store i32 0, i32* %9
%43 = load i32, i32* %10
%44 = add nsw i32 %43, 1
store i32 %44, i32* %10
br label %45
45: ; preds = %42, %39
br label %91
46: ; preds = %31
br label %47
47: ; preds = %50, %46
%48 = load i32, i32* %10
%49 = icmp sgt i32 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %47
%51 = load i32*, i32** %7
%52 = call i32 @fputc(i8 signext 9, i32* %51)
%53 = load i32, i32* %10
%54 = add nsw i32 %53, -1
store i32 %54, i32* %10
br label %47
55: ; preds = %47
%56 = load i8, i8* %8
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 9
br i1 %58, label %59, label %60
59: ; preds = %55
store i32 0, i32* %9
br label %70
60: ; preds = %55
br label %61
61: ; preds = %64, %60
%62 = load i32, i32* %9
%63 = icmp sgt i32 %62, 0
br i1 %63, label %64, label %69
64: ; preds = %61
%65 = load i32*, i32** %7
%66 = call i32 @fputc(i8 signext 32, i32* %65)
%67 = load i32, i32* %9
%68 = add nsw i32 %67, -1
store i32 %68, i32* %9
br label %61
69: ; preds = %61
br label %70
70: ; preds = %69, %59
%71 = load i8, i8* %8
%72 = load i32*, i32** %7
%73 = call i32 @fputc(i8 signext %71, i32* %72)
%74 = load i8, i8* %8
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 10
br i1 %76, label %77, label %78
77: ; preds = %70
store i32 0, i32* %11
br label %90
78: ; preds = %70
%79 = load i8, i8* %8
%80 = sext i8 %79 to i32
%81 = icmp eq i32 %80, 9
br i1 %81, label %82, label %89
82: ; preds = %78
%83 = load i32, i32* %11
%84 = load i32, i32* %11
%85 = srem i32 %84, 8
%86 = sub nsw i32 8, %85
%87 = add nsw i32 %83, %86
%88 = sub nsw i32 %87, 1
store i32 %88, i32* %11
br label %89
89: ; preds = %82, %78
br label %90
90: ; preds = %89, %77
br label %91
91: ; preds = %90, %45
br label %92
92: ; preds = %91
%93 = load i32, i32* %11
%94 = add nsw i32 %93, 1
store i32 %94, i32* %11
br label %24
95: ; preds = %24
%96 = load i32*, i32** %6
%97 = call i32 @fclose(i32* %96)
%98 = load i32*, i32** %7
%99 = call i32 @fclose(i32* %98)
store i32 0, i32* %3
br label %100
100: ; preds = %95, %21, %15
%101 = load i32, i32* %3
ret i32 %101
}

LLVM IR (-O2):
@.str = [11 x i8] c"output.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"input.dat\00"
@.str.3 = [2 x i8] c"w\00"
@EOF = global i8 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %68
7: ; preds = %2
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call signext i8 @fgetc(i32* %3)
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %11, %12
br i1 %13, label %65, label %16
14: ; preds = %7
%15 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %68
16: ; preds = %10, %57
%17 = phi i8 [ %62, %57 ], [ %11, %10 ]
%18 = phi i32 [ %61, %57 ], [ 0, %10 ]
%19 = phi i32 [ %59, %57 ], [ 0, %10 ]
%20 = phi i32 [ %58, %57 ], [ 0, %10 ]
%21 = icmp eq i8 %17, 32
br i1 %21, label %24, label %22
22: ; preds = %16
%23 = icmp sgt i32 %19, 0
br i1 %23, label %31, label %36
24: ; preds = %16
%25 = and i32 %18, 7
%26 = icmp eq i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = add nsw i32 %20, 1
br label %57
29: ; preds = %24
%30 = add nsw i32 %19, 1
br label %57
31: ; preds = %22, %31
%32 = phi i32 [ %34, %31 ], [ %19, %22 ]
%33 = tail call i32 @fputc(i8 signext 9, i32* %8)
%34 = add nsw i32 %32, -1
%35 = icmp ugt i32 %32, 1
br i1 %35, label %31, label %36
36: ; preds = %31, %22
%37 = phi i32 [ %19, %22 ], [ 0, %31 ]
%38 = icmp eq i8 %17, 9
br i1 %38, label %46, label %39
39: ; preds = %36
%40 = icmp sgt i32 %20, 0
br i1 %40, label %41, label %46
41: ; preds = %39, %41
%42 = phi i32 [ %44, %41 ], [ %20, %39 ]
%43 = tail call i32 @fputc(i8 signext 32, i32* %8)
%44 = add nsw i32 %42, -1
%45 = icmp ugt i32 %42, 1
br i1 %45, label %41, label %46
46: ; preds = %41, %39, %36
%47 = phi i32 [ 0, %36 ], [ %20, %39 ], [ 0, %41 ]
%48 = tail call i32 @fputc(i8 signext %17, i32* %8)
%49 = icmp eq i8 %17, 10
%50 = xor i1 %38, true
%51 = or i1 %49, %50
%52 = select i1 %49, i32 0, i32 %18
br i1 %51, label %57, label %53
53: ; preds = %46
%54 = srem i32 %18, 8
%55 = add i32 %18, 7
%56 = sub i32 %55, %54
br label %57
57: ; preds = %46, %29, %27, %53
%58 = phi i32 [ %28, %27 ], [ 0, %29 ], [ %47, %53 ], [ %47, %46 ]
%59 = phi i32 [ %19, %27 ], [ %30, %29 ], [ %37, %53 ], [ %37, %46 ]
%60 = phi i32 [ %18, %27 ], [ %18, %29 ], [ %56, %53 ], [ %52, %46 ]
%61 = add nsw i32 %60, 1
%62 = tail call signext i8 @fgetc(i32* %3)
%63 = load i8, i8* @EOF
%64 = icmp eq i8 %62, %63
br i1 %64, label %65, label %16
65: ; preds = %57, %10
%66 = tail call i32 @fclose(i32* %3)
%67 = tail call i32 @fclose(i32* %8)
br label %68
68: ; preds = %65, %14, %5
%69 = phi i32 [ 1, %5 ], [ 1, %14 ], [ 0, %65 ]
ret i32 %69
}