#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*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_SET;
unsigned long SkipFrame(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
unsigned long strlen(char *);
void ForwardToFrame(unsigned long Frame, FILE *Log1, FILE *Log2) {
  unsigned long FrameNumber1 = 0, FrameNumber2 = 0;
  long Position1, Position2;
  while (FrameNumber1 < Frame && FrameNumber2 < Frame && !feof(Log1) &&
         !feof(Log2)) {
    if (Frame - FrameNumber1 > 2)
      fseek(Log1, (Frame - FrameNumber1 - 2) * strlen("Frame n Begin End") - 2,
            SEEK_CUR);
    if (Frame - FrameNumber2 > 2)
      fseek(Log2, (Frame - FrameNumber2 - 2) * strlen("Frame n Begin End") - 2,
            SEEK_CUR);
    Position1 = ftell(Log1);
    Position2 = ftell(Log2);
    FrameNumber1 = SkipFrame(Log1);
    FrameNumber2 = SkipFrame(Log2);
    if (FrameNumber1 >= Frame)
      fseek(Log1, Position1, SEEK_SET);
    if (FrameNumber2 >= Frame)
      fseek(Log2, Position2, SEEK_SET);
    while (FrameNumber1 < FrameNumber2)
      FrameNumber1 = SkipFrame(Log1);
    while (FrameNumber2 < FrameNumber1)
      FrameNumber2 = SkipFrame(Log2);
  }
}


x86 assembly (clang, -O0):
<ForwardToFrame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x39(%rbp)
jae    11c7 <ForwardToFrame+0x77>
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x39(%rbp)
jae    11c7 <ForwardToFrame+0x77>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x39(%rbp)
jne    11c7 <ForwardToFrame+0x77>
mov    -0x18(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11d7 <ForwardToFrame+0x87>
jmp    134a <ForwardToFrame+0x1fa>
mov    -0x8(%rbp),%rax
sub    -0x20(%rbp),%rax
cmp    $0x2,%rax
jbe    122b <ForwardToFrame+0xdb>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
sub    -0x20(%rbp),%rax
sub    $0x2,%rax
mov    %rax,-0x50(%rbp)
lea    0xdf8(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdi
imul   %rax,%rsi
sub    $0x2,%rsi
mov    0x2dc4(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x8(%rbp),%rax
sub    -0x28(%rbp),%rax
cmp    $0x2,%rax
jbe    127f <ForwardToFrame+0x12f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rax
sub    -0x28(%rbp),%rax
sub    $0x2,%rax
mov    %rax,-0x60(%rbp)
lea    0xda4(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x60(%rbp),%rsi
mov    -0x58(%rbp),%rdi
imul   %rax,%rsi
sub    $0x2,%rsi
mov    0x2d70(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <SkipFrame@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <SkipFrame@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jb     12d7 <ForwardToFrame+0x187>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    0x2d08(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jb     12fb <ForwardToFrame+0x1ab>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    0x2ce4(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
jmp    1300 <ForwardToFrame+0x1b0>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1320 <ForwardToFrame+0x1d0>
mov    -0x10(%rbp),%rdi
call   1070 <SkipFrame@plt>
mov    %rax,-0x20(%rbp)
jmp    1300 <ForwardToFrame+0x1b0>
jmp    1325 <ForwardToFrame+0x1d5>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1345 <ForwardToFrame+0x1f5>
mov    -0x18(%rbp),%rdi
call   1070 <SkipFrame@plt>
mov    %rax,-0x28(%rbp)
jmp    1325 <ForwardToFrame+0x1d5>
jmp    1174 <ForwardToFrame+0x24>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ForwardToFrame>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     12be <ForwardToFrame+0x17e>
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
xor    %ebx,%ebx
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
call   1040 <feof@plt>
test   %eax,%eax
jne    12be <ForwardToFrame+0x17e>
mov    %r14,%rdi
call   1040 <feof@plt>
test   %eax,%eax
jne    12be <ForwardToFrame+0x17e>
mov    %r15,%rax
sub    %rbx,%rax
cmp    $0x3,%rax
jb     11bc <ForwardToFrame+0x7c>
mov    %rax,%rcx
shl    $0x4,%rcx
lea    (%rax,%rcx,1),%rsi
add    $0xffffffffffffffdc,%rsi
mov    0x2e36(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
call   1050 <fseek@plt>
mov    %r15,%rax
sub    %r13,%rax
cmp    $0x3,%rax
jb     11e8 <ForwardToFrame+0xa8>
mov    %rax,%rcx
shl    $0x4,%rcx
lea    (%rax,%rcx,1),%rsi
add    $0xffffffffffffffdc,%rsi
mov    0x2e0a(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
call   1050 <fseek@plt>
mov    %r12,%rdi
call   1030 <ftell@plt>
mov    %rax,%rbp
mov    %r14,%rdi
call   1030 <ftell@plt>
mov    %rax,(%rsp)
mov    %r12,%rdi
call   1060 <SkipFrame@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1060 <SkipFrame@plt>
mov    %rax,%r13
cmp    %r15,%rbx
jae    1240 <ForwardToFrame+0x100>
cmp    %r15,%r13
jae    1259 <ForwardToFrame+0x119>
cmp    %r13,%rbx
jb     1280 <ForwardToFrame+0x140>
cmp    %rbx,%r13
jb     12a0 <ForwardToFrame+0x160>
cmp    %r15,%rbx
jb     12b5 <ForwardToFrame+0x175>
jmp    12be <ForwardToFrame+0x17e>
nopw   0x0(%rax,%rax,1)
mov    0x2d91(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    %rbp,%rsi
call   1050 <fseek@plt>
cmp    %r15,%r13
jb     121f <ForwardToFrame+0xdf>
mov    0x2d78(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    (%rsp),%rsi
call   1050 <fseek@plt>
cmp    %r13,%rbx
jae    1224 <ForwardToFrame+0xe4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
call   1060 <SkipFrame@plt>
cmp    %r13,%rax
jb     1280 <ForwardToFrame+0x140>
mov    %rax,%rbx
cmp    %rbx,%r13
jae    1229 <ForwardToFrame+0xe9>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1060 <SkipFrame@plt>
cmp    %rbx,%rax
jb     12a0 <ForwardToFrame+0x160>
mov    %rax,%r13
cmp    %r15,%rbx
jae    12be <ForwardToFrame+0x17e>
cmp    %r15,%r13
jb     1170 <ForwardToFrame+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Frame n Begin End\00"
@SEEK_CUR = global i32 0
@SEEK_SET = global i32 0
define void @ForwardToFrame(i64 %0, i32* %1, i32* %2) {
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i64 %0, i64* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i64 0, i64* %7
store i64 0, i64* %8
br label %11
11: ; preds = %104, %3
%12 = load i64, i64* %7
%13 = load i64, i64* %4
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %28
15: ; preds = %11
%16 = load i64, i64* %8
%17 = load i64, i64* %4
%18 = icmp ult i64 %16, %17
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = load i32*, i32** %5
%21 = call i32 @feof(i32* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %19
%24 = load i32*, i32** %6
%25 = call i32 @feof(i32* %24)
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
br label %28
28: ; preds = %23, %19, %15, %11
%29 = phi i1 [ false, %19 ], [ false, %15 ], [ false, %11 ], [ %27, %23 ]
br i1 %29, label %30, label %105
30: ; preds = %28
%31 = load i64, i64* %4
%32 = load i64, i64* %7
%33 = sub i64 %31, %32
%34 = icmp ugt i64 %33, 2
br i1 %34, label %35, label %46
35: ; preds = %30
%36 = load i32*, i32** %5
%37 = load i64, i64* %4
%38 = load i64, i64* %7
%39 = sub i64 %37, %38
%40 = sub i64 %39, 2
%41 = call i64 @strlen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%42 = mul i64 %40, %41
%43 = sub i64 %42, 2
%44 = load i32, i32* @SEEK_CUR
%45 = call i32 @fseek(i32* %36, i64 %43, i32 %44)
br label %46
46: ; preds = %35, %30
%47 = load i64, i64* %4
%48 = load i64, i64* %8
%49 = sub i64 %47, %48
%50 = icmp ugt i64 %49, 2
br i1 %50, label %51, label %62
51: ; preds = %46
%52 = load i32*, i32** %6
%53 = load i64, i64* %4
%54 = load i64, i64* %8
%55 = sub i64 %53, %54
%56 = sub i64 %55, 2
%57 = call i64 @strlen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%58 = mul i64 %56, %57
%59 = sub i64 %58, 2
%60 = load i32, i32* @SEEK_CUR
%61 = call i32 @fseek(i32* %52, i64 %59, i32 %60)
br label %62
62: ; preds = %51, %46
%63 = load i32*, i32** %5
%64 = call i64 @ftell(i32* %63)
store i64 %64, i64* %9
%65 = load i32*, i32** %6
%66 = call i64 @ftell(i32* %65)
store i64 %66, i64* %10
%67 = load i32*, i32** %5
%68 = call i64 @SkipFrame(i32* %67)
store i64 %68, i64* %7
%69 = load i32*, i32** %6
%70 = call i64 @SkipFrame(i32* %69)
store i64 %70, i64* %8
%71 = load i64, i64* %7
%72 = load i64, i64* %4
%73 = icmp uge i64 %71, %72
br i1 %73, label %74, label %79
74: ; preds = %62
%75 = load i32*, i32** %5
%76 = load i64, i64* %9
%77 = load i32, i32* @SEEK_SET
%78 = call i32 @fseek(i32* %75, i64 %76, i32 %77)
br label %79
79: ; preds = %74, %62
%80 = load i64, i64* %8
%81 = load i64, i64* %4
%82 = icmp uge i64 %80, %81
br i1 %82, label %83, label %88
83: ; preds = %79
%84 = load i32*, i32** %6
%85 = load i64, i64* %10
%86 = load i32, i32* @SEEK_SET
%87 = call i32 @fseek(i32* %84, i64 %85, i32 %86)
br label %88
88: ; preds = %83, %79
br label %89
89: ; preds = %93, %88
%90 = load i64, i64* %7
%91 = load i64, i64* %8
%92 = icmp ult i64 %90, %91
br i1 %92, label %93, label %96
93: ; preds = %89
%94 = load i32*, i32** %5
%95 = call i64 @SkipFrame(i32* %94)
store i64 %95, i64* %7
br label %89
96: ; preds = %89
br label %97
97: ; preds = %101, %96
%98 = load i64, i64* %8
%99 = load i64, i64* %7
%100 = icmp ult i64 %98, %99
br i1 %100, label %101, label %104
101: ; preds = %97
%102 = load i32*, i32** %6
%103 = call i64 @SkipFrame(i32* %102)
store i64 %103, i64* %8
br label %97
104: ; preds = %97
br label %11
105: ; preds = %28
ret void
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
@SEEK_SET = global i32 0
define void @ForwardToFrame(i64 %0, i32* %1, i32* %2) {
%4 = icmp eq i64 %0, 0
br i1 %4, label %59, label %10
5: ; preds = %56, %50
%6 = phi i64 [ %38, %50 ], [ %57, %56 ]
%7 = icmp ult i64 %51, %0
%8 = icmp ult i64 %6, %0
%9 = select i1 %7, i1 %8, i1 false
br i1 %9, label %10, label %59
10: ; preds = %3, %5
%11 = phi i64 [ %51, %5 ], [ 0, %3 ]
%12 = phi i64 [ %6, %5 ], [ 0, %3 ]
%13 = tail call i32 @feof(i32* %1)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %59
15: ; preds = %10
%16 = tail call i32 @feof(i32* %2)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %59
18: ; preds = %15
%19 = sub i64 %0, %11
%20 = icmp ugt i64 %19, 2
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = mul i64 %19, 17
%23 = add i64 %22, -36
%24 = load i32, i32* @SEEK_CUR
%25 = tail call i32 @fseek(i32* %1, i64 %23, i32 %24)
br label %26
26: ; preds = %21, %18
%27 = sub i64 %0, %12
%28 = icmp ugt i64 %27, 2
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = mul i64 %27, 17
%31 = add i64 %30, -36
%32 = load i32, i32* @SEEK_CUR
%33 = tail call i32 @fseek(i32* %2, i64 %31, i32 %32)
br label %34
34: ; preds = %29, %26
%35 = tail call i64 @ftell(i32* %1)
%36 = tail call i64 @ftell(i32* %2)
%37 = tail call i64 @SkipFrame(i32* %1)
%38 = tail call i64 @SkipFrame(i32* %2)
%39 = icmp ult i64 %37, %0
br i1 %39, label %43, label %40
40: ; preds = %34
%41 = load i32, i32* @SEEK_SET
%42 = tail call i32 @fseek(i32* %1, i64 %35, i32 %41)
br label %43
43: ; preds = %40, %34
%44 = icmp ult i64 %38, %0
br i1 %44, label %48, label %45
45: ; preds = %43
%46 = load i32, i32* @SEEK_SET
%47 = tail call i32 @fseek(i32* %2, i64 %36, i32 %46)
br label %48
48: ; preds = %45, %43
%49 = icmp ult i64 %37, %38
br i1 %49, label %53, label %50
50: ; preds = %53, %48
%51 = phi i64 [ %37, %48 ], [ %54, %53 ]
%52 = icmp ult i64 %38, %51
br i1 %52, label %56, label %5
53: ; preds = %48, %53
%54 = tail call i64 @SkipFrame(i32* %1)
%55 = icmp ult i64 %54, %38
br i1 %55, label %53, label %50
56: ; preds = %50, %56
%57 = tail call i64 @SkipFrame(i32* %2)
%58 = icmp ult i64 %57, %51
br i1 %58, label %56, label %5
59: ; preds = %15, %10, %5, %3
ret void
}