#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 uint32_t;
typedef char int32_t;

/* Variables and functions */
char EOF;
int EXIT_SUCCESS;
char getchar();
int /*<<< orphan*/ printf(char *, int, char);
int /*<<< orphan*/ putchar(char);
int main(void) {
  int32_t character = 0;
  uint32_t line_length = 0;
  uint32_t tab_width = 8;
  while ((character = getchar()) != EOF) {
    if (character == '\t') {
      uint32_t spaces_to_add = tab_width - (line_length % tab_width);
      printf("%*c", spaces_to_add, ' ');
      line_length += spaces_to_add;
    } else {
      putchar(character);
      line_length = (character != '\n') ? line_length + 1 : 0;
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x8,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e83(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ed <main+0xbd>
movsbl -0x5(%rbp),%eax
cmp    $0x9,%eax
jne    11b4 <main+0x84>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    -0x18(%rbp),%eax
sub    %edx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe64(%rip),%rdi
mov    $0x20,%edx
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11e8 <main+0xb8>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
je     11d8 <main+0xa8>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e2 <main+0xb2>
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e2 <main+0xb2>
mov    -0x1c(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <main+0x21>
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9f(%rip),%r12
cmp    (%r12),%al
jne    1161 <main+0x31>
mov    0x2e82(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
lea    0xe96(%rip),%r14
xor    %ebp,%ebp
jmp    1191 <main+0x61>
xchg   %ax,%ax
movsbl %bl,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    $0xa,%bl
cmove  %r15d,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    (%r12),%al
je     114f <main+0x1f>
cmp    $0x9,%bl
jne    1170 <main+0x40>
lea    0x7(%rbp),%ebx
test   %ebp,%ebp
cmovns %ebp,%ebx
and    $0xfffffff8,%ebx
sub    %ebp,%ebx
lea    0x8(%rbx),%esi
mov    %r14,%rdi
mov    $0x20,%edx
call   1040 <printf@plt>
add    %ebx,%ebp
add    $0x8,%ebp
jmp    1182 <main+0x52>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [4 x i8] c"%*c\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i8 0, i8* %2
store i32 0, i32* %3
store i32 8, i32* %4
br label %6
6: ; preds = %39, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %2
%8 = sext i8 %7 to i32
%9 = load i8, i8* @EOF
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %40
12: ; preds = %6
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 9
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = srem i32 %18, %19
%21 = sub nsw i32 %17, %20
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22, i8 signext 32)
%24 = load i32, i32* %5
%25 = load i32, i32* %3
%26 = add nsw i32 %25, %24
store i32 %26, i32* %3
br label %39
27: ; preds = %12
%28 = load i8, i8* %2
%29 = call i32 @putchar(i8 signext %28)
%30 = load i8, i8* %2
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 10
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
br label %37
36: ; preds = %27
br label %37
37: ; preds = %36, %33
%38 = phi i32 [ %35, %33 ], [ 0, %36 ]
store i32 %38, i32* %3
br label %39
39: ; preds = %37, %16
br label %6
40: ; preds = %6
%41 = load i32, i32* @EXIT_SUCCESS
ret i32 %41
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [4 x i8] c"%*c\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %23, label %4
4: ; preds = %0, %18
%5 = phi i8 [ %20, %18 ], [ %1, %0 ]
%6 = phi i32 [ %19, %18 ], [ 0, %0 ]
%7 = icmp eq i8 %5, 9
br i1 %7, label %8, label %13
8: ; preds = %4
%9 = srem i32 %6, 8
%10 = sub nsw i32 8, %9
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10, i8 signext 32)
%12 = add nsw i32 %10, %6
br label %18
13: ; preds = %4
%14 = tail call i32 @putchar(i8 signext %5)
%15 = icmp eq i8 %5, 10
%16 = add nsw i32 %6, 1
%17 = select i1 %15, i32 0, i32 %16
br label %18
18: ; preds = %13, %8
%19 = phi i32 [ %12, %8 ], [ %17, %13 ]
%20 = tail call signext i8 (...) @getchar()
%21 = load i8, i8* @EOF
%22 = icmp eq i8 %20, %21
br i1 %22, label %23, label %4
23: ; preds = %18, %0
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}