#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*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
int main() {
  FILE *fp1, *fp2;
  char line1[300], line2[300];
  if ((fp1 = fopen("test.txt", "r")) != NULL) {
    if ((fp2 = fopen("test2.txt", "r")) != NULL) {
      do {
        fgets(line1, 1000, fp1);
        fgets(line2, 1000, fp2);
      } while (strcmp(line1, line2) == 0);
      printf("%s", line1);
    }
  }
  fclose(fp1);
  fclose(fp2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x280,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1208 <main+0xb8>
lea    0xe81(%rip),%rdi
lea    0xe78(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1203 <main+0xb3>
jmp    11a9 <main+0x59>
lea    -0x150(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
lea    -0x280(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
lea    -0x150(%rbp),%rdi
lea    -0x280(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11a9 <main+0x59>
lea    -0x150(%rbp),%rsi
lea    0xe17(%rip),%rdi
call   1040 <printf@plt>
jmp    1208 <main+0xb8>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x280,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x268,%rsp
lea    0xe9b(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     11e1 <main+0x91>
lea    0xe8b(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11e3 <main+0x93>
mov    %rax,%r15
mov    %rsp,%r12
lea    0x130(%rsp),%rbx
nop
mov    %r12,%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11a0 <main+0x50>
lea    0xe3e(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
jmp    11e6 <main+0x96>
jmp    11e6 <main+0x96>
xor    %r15d,%r15d
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x268,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"test2.txt\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [300 x i8]
%5 = alloca [300 x i8]
store i32 0, i32* %1
%6 = 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* %6, i32** %2
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %28
8: ; preds = %0
%9 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %3
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %27
11: ; preds = %8
br label %12
12: ; preds = %19, %11
%13 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
%14 = load i32*, i32** %2
%15 = call i32 @fgets(i8* %13, i32 1000, i32* %14)
%16 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%17 = load i32*, i32** %3
%18 = call i32 @fgets(i8* %16, i32 1000, i32* %17)
br label %19
19: ; preds = %12
%20 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
%21 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%22 = call i64 @strcmp(i8* %20, i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %12, label %24
24: ; preds = %19
%25 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %24, %8
br label %28
28: ; preds = %27, %0
%29 = load i32*, i32** %2
%30 = call i32 @fclose(i32* %29)
%31 = load i32*, i32** %3
%32 = call i32 @fclose(i32* %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"test2.txt\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [300 x i8]
%2 = alloca [300 x i8]
%3 = getelementptr inbounds [300 x i8], [300 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 0
%5 = 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))
%6 = icmp eq i32* %5, null
br i1 %6, label %17, label %7
7: ; preds = %0
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %17, label %10
10: ; preds = %7, %10
%11 = call i32 @fgets(i8* %3, i32 1000, i32* %5)
%12 = call i32 @fgets(i8* %4, i32 1000, i32* %8)
%13 = call i64 @strcmp(i8* %3, i8* %4)
%14 = icmp eq i64 %13, 0
br i1 %14, label %10, label %15
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %17
17: ; preds = %7, %15, %0
%18 = phi i32* [ %8, %15 ], [ null, %7 ], [ undef, %0 ]
%19 = call i32 @fclose(i32* %5)
%20 = call i32 @fclose(i32* %18)
ret i32 0
}