#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ *strstr(char *, char *);
int main() {
  FILE *log_file;
  FILE *result_file;
  char current_str[1000];
  if (!(log_file = fopen("apoj.txt", "r"))) {
    printf("Open apoj_file failed.\n");
    return 0;
  }
  result_file = fopen("result.txt", "w");
fin:
  while (!(feof(log_file))) {
    fgets(current_str, 1000, log_file);
    if (ferror(log_file)) {
      printf("error");
      return 0;
    }
    if (((strstr(current_str, "10077")) != NULL) &&
        ((strstr(current_str, "Новая запись:")) != NULL)) {
      fputs(current_str, stdout);
      fputs(current_str, result_file);
    } else
      goto fin;
  }
  fclose(log_file);
  fclose(result_file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11cb <main+0x4b>
lea    0xe4f(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12cd <main+0x14d>
lea    0xe4f(%rip),%rdi
lea    0xe53(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
jmp    11e7 <main+0x67>
mov    -0x10(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1205 <main+0x85>
jmp    12b4 <main+0x134>
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1070 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     1245 <main+0xc5>
lea    0xdfa(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12cd <main+0x14d>
lea    -0x400(%rbp),%rdi
lea    0xde1(%rip),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
je     12aa <main+0x12a>
lea    -0x400(%rbp),%rdi
lea    0xdca(%rip),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
je     12aa <main+0x12a>
lea    -0x400(%rbp),%rdi
mov    0x2d53(%rip),%rax
mov    (%rax),%rsi
call   1060 <fputs@plt>
lea    -0x400(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
jmp    12af <main+0x12f>
jmp    11e2 <main+0x62>
jmp    11e7 <main+0x67>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3e8,%rsp
lea    0xe58(%rip),%rdi
lea    0xe6b(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     11f3 <main+0x63>
mov    %rax,%rbx
lea    0xe46(%rip),%rdi
lea    0xe4a(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %eax,%eax
je     1204 <main+0x74>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
jmp    128e <main+0xfe>
lea    0xe41(%rip),%rdi
call   1030 <puts@plt>
jmp    128e <main+0xfe>
mov    %rsp,%r15
lea    0xe0e(%rip),%r12
lea    0xe0d(%rip),%r13
mov    0x2dc4(%rip),%rbp
jmp    122c <main+0x9c>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    11de <main+0x4e>
mov    %r15,%rdi
mov    $0x3e8,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
mov    %rbx,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    1282 <main+0xf2>
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <strstr@plt>
test   %rax,%rax
je     1220 <main+0x90>
mov    %r15,%rdi
mov    %r13,%rsi
call   10b0 <strstr@plt>
test   %rax,%rax
je     1220 <main+0x90>
mov    0x0(%rbp),%rsi
mov    %r15,%rdi
call   1070 <fputs@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <fputs@plt>
jmp    1220 <main+0x90>
lea    0xd8d(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"apoj.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [24 x i8] c"Open apoj_file failed.\0A\00"
@.str.3 = [11 x i8] c"result.txt\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [6 x i8] c"error\00"
@.str.6 = [6 x i8] c"10077\00"
@.str.7 = [25 x i8] c"\D0\9D\D0\BE\D0\B2\D0\B0\D1\8F \D0\B7\D0\B0\D0\BF\D0\B8\D1\81\D1\8C:\00"
@stdout = global i32* null
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [1000 x i8]
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = icmp ne i32* %5, null
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %48
9: ; preds = %0
%10 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %10, i32** %3
br label %11
11: ; preds = %41, %9
br label %12
12: ; preds = %42, %11
%13 = load i32*, i32** %2
%14 = call i32 @feof(i32* %13)
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
br i1 %16, label %17, label %43
17: ; preds = %12
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%19 = load i32*, i32** %2
%20 = call i32 @fgets(i8* %18, i32 1000, i32* %19)
%21 = load i32*, i32** %2
%22 = call i64 @ferror(i32* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %48
26: ; preds = %17
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%28 = call i32* @strstr(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%29 = icmp ne i32* %28, null
br i1 %29, label %30, label %41
30: ; preds = %26
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%32 = call i32* @strstr(i8* %31, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%33 = icmp ne i32* %32, null
br i1 %33, label %34, label %41
34: ; preds = %30
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%36 = load i32*, i32** @stdout
%37 = call i32 @fputs(i8* %35, i32* %36)
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%39 = load i32*, i32** %3
%40 = call i32 @fputs(i8* %38, i32* %39)
br label %42
41: ; preds = %30, %26
br label %11
42: ; preds = %34
br label %12
43: ; preds = %12
%44 = load i32*, i32** %2
%45 = call i32 @fclose(i32* %44)
%46 = load i32*, i32** %3
%47 = call i32 @fclose(i32* %46)
store i32 0, i32* %1
br label %48
48: ; preds = %43, %24, %7
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str = [9 x i8] c"apoj.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [11 x i8] c"result.txt\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [6 x i8] c"error\00"
@.str.6 = [6 x i8] c"10077\00"
@.str.7 = [25 x i8] c"\D0\9D\D0\BE\D0\B2\D0\B0\D1\8F \D0\B7\D0\B0\D0\BF\D0\B8\D1\81\D1\8C:\00"
@stdout = global i32* null
@str = [23 x i8] c"Open apoj_file failed.\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %36
7: ; preds = %0
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @feof(i32* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %33
11: ; preds = %7, %29
%12 = call i32 @fgets(i8* %2, i32 1000, i32* %3)
%13 = call i64 @ferror(i32* %3)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %36
17: ; preds = %11
%18 = call i32* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %30, label %20
20: ; preds = %17
%21 = call i32* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %30, label %23
23: ; preds = %20
%24 = load i32*, i32** @stdout
%25 = call i32 @fputs(i8* %2, i32* %24)
%26 = call i32 @fputs(i8* %2, i32* %8)
%27 = call i32 @feof(i32* %3)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %23, %30
br label %11
30: ; preds = %20, %17
%31 = call i32 @feof(i32* %3)
%32 = icmp eq i32 %31, 0
br i1 %32, label %29, label %33
33: ; preds = %30, %23, %7
%34 = call i32 @fclose(i32* %3)
%35 = call i32 @fclose(i32* %8)
br label %36
36: ; preds = %33, %15, %5
ret i32 0
}