#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*/ str2;
typedef int /*<<< orphan*/ str1;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
void compare(FILE *fp1, FILE *fp2) {
  char str1[128], str2[128], *p, *q;
  str1[0] = '\0';
  str2[0] = '\0';
  p = str1, q = str2;
  while (strcmp(str1, str2) == 0) {
    if (p == NULL) {
      return;
    }
    p = fgets(str1, sizeof(str1), fp1);
    q = fgets(str2, sizeof(str2), fp2);
  }
  fprintf(stdout, "< %s\n", str1);
  fprintf(stdout, "> %s\n", str2);
}


x86 assembly (clang, -O0):
<compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x90(%rbp)
movb   $0x0,-0x110(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0x118(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11da <compare+0xaa>
cmpq   $0x0,-0x118(%rbp)
jne    119d <compare+0x6d>
jmp    1212 <compare+0xe2>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x80,%esi
call   1030 <fgets@plt>
mov    %rax,-0x118(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x80,%esi
call   1030 <fgets@plt>
mov    %rax,-0x120(%rbp)
jmp    116d <compare+0x3d>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rdx
lea    0xe0f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    0xdf9(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movb   $0x0,0x80(%rsp)
movb   $0x0,(%rsp)
lea    0x80(%rsp),%r12
mov    %rsp,%rsi
mov    %r12,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11a8 <compare+0x78>
mov    %rsp,%r13
mov    %r12,%rbx
test   %rbx,%rbx
je     11d6 <compare+0xa6>
mov    %r12,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   1030 <fgets@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1170 <compare+0x40>
mov    0x2e31(%rip),%rbx
mov    (%rbx),%edi
lea    0xe48(%rip),%rsi
lea    0x80(%rsp),%rdx
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe38(%rip),%rsi
mov    %rsp,%rdx
call   1050 <fprintf@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [6 x i8] c"< %s\0A\00"
@.str.1 = [6 x i8] c"> %s\0A\00"
define void @compare(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [128 x i8]
%6 = alloca [128 x i8]
%7 = alloca i8*
%8 = alloca i8*
store i32* %0, i32** %3
store i32* %1, i32** %4
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
store i8 0, i8* %9
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
store i8 0, i8* %10
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
store i8* %11, i8** %7
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
store i8* %12, i8** %8
br label %13
13: ; preds = %22, %2
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%16 = call i64 @strcmp(i8* %14, i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %29
18: ; preds = %13
%19 = load i8*, i8** %7
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %22
21: ; preds = %18
br label %36
22: ; preds = %18
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%24 = load i32*, i32** %3
%25 = call i8* @fgets(i8* %23, i32 128, i32* %24)
store i8* %25, i8** %7
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%27 = load i32*, i32** %4
%28 = call i8* @fgets(i8* %26, i32 128, i32* %27)
store i8* %28, i8** %8
br label %13
29: ; preds = %13
%30 = load i32, i32* @stdout
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%32 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = load i32, i32* @stdout
%34 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%35 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %29, %21
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [6 x i8] c"< %s\0A\00"
@.str.1 = [6 x i8] c"> %s\0A\00"
define void @compare(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
store i8 0, i8* %5
store i8 0, i8* %6
%7 = call i64 @strcmp(i8* %5, i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %2, %12
%10 = phi i8* [ %13, %12 ], [ %5, %2 ]
%11 = icmp eq i8* %10, null
br i1 %11, label %22, label %12
12: ; preds = %9
%13 = call i8* @fgets(i8* %5, i32 128, i32* %0)
%14 = call i8* @fgets(i8* %6, i32 128, i32* %1)
%15 = call i64 @strcmp(i8* %5, i8* %6)
%16 = icmp eq i64 %15, 0
br i1 %16, label %9, label %17
17: ; preds = %12, %2
%18 = load i32, i32* @stdout
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5)
%20 = load i32, i32* @stdout
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %22
22: ; preds = %9, %17
ret void
}