#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*/ EXIT_FAILURE;
char *calloc(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strtok(char *, char const *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    printf("cmt: No file names given\n");
    exit(EXIT_FAILURE);
  }
  FILE *inputfile;
  if ((inputfile = fopen(argv[1], "r")) == NULL) {
    printf("cmt: %s: No such file or directory.\n", argv[1]);
    exit(EXIT_FAILURE);
  }
  FILE *outputfile;
  if ((outputfile = fopen(argv[2], "w")) == NULL) {
    printf("cmt: %s: No such file or directory.\n", argv[2]);
    exit(EXIT_FAILURE);
  }
  char line[128];
  const char s[2] = " ";
  char *token;
  char *first;
  char *second;
  char *previous_word = calloc(64, sizeof(char));
  while (fgets(line, sizeof line, inputfile) != NULL) {
    line[strlen(line) - 1] = '\0';
    token = strtok(line, s);
    first = token;
    token = strtok(NULL, s);
    second = token;
    if (strcmp(first, previous_word) != 0)
      fprintf(outputfile, "%s %s\n", first, second);
    strcpy(previous_word, first);
  }
  free(previous_word);
  fclose(inputfile);
  fclose(outputfile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11ff <main+0x3f>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0c(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1245 <main+0x85>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xded(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    128b <main+0xcb>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0xdb1(%rip),%ax
mov    %ax,-0xa2(%rbp)
mov    $0x40,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0xc8(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x80,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1387 <main+0x1c7>
lea    -0xa0(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xa0(%rbp,%rax,1)
lea    -0xa0(%rbp),%rdi
lea    -0xa2(%rbp),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0xb0(%rbp)
mov    -0xb0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    -0xa2(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <strtok@plt>
mov    %rax,-0xb0(%rbp)
mov    -0xb0(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0xb8(%rbp),%rdi
mov    -0xc8(%rbp),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     136f <main+0x1af>
mov    -0x20(%rbp),%rdi
mov    -0xb8(%rbp),%rdx
mov    -0xc0(%rbp),%rcx
lea    0xcdb(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0xc8(%rbp),%rdi
mov    -0xb8(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    12af <main+0xef>
mov    -0xc8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
cmp    $0x3,%edi
jne    1311 <main+0x141>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe08(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     131f <main+0x14f>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
lea    0xe13(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1325 <main+0x155>
movw   $0x20,0x6(%rsp)
mov    $0x40,%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,%r12
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12e3 <main+0x113>
lea    0x6(%rsp),%r13
jmp    1290 <main+0xc0>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12e3 <main+0x113>
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
mov    %r13,%rsi
call   10e0 <strtok@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %r13,%rsi
call   10e0 <strtok@plt>
mov    %rax,%r14
mov    %rbp,%rdi
mov    %r12,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1270 <main+0xa0>
mov    0x8(%rsp),%rdi
lea    0xd53(%rip),%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
call   10c0 <fprintf@plt>
jmp    1270 <main+0xa0>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd18(%rip),%rdi
call   1050 <puts@plt>
jmp    1337 <main+0x167>
mov    0x8(%rbx),%rsi
jmp    1329 <main+0x159>
mov    0x10(%rbx),%rsi
lea    0xcd2(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2ca2(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"cmt: No file names given\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [37 x i8] c"cmt: %s: No such file or directory.\0A\00"
@.str.3 = [2 x i8] c"w\00"
@__const.main.s = [2 x i8] c" \00"
@.str.4 = [7 x i8] c"%s %s\0A\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 [128 x i8]
%9 = alloca [2 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %6
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %33
26: ; preds = %20
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %20
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %37, i32** %7
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %46
39: ; preds = %33
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %33
%47 = bitcast [2 x i8]* %9 to i8*
%48 = call i8* @calloc(i32 64, i32 1)
store i8* %48, i8** %13
br label %49
49: ; preds = %76, %46
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%51 = load i32*, i32** %6
%52 = call i32* @fgets(i8* %50, i32 128, i32* %51)
%53 = icmp ne i32* %52, null
br i1 %53, label %54, label %80
54: ; preds = %49
%55 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%56 = call i32 @strlen(i8* %55)
%57 = sub nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 %58
store i8 0, i8* %59
%60 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%61 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%62 = call i8* @strtok(i8* %60, i8* %61)
store i8* %62, i8** %10
%63 = load i8*, i8** %10
store i8* %63, i8** %11
%64 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%65 = call i8* @strtok(i8* null, i8* %64)
store i8* %65, i8** %10
%66 = load i8*, i8** %10
store i8* %66, i8** %12
%67 = load i8*, i8** %11
%68 = load i8*, i8** %13
%69 = call i64 @strcmp(i8* %67, i8* %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %54
%72 = load i32*, i32** %7
%73 = load i8*, i8** %11
%74 = load i8*, i8** %12
%75 = call i32 @fprintf(i32* %72, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %73, i8* %74)
br label %76
76: ; preds = %71, %54
%77 = load i8*, i8** %13
%78 = load i8*, i8** %11
%79 = call i32 @strcpy(i8* %77, i8* %78)
br label %49
80: ; preds = %49
%81 = load i8*, i8** %13
%82 = call i32 @free(i8* %81)
%83 = load i32*, i32** %6
%84 = call i32 @fclose(i32* %83)
%85 = load i32*, i32** %7
%86 = call i32 @fclose(i32* %85)
ret i32 0
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [37 x i8] c"cmt: %s: No such file or directory.\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [7 x i8] c"%s %s\0A\00"
@str = [25 x i8] c"cmt: No file names given\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = alloca i16
%5 = icmp eq i32 %0, 3
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load i8*, i8** %11
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %10
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i8*, i8** %21
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = load i32, i32* @EXIT_FAILURE
%29 = tail call i32 @exit(i32 %28)
unreachable
30: ; preds = %20
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%32 = bitcast i16* %4 to i8*
store i16 32, i16* %4
%33 = tail call dereferenceable_or_null(64) i8* @calloc(i32 64, i32 1)
%34 = call i32* @fgets(i8* %31, i32 128, i32* %13)
%35 = icmp eq i32* %34, null
br i1 %35, label %51, label %36
36: ; preds = %30, %47
%37 = call i32 @strlen(i8* %31)
%38 = add nsw i32 %37, -1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %39
store i8 0, i8* %40
%41 = call i8* @strtok(i8* %31, i8* %32)
%42 = call i8* @strtok(i8* null, i8* %32)
%43 = call i64 @strcmp(i8* %41, i8* %33)
%44 = icmp eq i64 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %36
%46 = call i32 @fprintf(i32* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %41, i8* %42)
br label %47
47: ; preds = %45, %36
%48 = call i32 @strcpy(i8* %33, i8* %41)
%49 = call i32* @fgets(i8* %31, i32 128, i32* %13)
%50 = icmp eq i32* %49, null
br i1 %50, label %51, label %36
51: ; preds = %47, %30
%52 = call i32 @free(i8* %33)
%53 = call i32 @fclose(i32* %13)
%54 = call i32 @fclose(i32* %23)
ret i32 0
}