#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, long, int /*<<< orphan*/ *);
scalar_t__ malloc(long);
int /*<<< orphan*/ perror(char *);
int main(void) {
  const char source[] = "input.txt";
  FILE *in_stream = fopen(source, "rb");
  if (in_stream != NULL) {
    const char dest[] = "output.txt";
    FILE *out_stream = fopen(dest, "wb");
    if (out_stream != NULL) {
      fseek(in_stream, 0, SEEK_END);
      long int file_size = ftell(in_stream);
      fseek(in_stream, 0, SEEK_SET);
      char *buff = (char *)malloc(file_size * sizeof(char));
      if (buff != NULL) {
        char symbol;
        fread(buff, sizeof(char), file_size, in_stream);
        fwrite(buff, sizeof(char), file_size, out_stream);
      } else {
        perror("Ошибка выделения памяти");
      }
      fclose(out_stream);
    } else {
      perror("Ошибка создания потока вывода");
    }
    fclose(in_stream);
  } else {
    perror("Ошибка создания потока ввода");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe6a(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xe67(%rip),%ax
mov    %ax,-0x6(%rbp)
lea    -0xe(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     12b8 <main+0x138>
mov    0xe42(%rip),%rax
mov    %rax,-0x23(%rbp)
mov    0xe3f(%rip),%ax
mov    %ax,-0x1b(%rbp)
mov    0xe37(%rip),%al
mov    %al,-0x19(%rbp)
lea    -0x23(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     129e <main+0x11e>
mov    -0x18(%rbp),%rdi
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2daa(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x38(%rbp),%rdi
shl    $0x0,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1284 <main+0x104>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
jmp    1290 <main+0x110>
lea    0xd90(%rip),%rdi
call   1090 <perror@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12aa <main+0x12a>
lea    0xda3(%rip),%rdi
call   1090 <perror@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12c4 <main+0x144>
lea    0xdc1(%rip),%rdi
call   1090 <perror@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movabs $0x78742e7475706e69,%rax
2e 74 78
mov    %rax,0x8(%rsp)
movw   $0x74,0x10(%rsp)
lea    0xe62(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1277 <main+0xf7>
mov    %rax,%r15
movabs $0x742e74757074756f,%rax
74 2e 74
mov    %rax,0x18(%rsp)
movl   $0x747874,0x1f(%rsp)
lea    0xe3c(%rip),%rsi
lea    0x18(%rsp),%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1285 <main+0x105>
mov    %rax,%r14
mov    0x2def(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
mov    %r15,%rdi
call   1050 <ftell@plt>
mov    %rax,%r12
mov    0x2dc1(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
mov    %r12,%rdi
call   1060 <malloc@plt>
test   %rax,%rax
je     1293 <main+0x113>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    %r15,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe02(%rip),%rdi
call   1090 <perror@plt>
jmp    1269 <main+0xe9>
lea    0xdbc(%rip),%rdi
call   1090 <perror@plt>
jmp    1261 <main+0xe1>
lea    0xd81(%rip),%rdi
call   1090 <perror@plt>
jmp    1259 <main+0xd9>

LLVM IR (-O0):
@__const.main.source = [10 x i8] c"input.txt\00"
@.str = [3 x i8] c"rb\00"
@__const.main.dest = [11 x i8] c"output.txt\00"
@.str.1 = [3 x i8] c"wb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.2 = [45 x i8] c"\D0\9E\D1\88\D0\B8\D0\B1\D0\BA\D0\B0 \D0\B2\D1\8B\D0\B4\D0\B5\D0\BB\D0\B5\D0\BD\D0\B8\D1\8F \D0\BF\D0\B0\D0\BC\D1\8F\D1\82\D0\B8\00"
@.str.3 = [56 x i8] c"\D0\9E\D1\88\D0\B8\D0\B1\D0\BA\D0\B0 \D1\81\D0\BE\D0\B7\D0\B4\D0\B0\D0\BD\D0\B8\D1\8F \D0\BF\D0\BE\D1\82\D0\BE\D0\BA\D0\B0 \D0\B2\D1\8B\D0\B2\D0\BE\D0\B4\D0\B0\00"
@.str.4 = [54 x i8] c"\D0\9E\D1\88\D0\B8\D0\B1\D0\BA\D0\B0 \D1\81\D0\BE\D0\B7\D0\B4\D0\B0\D0\BD\D0\B8\D1\8F \D0\BF\D0\BE\D1\82\D0\BE\D0\BA\D0\B0 \D0\B2\D0\B2\D0\BE\D0\B4\D0\B0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32*
%4 = alloca [11 x i8]
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8
store i32 0, i32* %1
%9 = bitcast [10 x i8]* %2 to i8*
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %3
%12 = load i32*, i32** %3
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %54
14: ; preds = %0
%15 = bitcast [11 x i8]* %4 to i8*
%16 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %5
%18 = load i32*, i32** %5
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %49
20: ; preds = %14
%21 = load i32*, i32** %3
%22 = load i32, i32* @SEEK_END
%23 = call i32 @fseek(i32* %21, i32 0, i32 %22)
%24 = load i32*, i32** %3
%25 = call i64 @ftell(i32* %24)
store i64 %25, i64* %6
%26 = load i32*, i32** %3
%27 = load i32, i32* @SEEK_SET
%28 = call i32 @fseek(i32* %26, i32 0, i32 %27)
%29 = load i64, i64* %6
%30 = mul i64 %29, 1
%31 = call i64 @malloc(i64 %30)
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %7
%33 = load i8*, i8** %7
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %44
35: ; preds = %20
%36 = load i8*, i8** %7
%37 = load i64, i64* %6
%38 = load i32*, i32** %3
%39 = call i32 @fread(i8* %36, i32 1, i64 %37, i32* %38)
%40 = load i8*, i8** %7
%41 = load i64, i64* %6
%42 = load i32*, i32** %5
%43 = call i32 @fwrite(i8* %40, i32 1, i64 %41, i32* %42)
br label %46
44: ; preds = %20
%45 = call i32 @perror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %44, %35
%47 = load i32*, i32** %5
%48 = call i32 @fclose(i32* %47)
br label %51
49: ; preds = %14
%50 = call i32 @perror(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
br label %51
51: ; preds = %49, %46
%52 = load i32*, i32** %3
%53 = call i32 @fclose(i32* %52)
br label %56
54: ; preds = %0
%55 = call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %54, %51
ret i32 0
}

LLVM IR (-O2):
@__const.main.source = [10 x i8] c"input.txt\00"
@.str = [3 x i8] c"rb\00"
@__const.main.dest = [11 x i8] c"output.txt\00"
@.str.1 = [3 x i8] c"wb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.2 = [45 x i8] c"\D0\9E\D1\88\D0\B8\D0\B1\D0\BA\D0\B0 \D0\B2\D1\8B\D0\B4\D0\B5\D0\BB\D0\B5\D0\BD\D0\B8\D1\8F \D0\BF\D0\B0\D0\BC\D1\8F\D1\82\D0\B8\00"
@.str.3 = [56 x i8] c"\D0\9E\D1\88\D0\B8\D0\B1\D0\BA\D0\B0 \D1\81\D0\BE\D0\B7\D0\B4\D0\B0\D0\BD\D0\B8\D1\8F \D0\BF\D0\BE\D1\82\D0\BE\D0\BA\D0\B0 \D0\B2\D1\8B\D0\B2\D0\BE\D0\B4\D0\B0\00"
@.str.4 = [54 x i8] c"\D0\9E\D1\88\D0\B8\D0\B1\D0\BA\D0\B0 \D1\81\D0\BE\D0\B7\D0\B4\D0\B0\D0\BD\D0\B8\D1\8F \D0\BF\D0\BE\D1\82\D0\BE\D0\BA\D0\B0 \D0\B2\D0\B2\D0\BE\D0\B4\D0\B0\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [11 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %30, label %6
6: ; preds = %0
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %26, label %10
10: ; preds = %6
%11 = load i32, i32* @SEEK_END
%12 = tail call i32 @fseek(i32* %4, i32 0, i32 %11)
%13 = tail call i64 @ftell(i32* %4)
%14 = load i32, i32* @SEEK_SET
%15 = tail call i32 @fseek(i32* %4, i32 0, i32 %14)
%16 = tail call i64 @malloc(i64 %13)
%17 = inttoptr i64 %16 to i8*
%18 = icmp eq i64 %16, 0
br i1 %18, label %22, label %19
19: ; preds = %10
%20 = tail call i32 @fread(i8* %17, i32 1, i64 %13, i32* %4)
%21 = tail call i32 @fwrite(i8* %17, i32 1, i64 %13, i32* %8)
br label %24
22: ; preds = %10
%23 = tail call i32 @perror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
%25 = tail call i32 @fclose(i32* %8)
br label %28
26: ; preds = %6
%27 = tail call i32 @perror(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %24
%29 = tail call i32 @fclose(i32* %4)
br label %32
30: ; preds = %0
%31 = tail call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
ret i32 0
}