#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strstr(char *, char *);
int main(int argc, char *argv[]) {
  char line[80];
  if (argc != 6) {
    fprintf(stderr, "Вы должны передать 5 аргументов\n");
    return 1;
  }
  FILE *in = fopen("spooky.csv", "r");
  FILE *file1 = fopen(argv[2], "w");
  FILE *file2 = fopen(argv[4], "w");
  FILE *file3 = fopen(argv[5], "w");
  while (fscanf(in, "%79[^\n]\n", line) == 1) {
    if (strstr(line, argv[1])) {
      fprintf(file1, "%s\n", line);
    } else if (strstr(line, argv[3])) {
      fprintf(file2, "%s\n", line);
    } else {
      fprintf(file3, "%s\n", line);
    }
  }
  fclose(file1);
  fclose(file2);
  fclose(file3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x6,-0x8(%rbp)
je     1197 <main+0x47>
mov    0x2e66(%rip),%rax
movslq (%rax),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c1 <main+0x171>
lea    0xe9d(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xe73(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    0xe5b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x80(%rbp)
mov    -0x68(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe45(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    129f <main+0x14f>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1249 <main+0xf9>
mov    -0x70(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    129a <main+0x14a>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     127f <main+0x12f>
mov    -0x78(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xde0(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1295 <main+0x145>
mov    -0x80(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xdc5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    129a <main+0x14a>
jmp    11f6 <main+0xa6>
mov    -0x70(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x78(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x80(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
cmp    $0x6,%edi
jne    1250 <main+0xf0>
mov    %rsi,%rbx
lea    0xeba(%rip),%rdi
lea    0xebe(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xead(%rip),%rbp
mov    %rbp,%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
mov    0x20(%rbx),%rdi
mov    %rbp,%rsi
call   1060 <fopen@plt>
mov    %rax,(%rsp)
mov    0x28(%rbx),%rdi
mov    %rbp,%rsi
call   1060 <fopen@plt>
mov    %rax,0x8(%rsp)
lea    0xe7c(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %r14,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    1277 <main+0x117>
lea    0x10(%rsp),%rbp
lea    0xe63(%rip),%r12
lea    0xe53(%rip),%r13
jmp    1220 <main+0xc0>
nopl   0x0(%rax)
mov    %r12,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    1277 <main+0x117>
mov    0x8(%rbx),%rsi
mov    %rbp,%rdi
call   1080 <strstr@plt>
mov    %r15,%rdi
test   %rax,%rax
jne    1200 <main+0xa0>
mov    0x18(%rbx),%rsi
mov    %rbp,%rdi
call   1080 <strstr@plt>
mov    0x8(%rsp),%rdi
test   %rax,%rax
je     1200 <main+0xa0>
mov    (%rsp),%rdi
jmp    1200 <main+0xa0>
mov    0x2d89(%rip),%rax
movslq (%rax),%rcx
lea    0xd9f(%rip),%rdi
mov    $0x3a,%esi
mov    $0x1,%edx
call   1070 <fwrite@plt>
mov    $0x1,%eax
jmp    1294 <main+0x134>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    (%rsp),%rdi
call   1030 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [59 x i8] c"\D0\92\D1\8B \D0\B4\D0\BE\D0\BB\D0\B6\D0\BD\D1\8B \D0\BF\D0\B5\D1\80\D0\B5\D0\B4\D0\B0\D1\82\D1\8C 5 \D0\B0\D1\80\D0\B3\D1\83\D0\BC\D0\B5\D0\BD\D1\82\D0\BE\D0\B2\0A\00"
@.str.1 = [11 x i8] c"spooky.csv\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [9 x i8] c"%79[^\0A]\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [80 x i8]
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 6
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %72
18: ; preds = %2
%19 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %19, i32** %7
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %23, i32** %8
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 4
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %27, i32** %9
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 5
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %31, i32** %10
br label %32
32: ; preds = %64, %18
%33 = load i32*, i32** %7
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%35 = call i32 @fscanf(i32* %33, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %34)
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %65
37: ; preds = %32
%38 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i64 @strstr(i8* %38, i8* %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %37
%45 = load i32*, i32** %8
%46 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %46)
br label %64
48: ; preds = %37
%49 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 3
%52 = load i8*, i8** %51
%53 = call i64 @strstr(i8* %49, i8* %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %48
%56 = load i32*, i32** %9
%57 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %56, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %57)
br label %63
59: ; preds = %48
%60 = load i32*, i32** %10
%61 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %61)
br label %63
63: ; preds = %59, %55
br label %64
64: ; preds = %63, %44
br label %32
65: ; preds = %32
%66 = load i32*, i32** %8
%67 = call i32 @fclose(i32* %66)
%68 = load i32*, i32** %9
%69 = call i32 @fclose(i32* %68)
%70 = load i32*, i32** %10
%71 = call i32 @fclose(i32* %70)
store i32 0, i32* %3
br label %72
72: ; preds = %65, %13
%73 = load i32, i32* %3
ret i32 %73
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [59 x i8] c"\D0\92\D1\8B \D0\B4\D0\BE\D0\BB\D0\B6\D0\BD\D1\8B \D0\BF\D0\B5\D1\80\D0\B5\D0\B4\D0\B0\D1\82\D1\8C 5 \D0\B0\D1\80\D0\B3\D1\83\D0\BC\D0\B5\D0\BD\D1\82\D0\BE\D0\B2\0A\00"
@.str.1 = [11 x i8] c"spooky.csv\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [9 x i8] c"%79[^\0A]\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 6
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i64 58, i64 1, i32* %9)
br label %45
11: ; preds = %2
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%16 = getelementptr inbounds i8*, i8** %1, i64 4
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = getelementptr inbounds i8*, i8** %1, i64 5
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %41
24: ; preds = %11
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = getelementptr inbounds i8*, i8** %1, i64 3
br label %27
27: ; preds = %24, %36
%28 = load i8*, i8** %25
%29 = call i64 @strstr(i8* %4, i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i8*, i8** %26
%33 = call i64 @strstr(i8* %4, i8* %32)
%34 = icmp eq i64 %33, 0
%35 = select i1 %34, i32* %21, i32* %18
br label %36
36: ; preds = %31, %27
%37 = phi i32* [ %15, %27 ], [ %35, %31 ]
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%39 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%40 = icmp eq i32 %39, 1
br i1 %40, label %27, label %41
41: ; preds = %36, %11
%42 = call i32 @fclose(i32* %15)
%43 = call i32 @fclose(i32* %18)
%44 = call i32 @fclose(i32* %21)
br label %45
45: ; preds = %41, %6
%46 = phi i32 [ 1, %6 ], [ 0, %41 ]
ret i32 %46
}