#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
char *malloc(int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  FILE *orig;
  FILE *dest;
  orig = fopen("../../dicts/rhymeDict.csv", "r+");
  dest = fopen("../../dicts/editedRhymeDict.csv", "w");
  char *inputLine = malloc(sizeof(char) * 512);
  char *last = malloc(sizeof(char) * 512);
  fgets(last, 512, orig);
  while (fgets(inputLine, 512, orig) != NULL) {
    if (strcmp(inputLine, last) != 0) {
      fputs(last, dest);
    }
    strcpy(last, inputLine);
  }
  fclose(orig);
  fclose(dest);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe79(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    $0x200,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x200,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x200,%esi
call   1060 <fgets@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x200,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1234 <main+0xc4>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1222 <main+0xb2>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11e2 <main+0x72>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe81(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
lea    0xe88(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
mov    $0x200,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    $0x200,%edi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
jmp    11db <main+0x6b>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     120d <main+0x9d>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11d0 <main+0x60>
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <fputs@plt>
jmp    11d0 <main+0x60>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"../../dicts/rhymeDict.csv\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.2 = [32 x i8] c"../../dicts/editedRhymeDict.csv\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %6
%11 = call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %11, i32** %7
%12 = call i8* @malloc(i32 512)
store i8* %12, i8** %8
%13 = call i8* @malloc(i32 512)
store i8* %13, i8** %9
%14 = load i8*, i8** %9
%15 = load i32*, i32** %6
%16 = call i32* @fgets(i8* %14, i32 512, i32* %15)
br label %17
17: ; preds = %31, %2
%18 = load i8*, i8** %8
%19 = load i32*, i32** %6
%20 = call i32* @fgets(i8* %18, i32 512, i32* %19)
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %35
22: ; preds = %17
%23 = load i8*, i8** %8
%24 = load i8*, i8** %9
%25 = call i64 @strcmp(i8* %23, i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i8*, i8** %9
%29 = load i32*, i32** %7
%30 = call i32 @fputs(i8* %28, i32* %29)
br label %31
31: ; preds = %27, %22
%32 = load i8*, i8** %9
%33 = load i8*, i8** %8
%34 = call i32 @strcpy(i8* %32, i8* %33)
br label %17
35: ; preds = %17
%36 = load i32*, i32** %6
%37 = call i32 @fclose(i32* %36)
%38 = load i32*, i32** %7
%39 = call i32 @fclose(i32* %38)
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [26 x i8] c"../../dicts/rhymeDict.csv\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.2 = [32 x i8] c"../../dicts/editedRhymeDict.csv\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call dereferenceable_or_null(512) i8* @malloc(i32 512)
%6 = tail call dereferenceable_or_null(512) i8* @malloc(i32 512)
%7 = tail call i32* @fgets(i8* %6, i32 512, i32* %3)
%8 = tail call i32* @fgets(i8* %5, i32 512, i32* %3)
%9 = icmp eq i32* %8, null
br i1 %9, label %19, label %10
10: ; preds = %2, %15
%11 = tail call i64 @strcmp(i8* %5, i8* %6)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @fputs(i8* %6, i32* %4)
br label %15
15: ; preds = %13, %10
%16 = tail call i32 @strcpy(i8* %6, i8* %5)
%17 = tail call i32* @fgets(i8* %5, i32 512, i32* %3)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %10
19: ; preds = %15, %2
%20 = tail call i32 @fclose(i32* %3)
%21 = tail call i32 @fclose(i32* %4)
ret i32 0
}