#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*/ errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int write(int, char *, int);
int main(int argc) {
  char s1[] = "................................"
              "................................";
  char buf[10240];
  int c, rc1, rc2;
  if (argc != 1) {
    fprintf(
        stderr,
        "ccat (counting cat) Version "
        "2000-06-15"
        "\n"
        "Copyright (C) 2000  Clifford Wolf, Thomas Baumgartner\n"
        "\n"
        "     This program is free software; you can redistribute it and/or "
        "modify\n"
        "     it under the terms of the GNU General Public License as "
        "published by\n"
        "     the Free Software Foundation; either version 2 of the License, "
        "or\n"
        "     (at your option) any later version.\n"
        "\n"
        "     This program is distributed in the hope that it will be useful,\n"
        "     but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
        "     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
        "     GNU General Public License for more details.\n"
        "\n"
        "     You should have received a copy of the GNU General Public "
        "License\n"
        "     along with this program; if not, write to the Free Software\n"
        "     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA "
        "02111-1307, USA.\n"
        "\n"
        "Usage:  `ccat' reads from its stdin and writes to stdout. No command "
        "line\n"
        "        arguments ar allowed. A status bar is printed to stderr.\n\n");
    fflush(stderr);
    return 1;
  }
  c = 1024;
  rc1 = rc2 = 0;
  while (1) {
    if (c % 1024 == 0) {
      fprintf(stderr, "\r%6d0 MB [%s]\r%6d0 MB [", c / 1024, s1, c / 1024);
      fflush(stderr);
    }
    if ((rc1 = read(0, buf, 10240)) <= 0) {
      rc2 = rc1;
      break;
    }
    if (c % 16 == 0) {
      fprintf(stderr, "X");
      fflush(stderr);
    }
    if ((rc2 = write(1, buf, rc1)) != rc1)
      break;
    c++;
  }
  if (rc1 == -1) {
    fprintf(stderr, "\nRead ERROR: %s\n", strerror(errno));
  } else if (rc2 == -1) {
    fprintf(stderr, "\nWrite ERROR: %s\n", strerror(errno));
  } else if (rc2 != rc1) {
    fprintf(stderr,
            "\nWrite ERROR: Only %d of %d bytes "
            "in the last block has been written.\n",
            rc2, rc1);
  } else
    fprintf(stderr, "\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2870,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe80(%rip),%rsi
mov    $0x41,%edx
call   1060 <memcpy@plt>
cmpl   $0x1,-0x8(%rbp)
je     11c5 <main+0x65>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
movl   $0x1,-0x4(%rbp)
jmp    13ed <main+0x28d>
movl   $0x400,-0x2854(%rbp)
movl   $0x0,-0x285c(%rbp)
movl   $0x0,-0x2858(%rbp)
mov    -0x2854(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    124e <main+0xee>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
mov    -0x2854(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2860(%rbp)
lea    -0x50(%rbp),%rcx
mov    -0x2854(%rbp),%eax
mov    $0x400,%esi
cltd
idiv   %esi
mov    -0x2860(%rbp),%edx
mov    %eax,%r8d
lea    0x11d0(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x2850(%rbp),%rsi
xor    %edi,%edi
mov    $0x2800,%edx
call   1040 <read@plt>
mov    %eax,-0x2858(%rbp)
cmp    $0x0,%eax
jg     1281 <main+0x121>
mov    -0x2858(%rbp),%eax
mov    %eax,-0x285c(%rbp)
jmp    12ff <main+0x19f>
mov    -0x2854(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12bd <main+0x15d>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    0x1179(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x2850(%rbp),%rsi
mov    -0x2858(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    %eax,-0x285c(%rbp)
cmp    -0x2858(%rbp),%eax
je     12eb <main+0x18b>
jmp    12ff <main+0x19f>
mov    -0x2854(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2854(%rbp)
jmp    11e3 <main+0x83>
cmpl   $0xffffffff,-0x2858(%rbp)
jne    1345 <main+0x1e5>
mov    0x2ccd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2864(%rbp)
mov    0x2cb6(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x2864(%rbp),%edi
mov    %rax,%rdx
lea    0x10ea(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    13e6 <main+0x286>
cmpl   $0xffffffff,-0x285c(%rbp)
jne    138b <main+0x22b>
mov    0x2c87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2868(%rbp)
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x2868(%rbp),%edi
mov    %rax,%rdx
lea    0x10b5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    13e1 <main+0x281>
mov    -0x285c(%rbp),%eax
cmp    -0x2858(%rbp),%eax
je     13c5 <main+0x265>
mov    0x2c3c(%rip),%rax
mov    (%rax),%edi
mov    -0x285c(%rbp),%edx
mov    -0x2858(%rbp),%ecx
lea    0x108d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    13dc <main+0x27c>
mov    0x2c14(%rip),%rax
mov    (%rax),%edi
lea    0x1032(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    13e1 <main+0x281>
jmp    13e6 <main+0x286>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2870,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2858,%rsp
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe90(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe74(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x40(%rsp)
cmp    $0x1,%edi
jne    123f <main+0xef>
mov    $0x400,%r14d
mov    0x2e35(%rip),%r13
mov    %rsp,%r15
lea    0x50(%rsp),%rbx
lea    0x1267(%rip),%r12
jmp    11db <main+0x8b>
nopl   0x0(%rax)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <write@plt>
add    $0x1,%r14d
cmp    %ebp,%eax
jne    126b <main+0x11b>
test   $0x3ff,%r14d
jne    120b <main+0xbb>
mov    0x0(%r13),%edi
mov    %r14d,%edx
shr    $0xa,%edx
lea    0x1214(%rip),%rsi
mov    %r15,%rcx
mov    %edx,%r8d
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%r13),%edi
call   1060 <fflush@plt>
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x2800,%edx
call   1040 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1264 <main+0x114>
test   $0xf,%r14b
jne    11c0 <main+0x70>
mov    0x0(%r13),%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%r13),%edi
call   1060 <fflush@plt>
jmp    11c0 <main+0x70>
mov    0x2d9a(%rip),%rbx
mov    (%rbx),%edi
lea    0xdf2(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
call   1060 <fflush@plt>
mov    $0x1,%ebx
jmp    12e2 <main+0x192>
mov    %ebp,%eax
cmp    $0xffffffff,%ebp
je     12bb <main+0x16b>
cmp    $0xffffffff,%eax
je     128a <main+0x13a>
mov    0x0(%r13),%edi
cmp    %ebp,%eax
jne    12a5 <main+0x155>
lea    0x1188(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    12e2 <main+0x192>
mov    0x0(%r13),%ebp
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0x1191(%rip),%rsi
jmp    12d4 <main+0x184>
lea    0x119a(%rip),%rsi
xor    %ebx,%ebx
mov    %eax,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    12e2 <main+0x192>
mov    0x0(%r13),%ebp
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0x114f(%rip),%rsi
xor    %ebx,%ebx
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebx,%eax
add    $0x2858,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.s1 = [65 x i8] c"................................................................\00"
@stderr = global i32 0
@.str = [968 x i8] c"ccat (counting cat) Version 2000-06-15\0ACopyright (C) 2000 Clifford Wolf, Thomas Baumgartner\0A\0A This program is free software; you can redistribute it and/or modify\0A it under the terms of the GNU General Public License as published by\0A the Free Software Foundation; either version 2 of the License, or\0A (at your option) any later version.\0A\0A This program is distributed in the hope that it will be useful,\0A but WITHOUT ANY WARRANTY; without even the implied warranty of\0A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\0A GNU General Public License for more details.\0A\0A You should have received a copy of the GNU General Public License\0A along with this program; if not, write to the Free Software\0A Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\0A\0AUsage: `ccat' reads from its stdin and writes to stdout. No command line\0A arguments ar allowed. A status bar is printed to stderr.\0A\0A\00"
@.str.1 = [24 x i8] c"\0D%6d0 MB [%s]\0D%6d0 MB [\00"
@.str.2 = [2 x i8] c"X\00"
@.str.3 = [17 x i8] c"\0ARead ERROR: %s\0A\00"
@errno = global i32 0
@.str.4 = [18 x i8] c"\0AWrite ERROR: %s\0A\00"
@.str.5 = [71 x i8] c"\0AWrite ERROR: Only %d of %d bytes in the last block has been written.\0A\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [65 x i8]
%5 = alloca [10240 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %2
store i32 %0, i32* %3
%9 = bitcast [65 x i8]* %4 to i8*
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([968 x i8], [968 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = call i32 @fflush(i32 %15)
store i32 1, i32* %2
br label %88
17: ; preds = %1
store i32 1024, i32* %6
store i32 0, i32* %8
store i32 0, i32* %7
br label %18
18: ; preds = %17, %54
%19 = load i32, i32* %6
%20 = srem i32 %19, 1024
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = load i32, i32* %6
%25 = sdiv i32 %24, 1024
%26 = getelementptr inbounds [65 x i8], [65 x i8]* %4, i64 0, i64 0
%27 = load i32, i32* %6
%28 = sdiv i32 %27, 1024
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %25, i8* %26, i32 %28)
%30 = load i32, i32* @stderr
%31 = call i32 @fflush(i32 %30)
br label %32
32: ; preds = %22, %18
%33 = getelementptr inbounds [10240 x i8], [10240 x i8]* %5, i64 0, i64 0
%34 = call i32 @read(i32 0, i8* %33, i32 10240)
store i32 %34, i32* %7
%35 = icmp sle i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load i32, i32* %7
store i32 %37, i32* %8
br label %57
38: ; preds = %32
%39 = load i32, i32* %6
%40 = srem i32 %39, 16
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %38
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%45 = load i32, i32* @stderr
%46 = call i32 @fflush(i32 %45)
br label %47
47: ; preds = %42, %38
%48 = getelementptr inbounds [10240 x i8], [10240 x i8]* %5, i64 0, i64 0
%49 = load i32, i32* %7
%50 = call i32 @write(i32 1, i8* %48, i32 %49)
store i32 %50, i32* %8
%51 = load i32, i32* %7
%52 = icmp ne i32 %50, %51
br i1 %52, label %53, label %54
53: ; preds = %47
br label %57
54: ; preds = %47
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %18
57: ; preds = %53, %36
%58 = load i32, i32* %7
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %65
60: ; preds = %57
%61 = load i32, i32* @stderr
%62 = load i32, i32* @errno
%63 = call i8* @strerror(i32 %62)
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %63)
br label %87
65: ; preds = %57
%66 = load i32, i32* %8
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %73
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = load i32, i32* @errno
%71 = call i8* @strerror(i32 %70)
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %71)
br label %86
73: ; preds = %65
%74 = load i32, i32* %8
%75 = load i32, i32* %7
%76 = icmp ne i32 %74, %75
br i1 %76, label %77, label %82
77: ; preds = %73
%78 = load i32, i32* @stderr
%79 = load i32, i32* %8
%80 = load i32, i32* %7
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0), i32 %79, i32 %80)
br label %85
82: ; preds = %73
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %85
85: ; preds = %82, %77
br label %86
86: ; preds = %85, %68
br label %87
87: ; preds = %86, %60
store i32 0, i32* %2
br label %88
88: ; preds = %87, %12
%89 = load i32, i32* %2
ret i32 %89
}

LLVM IR (-O2):
@__const.main.s1 = [65 x i8] c"................................................................\00"
@stderr = global i32 0
@.str = [968 x i8] c"ccat (counting cat) Version 2000-06-15\0ACopyright (C) 2000 Clifford Wolf, Thomas Baumgartner\0A\0A This program is free software; you can redistribute it and/or modify\0A it under the terms of the GNU General Public License as published by\0A the Free Software Foundation; either version 2 of the License, or\0A (at your option) any later version.\0A\0A This program is distributed in the hope that it will be useful,\0A but WITHOUT ANY WARRANTY; without even the implied warranty of\0A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\0A GNU General Public License for more details.\0A\0A You should have received a copy of the GNU General Public License\0A along with this program; if not, write to the Free Software\0A Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\0A\0AUsage: `ccat' reads from its stdin and writes to stdout. No command line\0A arguments ar allowed. A status bar is printed to stderr.\0A\0A\00"
@.str.1 = [24 x i8] c"\0D%6d0 MB [%s]\0D%6d0 MB [\00"
@.str.2 = [2 x i8] c"X\00"
@.str.3 = [17 x i8] c"\0ARead ERROR: %s\0A\00"
@errno = global i32 0
@.str.4 = [18 x i8] c"\0AWrite ERROR: %s\0A\00"
@.str.5 = [71 x i8] c"\0AWrite ERROR: Only %d of %d bytes in the last block has been written.\0A\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0) {
%2 = alloca [65 x i8]
%3 = alloca [10240 x i8]
%4 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 0
%6 = icmp eq i32 %0, 1
br i1 %6, label %12, label %7
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([968 x i8], [968 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = tail call i32 @fflush(i32 %10)
br label %59
12: ; preds = %1, %33
%13 = phi i32 [ %36, %33 ], [ 1024, %1 ]
%14 = and i32 %13, 1023
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = lshr i32 %13, 10
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %4, i32 %18)
%20 = load i32, i32* @stderr
%21 = call i32 @fflush(i32 %20)
br label %22
22: ; preds = %16, %12
%23 = call i32 @read(i32 0, i8* %5, i32 10240)
%24 = icmp slt i32 %23, 1
br i1 %24, label %37, label %25
25: ; preds = %22
%26 = and i32 %13, 15
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = call i32 @fflush(i32 %31)
br label %33
33: ; preds = %28, %25
%34 = call i32 @write(i32 1, i8* %5, i32 %23)
%35 = icmp eq i32 %34, %23
%36 = add nuw nsw i32 %13, 1
br i1 %35, label %12, label %44
37: ; preds = %22
%38 = icmp eq i32 %23, -1
br i1 %38, label %39, label %44
39: ; preds = %37
%40 = load i32, i32* @stderr
%41 = load i32, i32* @errno
%42 = call i8* @strerror(i32 %41)
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %42)
br label %59
44: ; preds = %33, %37
%45 = phi i32 [ %23, %37 ], [ %34, %33 ]
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load i32, i32* @stderr
%49 = load i32, i32* @errno
%50 = call i8* @strerror(i32 %49)
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %50)
br label %59
52: ; preds = %44
%53 = icmp eq i32 %45, %23
%54 = load i32, i32* @stderr
br i1 %53, label %57, label %55
55: ; preds = %52
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0), i32 %45, i32 %23)
br label %59
57: ; preds = %52
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %59
59: ; preds = %39, %55, %57, %47, %7
%60 = phi i32 [ 1, %7 ], [ 0, %47 ], [ 0, %57 ], [ 0, %55 ], [ 0, %39 ]
ret i32 %60
}