#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*/ *vi_openAtEnd(char *, long *);
int vi_tailOutput(int /*<<< orphan*/ *, long, long);
void vi_tailIteration(char *filename, long *len) {
  long newlen, datalen;
  FILE *fp = NULL;
  fp = vi_openAtEnd(filename, &newlen);
  if (fp != NULL) {
    if (*len == -1) {
      *len = newlen;
    } else if (newlen < *len) {
      *len = 0;
    } else if (newlen > *len) {
      datalen = newlen - *len;
      if (vi_tailOutput(fp, *len, datalen) != -1)
        *len = newlen;
    }
  }
  if (fp != NULL)
    fclose(fp);
}


x86 assembly (clang, -O0):
<vi_tailIteration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <vi_openAtEnd@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ff <vi_tailIteration+0xcf>
mov    -0x10(%rbp),%rax
cmpq   $0xffffffffffffffff,(%rax)
jne    1182 <vi_tailIteration+0x52>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    11fa <vi_tailIteration+0xca>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jge    11a3 <vi_tailIteration+0x73>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
jmp    11f5 <vi_tailIteration+0xc5>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jle    11f0 <vi_tailIteration+0xc0>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    (%rcx),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <vi_tailOutput@plt>
cmp    $0xffffffff,%eax
je     11eb <vi_tailIteration+0xbb>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    11f0 <vi_tailIteration+0xc0>
jmp    11f5 <vi_tailIteration+0xc5>
jmp    11fa <vi_tailIteration+0xca>
jmp    11ff <vi_tailIteration+0xcf>
cmpq   $0x0,-0x28(%rbp)
je     1213 <vi_tailIteration+0xe3>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vi_tailIteration>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rsp,%rsi
call   1050 <vi_openAtEnd@plt>
test   %rax,%rax
je     117b <vi_tailIteration+0x4b>
mov    %rax,%rbx
mov    (%r14),%rsi
mov    (%rsp),%rdx
cmp    $0xffffffffffffffff,%rsi
je     1170 <vi_tailIteration+0x40>
sub    %rsi,%rdx
jge    115d <vi_tailIteration+0x2d>
xor    %edx,%edx
jmp    1170 <vi_tailIteration+0x40>
jle    1173 <vi_tailIteration+0x43>
mov    %rbx,%rdi
call   1040 <vi_tailOutput@plt>
cmp    $0xffffffff,%eax
je     1173 <vi_tailIteration+0x43>
mov    (%rsp),%rdx
mov    %rdx,(%r14)
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @vi_tailIteration(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32*
store i8* %0, i8** %3
store i64* %1, i64** %4
store i32* null, i32** %7
%8 = load i8*, i8** %3
%9 = call i32* @vi_openAtEnd(i8* %8, i64* %5)
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %49
12: ; preds = %2
%13 = load i64*, i64** %4
%14 = load i64, i64* %13
%15 = icmp eq i64 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i64, i64* %5
%18 = load i64*, i64** %4
store i64 %17, i64* %18
br label %48
19: ; preds = %12
%20 = load i64, i64* %5
%21 = load i64*, i64** %4
%22 = load i64, i64* %21
%23 = icmp slt i64 %20, %22
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = load i64*, i64** %4
store i64 0, i64* %25
br label %47
26: ; preds = %19
%27 = load i64, i64* %5
%28 = load i64*, i64** %4
%29 = load i64, i64* %28
%30 = icmp sgt i64 %27, %29
br i1 %30, label %31, label %46
31: ; preds = %26
%32 = load i64, i64* %5
%33 = load i64*, i64** %4
%34 = load i64, i64* %33
%35 = sub nsw i64 %32, %34
store i64 %35, i64* %6
%36 = load i32*, i32** %7
%37 = load i64*, i64** %4
%38 = load i64, i64* %37
%39 = load i64, i64* %6
%40 = call i32 @vi_tailOutput(i32* %36, i64 %38, i64 %39)
%41 = icmp ne i32 %40, -1
br i1 %41, label %42, label %45
42: ; preds = %31
%43 = load i64, i64* %5
%44 = load i64*, i64** %4
store i64 %43, i64* %44
br label %45
45: ; preds = %42, %31
br label %46
46: ; preds = %45, %26
br label %47
47: ; preds = %46, %24
br label %48
48: ; preds = %47, %16
br label %49
49: ; preds = %48, %2
%50 = load i32*, i32** %7
%51 = icmp ne i32* %50, null
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i32*, i32** %7
%54 = call i32 @fclose(i32* %53)
br label %55
55: ; preds = %52, %49
ret void
}

LLVM IR (-O2):
define void @vi_tailIteration(i8* %0, i64* nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = call i32* @vi_openAtEnd(i8* %0, i64* %3)
%6 = icmp eq i32* %5, null
br i1 %6, label %25, label %7
7: ; preds = %2
%8 = load i64, i64* %1
%9 = icmp eq i64 %8, -1
%10 = load i64, i64* %3
br i1 %9, label %21, label %11
11: ; preds = %7
%12 = icmp slt i64 %10, %8
br i1 %12, label %21, label %13
13: ; preds = %11
%14 = icmp sgt i64 %10, %8
br i1 %14, label %15, label %23
15: ; preds = %13
%16 = sub nsw i64 %10, %8
%17 = call i32 @vi_tailOutput(i32* %5, i64 %8, i64 %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i64, i64* %3
br label %21
21: ; preds = %11, %7, %19
%22 = phi i64 [ %20, %19 ], [ %10, %7 ], [ 0, %11 ]
store i64 %22, i64* %1
br label %23
23: ; preds = %21, %15, %13
%24 = call i32 @fclose(i32* %5)
br label %25
25: ; preds = %2, %23
ret void
}