#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 *args[]) {
  char line[80];
  FILE *in;
  FILE *file1;
  FILE *file2;
  FILE *file3;
  if (argc != 6) {
    fprintf(stderr, "You need to give 5 arguments\n");
    return 1;
  }
  in = fopen("spooky.csv", "r");
  file1 = fopen(args[2], "w");
  file2 = fopen(args[4], "w");
  file3 = fopen(args[5], "w");
  if (in == NULL) {
    fprintf(stderr, "spooky.csvを開けません\n");
    return 1;
  }
  if (file1 == NULL) {
    fprintf(stderr, "%sを開けません\n", args[2]);
    return 1;
  }
  if (file2 == NULL) {
    fprintf(stderr, "%sを開けません\n", args[4]);
    return 1;
  }
  if (file3 == NULL) {
    fprintf(stderr, "%sを開けません\n", args[5]);
    return 1;
  }
  while (fscanf(in, "%79[^\n]\n", line) == 1) {
    if (strstr(line, args[1]))
      fprintf(file1, "%s\n", line);
    else if (strstr(line, args[3]))
      fprintf(file2, "%s\n", line);
    else
      fprintf(file3, "%s\n", line);
  }
  fclose(in);
  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
mov    (%rax),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a3 <main+0x253>
lea    0xe80(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe6e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xe56(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    0xe3e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    1225 <main+0xd5>
mov    0x2dd8(%rip),%rax
mov    (%rax),%rdi
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a3 <main+0x253>
cmpq   $0x0,-0x70(%rbp)
jne    125c <main+0x10c>
mov    0x2da9(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe02(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a3 <main+0x253>
cmpq   $0x0,-0x78(%rbp)
jne    1293 <main+0x143>
mov    0x2d72(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xdcb(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a3 <main+0x253>
cmpq   $0x0,-0x80(%rbp)
jne    12ca <main+0x17a>
mov    0x2d3b(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdx
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a3 <main+0x253>
jmp    12cf <main+0x17f>
mov    -0x68(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xd83(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    1378 <main+0x228>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1322 <main+0x1d2>
mov    -0x70(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xd54(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1373 <main+0x223>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1358 <main+0x208>
mov    -0x78(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xd1e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    136e <main+0x21e>
mov    -0x80(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xd03(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1373 <main+0x223>
jmp    12cf <main+0x17f>
mov    -0x68(%rbp),%rdi
call   1030 <fclose@plt>
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    1277 <main+0x117>
mov    %rsi,%rbx
lea    0xe9d(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe90(%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,%r12
mov    0x28(%rbx),%rdi
mov    %rbp,%rsi
call   1060 <fopen@plt>
test   %r14,%r14
je     128a <main+0x12a>
test   %r15,%r15
je     12ac <main+0x14c>
test   %r12,%r12
je     12bc <main+0x15c>
mov    %rax,%r13
test   %rax,%rax
je     12f2 <main+0x192>
mov    %r12,0x8(%rsp)
lea    0xe6d(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %r14,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    12cc <main+0x16c>
lea    0x10(%rsp),%rbp
lea    0xe4b(%rip),%r12
jmp    1248 <main+0xe8>
nopl   0x0(%rax,%rax,1)
lea    0xe43(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    12cc <main+0x16c>
mov    0x8(%rbx),%rsi
mov    %rbp,%rdi
call   1080 <strstr@plt>
mov    %r15,%rdi
test   %rax,%rax
jne    1220 <main+0xc0>
mov    0x18(%rbx),%rsi
mov    %rbp,%rdi
call   1080 <strstr@plt>
mov    %r13,%rdi
test   %rax,%rax
je     1220 <main+0xc0>
mov    0x8(%rsp),%rdi
jmp    1220 <main+0xc0>
mov    0x2d62(%rip),%rax
mov    (%rax),%rcx
lea    0xd78(%rip),%rdi
jmp    129b <main+0x13b>
mov    0x2d4f(%rip),%rax
mov    (%rax),%rcx
lea    0xd92(%rip),%rdi
mov    $0x1d,%esi
mov    $0x1,%edx
call   1070 <fwrite@plt>
jmp    130e <main+0x1ae>
mov    0x2d2d(%rip),%rax
mov    (%rax),%rdi
mov    0x10(%rbx),%rdx
jmp    1300 <main+0x1a0>
mov    0x2d1d(%rip),%rax
mov    (%rax),%rdi
mov    0x20(%rbx),%rdx
jmp    1300 <main+0x1a0>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1030 <fclose@plt>
mov    %r13,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    1313 <main+0x1b3>
mov    0x2ce7(%rip),%rax
mov    (%rax),%rdi
mov    0x28(%rbx),%rdx
lea    0xd44(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32* null
@.str = [30 x i8] c"You need to give 5 arguments\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 = [30 x i8] c"spooky.csv\E3\82\92\E9\96\8B\E3\81\91\E3\81\BE\E3\81\9B\E3\82\93\0A\00"
@.str.5 = [22 x i8] c"%s\E3\82\92\E9\96\8B\E3\81\91\E3\81\BE\E3\81\9B\E3\82\93\0A\00"
@.str.6 = [9 x i8] c"%79[^\0A]\0A\00"
@.str.7 = [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 %16
13: ; preds = %2
%14 = load i32*, i32** @stderr
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %105
16: ; preds = %2
%17 = 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* %17, i32** %7
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %21, i32** %8
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 4
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %25, i32** %9
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 5
%28 = load i8*, i8** %27
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %29, i32** %10
%30 = load i32*, i32** %7
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %35
32: ; preds = %16
%33 = load i32*, i32** @stderr
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %105
35: ; preds = %16
%36 = load i32*, i32** %8
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i32*, i32** @stderr
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %42)
store i32 1, i32* %3
br label %105
44: ; preds = %35
%45 = load i32*, i32** %9
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %53
47: ; preds = %44
%48 = load i32*, i32** @stderr
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 4
%51 = load i8*, i8** %50
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %51)
store i32 1, i32* %3
br label %105
53: ; preds = %44
%54 = load i32*, i32** %10
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %62
56: ; preds = %53
%57 = load i32*, i32** @stderr
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 5
%60 = load i8*, i8** %59
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %57, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %60)
store i32 1, i32* %3
br label %105
62: ; preds = %53
br label %63
63: ; preds = %95, %62
%64 = load i32*, i32** %7
%65 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%66 = call i32 @fscanf(i32* %64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %65)
%67 = icmp eq i32 %66, 1
br i1 %67, label %68, label %96
68: ; preds = %63
%69 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 1
%72 = load i8*, i8** %71
%73 = call i64 @strstr(i8* %69, i8* %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %79
75: ; preds = %68
%76 = load i32*, i32** %8
%77 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%78 = call i32 (i32*, i8*, ...) @fprintf(i32* %76, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %77)
br label %95
79: ; preds = %68
%80 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 3
%83 = load i8*, i8** %82
%84 = call i64 @strstr(i8* %80, i8* %83)
%85 = icmp ne i64 %84, 0
br i1 %85, label %86, label %90
86: ; preds = %79
%87 = load i32*, i32** %9
%88 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %87, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %88)
br label %94
90: ; preds = %79
%91 = load i32*, i32** %10
%92 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%93 = call i32 (i32*, i8*, ...) @fprintf(i32* %91, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %92)
br label %94
94: ; preds = %90, %86
br label %95
95: ; preds = %94, %75
br label %63
96: ; preds = %63
%97 = load i32*, i32** %7
%98 = call i32 @fclose(i32* %97)
%99 = load i32*, i32** %8
%100 = call i32 @fclose(i32* %99)
%101 = load i32*, i32** %9
%102 = call i32 @fclose(i32* %101)
%103 = load i32*, i32** %10
%104 = call i32 @fclose(i32* %103)
store i32 0, i32* %3
br label %105
105: ; preds = %96, %56, %47, %38, %32, %13
%106 = load i32, i32* %3
ret i32 %106
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [30 x i8] c"You need to give 5 arguments\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 = [30 x i8] c"spooky.csv\E3\82\92\E9\96\8B\E3\81\91\E3\81\BE\E3\81\9B\E3\82\93\0A\00"
@.str.5 = [22 x i8] c"%s\E3\82\92\E9\96\8B\E3\81\91\E3\81\BE\E3\81\9B\E3\82\93\0A\00"
@.str.6 = [9 x i8] c"%79[^\0A]\0A\00"
@.str.7 = [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 %9, label %6
6: ; preds = %2
%7 = load i32*, i32** @stderr
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 29, i64 1, i32* %7)
br label %67
9: ; preds = %2
%10 = 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))
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%14 = getelementptr inbounds i8*, i8** %1, i64 4
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = getelementptr inbounds i8*, i8** %1, i64 5
%18 = load i8*, i8** %17
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i32* %10, null
br i1 %20, label %21, label %24
21: ; preds = %9
%22 = load i32*, i32** @stderr
%23 = tail call i64 @fwrite(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 29, i64 1, i32* %22)
br label %67
24: ; preds = %9
%25 = icmp eq i32* %13, null
br i1 %25, label %26, label %30
26: ; preds = %24
%27 = load i32*, i32** @stderr
%28 = load i8*, i8** %11
%29 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %28)
br label %67
30: ; preds = %24
%31 = icmp eq i32* %16, null
br i1 %31, label %32, label %36
32: ; preds = %30
%33 = load i32*, i32** @stderr
%34 = load i8*, i8** %14
%35 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %34)
br label %67
36: ; preds = %30
%37 = icmp eq i32* %19, null
br i1 %37, label %44, label %38
38: ; preds = %36
%39 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%40 = icmp eq i32 %39, 1
br i1 %40, label %41, label %62
41: ; preds = %38
%42 = getelementptr inbounds i8*, i8** %1, i64 1
%43 = getelementptr inbounds i8*, i8** %1, i64 3
br label %48
44: ; preds = %36
%45 = load i32*, i32** @stderr
%46 = load i8*, i8** %17
%47 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %46)
br label %67
48: ; preds = %41, %57
%49 = load i8*, i8** %42
%50 = call i64 @strstr(i8* %4, i8* %49)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %57
52: ; preds = %48
%53 = load i8*, i8** %43
%54 = call i64 @strstr(i8* %4, i8* %53)
%55 = icmp eq i64 %54, 0
%56 = select i1 %55, i32* %19, i32* %16
br label %57
57: ; preds = %52, %48
%58 = phi i32* [ %13, %48 ], [ %56, %52 ]
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %4)
%60 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%61 = icmp eq i32 %60, 1
br i1 %61, label %48, label %62
62: ; preds = %57, %38
%63 = call i32 @fclose(i32* %10)
%64 = call i32 @fclose(i32* %13)
%65 = call i32 @fclose(i32* %16)
%66 = call i32 @fclose(i32* %19)
br label %67
67: ; preds = %62, %44, %32, %26, %21, %6
%68 = phi i32 [ 1, %6 ], [ 1, %21 ], [ 1, %26 ], [ 1, %32 ], [ 1, %44 ], [ 0, %62 ]
ret i32 %68
}