#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 /*<<< orphan*/ Put(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fileno(int /*<<< orphan*/);
char *print_copyright(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int main(void) {
  char buf[256];
  printf("%s", print_copyright(0, "ccat", buf, 256));
  while (fgets(buf, 256, stdin) != NULL)
    Put(buf);
  write(fileno(stdout), ("\x1b[0m\n"), strlen("\x1b[0m\n"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x110(%rbp),%rdx
xor    %edi,%edi
lea    0xe71(%rip),%rsi
mov    $0x100,%ecx
call   1090 <print_copyright@plt>
mov    %rax,%rsi
lea    0xe5a(%rip),%rdi
call   1060 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e2f(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     11e0 <main+0x70>
lea    -0x110(%rbp),%rdi
call   1030 <Put@plt>
jmp    11ab <main+0x3b>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
call   1080 <fileno@plt>
mov    %eax,-0x114(%rbp)
lea    0xe0d(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x114(%rbp),%edi
mov    %eax,%edx
lea    0xdf9(%rip),%rsi
call   1040 <write@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
lea    0xe82(%rip),%rsi
mov    %rsp,%rbx
xor    %edi,%edi
mov    %rbx,%rdx
mov    $0x100,%ecx
call   1090 <print_copyright@plt>
lea    0xe66(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    0x2e3f(%rip),%r14
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     11ed <main+0x7d>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <Put@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1070 <fgets@plt>
test   %rax,%rax
jne    11d0 <main+0x60>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
call   1080 <fileno@plt>
mov    %eax,%ebx
lea    0xe04(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"ccat\00"
@stdin = global i32 0
@stdout = global i32 0
@.str.2 = [6 x i8] c"\1B[0m\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i8* @print_copyright(i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 256)
%5 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %6
6: ; preds = %11, %0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32* @fgets(i8* %7, i32 256, i32 %8)
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%13 = call i32 @Put(i8* %12)
br label %6
14: ; preds = %6
%15 = load i32, i32* @stdout
%16 = call i32 @fileno(i32 %15)
%17 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @write(i32 %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"ccat\00"
@stdin = global i32 0
@stdout = global i32 0
@.str.2 = [6 x i8] c"\1B[0m\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i8* @print_copyright(i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 256)
%4 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = load i32, i32* @stdin
%6 = call i32* @fgets(i8* %2, i32 256, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %13, label %8
8: ; preds = %0, %8
%9 = call i32 @Put(i8* %2)
%10 = load i32, i32* @stdin
%11 = call i32* @fgets(i8* %2, i32 256, i32 %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %8
13: ; preds = %8, %0
%14 = load i32, i32* @stdout
%15 = call i32 @fileno(i32 %14)
%16 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @write(i32 %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %16)
ret i32 0
}