#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 */
char EOF;
char getchar();
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char input[1000];
  char c;
  int i, j;
  for (i = 0; (c = getchar()) != EOF && i < 1000 - 1; i++) {
    input[i] = c;
    if (c == '\t') {
      for (j = 0; j <= 4 - 1; j++)
        input[i + j] = ' ';
      i += j - 1;
    }
  }
  printf("%s\n", input);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3f8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x3f1(%rbp)
movsbl %al,%ecx
mov    0x2e95(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x3fd(%rbp)
je     1179 <main+0x59>
cmpl   $0x3e7,-0x3f8(%rbp)
setl   %al
mov    %al,-0x3fd(%rbp)
mov    -0x3fd(%rbp),%al
test   $0x1,%al
jne    118c <main+0x6c>
jmp    121f <main+0xff>
mov    -0x3f1(%rbp),%cl
movslq -0x3f8(%rbp),%rax
mov    %cl,-0x3f0(%rbp,%rax,1)
movsbl -0x3f1(%rbp),%eax
cmp    $0x9,%eax
jne    1206 <main+0xe6>
movl   $0x0,-0x3fc(%rbp)
cmpl   $0x3,-0x3fc(%rbp)
jg     11f1 <main+0xd1>
mov    -0x3f8(%rbp),%eax
add    -0x3fc(%rbp),%eax
cltq
movb   $0x20,-0x3f0(%rbp,%rax,1)
20
mov    -0x3fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3fc(%rbp)
jmp    11ba <main+0x9a>
mov    -0x3fc(%rbp),%eax
sub    $0x1,%eax
add    -0x3f8(%rbp),%eax
mov    %eax,-0x3f8(%rbp)
jmp    120b <main+0xeb>
mov    -0x3f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f8(%rbp)
jmp    113c <main+0x1c>
lea    -0x3f0(%rbp),%rsi
lea    0xdd3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb0(%rip),%r14
cmp    (%r14),%al
je     116f <main+0x4f>
xor    %ebx,%ebx
nop
movslq %ebx,%rcx
mov    %al,(%rsp,%rcx,1)
cmp    $0x9,%al
jne    1156 <main+0x36>
movl   $0x20202020,(%rsp,%rcx,1)
add    $0x3,%ecx
mov    %ecx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%al
je     116f <main+0x4f>
lea    0x1(%rbx),%ecx
cmp    $0x3e6,%ebx
mov    %ecx,%ebx
jl     1140 <main+0x20>
lea    0xe8a(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i8 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %44, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %3
%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 %15
12: ; preds = %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 999
br label %15
15: ; preds = %12, %6
%16 = phi i1 [ false, %6 ], [ %14, %12 ]
br i1 %16, label %17, label %47
17: ; preds = %15
%18 = load i8, i8* %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %20
store i8 %18, i8* %21
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 9
br i1 %24, label %25, label %43
25: ; preds = %17
store i32 0, i32* %5
br label %26
26: ; preds = %35, %25
%27 = load i32, i32* %5
%28 = icmp sle i32 %27, 3
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = load i32, i32* %4
%31 = load i32, i32* %5
%32 = add nsw i32 %30, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %33
store i8 32, i8* %34
br label %35
35: ; preds = %29
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %26
38: ; preds = %26
%39 = load i32, i32* %5
%40 = sub nsw i32 %39, 1
%41 = load i32, i32* %4
%42 = add nsw i32 %41, %40
store i32 %42, i32* %4
br label %43
43: ; preds = %38, %17
br label %44
44: ; preds = %43
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %6
47: ; preds = %15
%48 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%49 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %48)
ret i32 0
}

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