#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 */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ stripansi(char *);
int main(int argc, char *argv[]) {
  char foo[4096];
  while (fgets(foo, 4096, stdin)) {
    stripansi(foo);
    fputs(foo, stdout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1010(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%edx
mov    $0x1000,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1193 <main+0x63>
lea    -0x1010(%rbp),%rdi
call   1030 <stripansi@plt>
lea    -0x1010(%rbp),%rdi
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
jmp    1149 <main+0x19>
xor    %eax,%eax
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1000,%rsp
mov    0x2ea5(%rip),%r14
mov    (%r14),%edx
mov    %rsp,%rdi
mov    $0x1000,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1198 <main+0x68>
mov    %rsp,%rbx
mov    0x2e76(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <stripansi@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   1040 <fputs@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %12, %2
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i64 @fgets(i8* %8, i32 4096, i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%14 = call i32 @stripansi(i8* %13)
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%16 = load i32, i32* @stdout
%17 = call i32 @fputs(i8* %15, i32 %16)
br label %7
18: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i64 @fgets(i8* %4, i32 4096, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %2, %8
%9 = call i32 @stripansi(i8* %4)
%10 = load i32, i32* @stdout
%11 = call i32 @fputs(i8* %4, i32 %10)
%12 = load i32, i32* @stdin
%13 = call i64 @fgets(i8* %4, i32 4096, i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %8
15: ; preds = %8, %2
ret i32 0
}