#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 get_blank_length(int, int);
int getchar();
int /*<<< orphan*/ putchar(int);
int main(void) {
  int cur_char;
  int cur_line_length;
  int cur_blank_length;
  int blank_index;
  cur_line_length = 0;
  while ((cur_char = getchar()) != EOF) {
    if (cur_char == '\n') {
      cur_line_length = 0;
    } else if (cur_char == '\t') {
      cur_blank_length = get_blank_length(cur_line_length, 4);
      for (blank_index = 0; blank_index < cur_blank_length; blank_index++) {
        putchar('^');
      }
      cur_line_length += cur_blank_length;
    } else {
      cur_line_length += 1;
    }
    if (cur_char != '\t') {
      putchar(cur_char);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
je     11ed <main+0xbd>
cmpl   $0xa,-0x8(%rbp)
jne    1175 <main+0x45>
movl   $0x0,-0xc(%rbp)
jmp    11d6 <main+0xa6>
cmpl   $0x9,-0x8(%rbp)
jne    11c8 <main+0x98>
mov    -0xc(%rbp),%edi
mov    $0x4,%esi
call   1040 <get_blank_length@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ba <main+0x8a>
mov    $0x5e,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1196 <main+0x66>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11d1 <main+0xa1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d6 <main+0xa6>
cmpl   $0x9,-0x8(%rbp)
je     11e8 <main+0xb8>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2ea3(%rip),%r14
cmp    (%r14),%eax
jne    1157 <main+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r15d,%r15d
jmp    1177 <main+0x47>
nopl   0x0(%rax)
add    $0x1,%r15d
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
je     114a <main+0x1a>
cmp    $0xa,%eax
je     11c0 <main+0x90>
cmp    $0x9,%eax
jne    1160 <main+0x30>
mov    %r15d,%edi
mov    $0x4,%esi
call   1040 <get_blank_length@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    11af <main+0x7f>
mov    %ebx,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    $0x5e,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11a0 <main+0x70>
add    %ebx,%r15d
jmp    116b <main+0x3b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %r15d,%r15d
jmp    1164 <main+0x34>

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* %3
br label %6
6: ; preds = %43, %0
%7 = call i32 (...) @getchar()
store i32 %7, i32* %2
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %44
10: ; preds = %6
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 10
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 0, i32* %3
br label %37
14: ; preds = %10
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 9
br i1 %16, label %17, label %33
17: ; preds = %14
%18 = load i32, i32* %3
%19 = call i32 @get_blank_length(i32 %18, i32 4)
store i32 %19, i32* %4
store i32 0, i32* %5
br label %20
20: ; preds = %26, %17
%21 = load i32, i32* %5
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = call i32 @putchar(i32 94)
br label %26
26: ; preds = %24
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %20
29: ; preds = %20
%30 = load i32, i32* %4
%31 = load i32, i32* %3
%32 = add nsw i32 %31, %30
store i32 %32, i32* %3
br label %36
33: ; preds = %14
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %36
36: ; preds = %33, %29
br label %37
37: ; preds = %36, %13
%38 = load i32, i32* %2
%39 = icmp ne i32 %38, 9
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load i32, i32* %2
%42 = call i32 @putchar(i32 %41)
br label %43
43: ; preds = %40, %37
br label %6
44: ; 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 %27, label %4
4: ; preds = %0, %22
%5 = phi i32 [ %24, %22 ], [ %1, %0 ]
%6 = phi i32 [ %23, %22 ], [ 0, %0 ]
switch i32 %5, label %15 [
i32 10, label %19
i32 9, label %7
]
7: ; preds = %4
%8 = tail call i32 @get_blank_length(i32 %6, i32 4)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %7, %10
%11 = phi i32 [ %13, %10 ], [ 0, %7 ]
%12 = tail call i32 @putchar(i32 94)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, %8
br i1 %14, label %17, label %10
15: ; preds = %4
%16 = add nsw i32 %6, 1
br label %19
17: ; preds = %10, %7
%18 = add nsw i32 %8, %6
br label %22
19: ; preds = %15, %4
%20 = phi i32 [ 0, %4 ], [ %16, %15 ]
%21 = tail call i32 @putchar(i32 %5)
br label %22
22: ; preds = %17, %19
%23 = phi i32 [ %20, %19 ], [ %18, %17 ]
%24 = tail call i32 (...) @getchar()
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %4
27: ; preds = %22, %0
ret i32 0
}