#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 scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ assert(int);
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ getenv(char *);
scalar_t__ malloc(int);
int open(char const *, int /*<<< orphan*/);
scalar_t__ read(int, char *, int);
scalar_t__ write(int /*<<< orphan*/, char *, scalar_t__);
void mcat_scd(const char *pathname) {
  int fd;
  ssize_t readed_octets;
  int BUFFSIZE;
  char *BUFFER;
  BUFFSIZE = atoi(getenv("MCAT_BUFFSIZE"));
  BUFFER = (char *)malloc((sizeof(char)) * BUFFSIZE);
  fd = open(pathname, O_RDONLY);
  assert(fd != -1);
  while ((readed_octets = read(fd, BUFFER, BUFFSIZE)) > 0) {
    assert(write(STDOUT_FILENO, BUFFER, readed_octets) == readed_octets);
  }
  free(BUFFER);
  close(fd);
  return;
}


x86 assembly (clang, -O0):
<mcat_scd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe5d(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0xc(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1070 <read@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jle    1234 <mcat_scd+0xa4>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <write@plt>
cmp    -0x18(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
jmp    11eb <mcat_scd+0x5b>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    -0xc(%rbp),%edi
call   1060 <close@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mcat_scd>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbp
lea    0xe5e(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
call   10b0 <atoi@plt>
mov    %eax,%r14d
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    0x2e1e(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10a0 <open@plt>
mov    %eax,%r15d
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1080 <assert@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1070 <read@plt>
test   %rax,%rax
jle    1233 <mcat_scd+0xa3>
mov    %rax,%rbp
mov    0x2df6(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    (%r12),%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1050 <write@plt>
xor    %edi,%edi
cmp    %rbp,%rax
sete   %dil
call   1080 <assert@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1070 <read@plt>
mov    %rax,%rbp
test   %rax,%rax
jg     1200 <mcat_scd+0x70>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %r15d,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <close@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"MCAT_BUFFSIZE\00"
@O_RDONLY = global i32 0
@STDOUT_FILENO = global i32 0
define void @mcat_scd(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %2
%7 = call i32 @getenv(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @atoi(i32 %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = mul i64 1, %10
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %6
%15 = load i8*, i8** %2
%16 = load i32, i32* @O_RDONLY
%17 = call i32 @open(i8* %15, i32 %16)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, -1
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
br label %22
22: ; preds = %28, %1
%23 = load i32, i32* %3
%24 = load i8*, i8** %6
%25 = load i32, i32* %5
%26 = call i64 @read(i32 %23, i8* %24, i32 %25)
store i64 %26, i64* %4
%27 = icmp sgt i64 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %22
%29 = load i32, i32* @STDOUT_FILENO
%30 = load i8*, i8** %6
%31 = load i64, i64* %4
%32 = call i64 @write(i32 %29, i8* %30, i64 %31)
%33 = load i64, i64* %4
%34 = icmp eq i64 %32, %33
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
br label %22
37: ; preds = %22
%38 = load i8*, i8** %6
%39 = call i32 @free(i8* %38)
%40 = load i32, i32* %3
%41 = call i32 @close(i32 %40)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"MCAT_BUFFSIZE\00"
@O_RDONLY = global i32 0
@STDOUT_FILENO = global i32 0
define void @mcat_scd(i8* nocapture %0) {
%2 = tail call i32 @getenv(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @atoi(i32 %2)
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to i8*
%6 = load i32, i32* @O_RDONLY
%7 = tail call i32 @open(i8* %0, i32 %6)
%8 = icmp ne i32 %7, -1
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i64 @read(i32 %7, i8* %5, i32 %3)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %1, %13
%14 = phi i64 [ %20, %13 ], [ %11, %1 ]
%15 = load i32, i32* @STDOUT_FILENO
%16 = tail call i64 @write(i32 %15, i8* %5, i64 %14)
%17 = icmp eq i64 %16, %14
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
%20 = tail call i64 @read(i32 %7, i8* %5, i32 %3)
%21 = icmp sgt i64 %20, 0
br i1 %21, label %13, label %22
22: ; preds = %13, %1
%23 = tail call i32 @free(i8* %5)
%24 = tail call i32 @close(i32 %7)
ret void
}