#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 */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
long *malloc(int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vi_tailIteration(char *, long *);
void vi_tail(int filec, char **filev) {
  long *len;
  int i;
  if (filec <= 0) {
    fprintf(stderr, "No files specified in tail-mode\n");
    exit(1);
  }
  len = malloc(filec);
  if (!len) {
    fprintf(stderr, "Out of memory\n");
    exit(1);
  }
  for (i = 0; i < filec; i++)
    len[i] = -1;
  while (1) {
    for (i = 0; i < filec; i++)
      vi_tailIteration(filev[i], &len[i]);
    sleep(1);
  }
}


x86 assembly (clang, -O0):
<vi_tail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     1188 <vi_tail+0x38>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11be <vi_tail+0x6e>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ef <vi_tail+0x9f>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movq   $0xffffffffffffffff,(%rax,%rcx,8)
ff
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c5 <vi_tail+0x75>
jmp    11f4 <vi_tail+0xa4>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1235 <vi_tail+0xe5>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1070 <vi_tailIteration@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11fb <vi_tail+0xab>
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    11f4 <vi_tail+0xa4>

x86 assembly (clang, -O2):
<vi_tail>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    11c4 <vi_tail+0x64>
mov    %rsi,%r14
mov    %edi,%ebp
call   1050 <malloc@plt>
test   %rax,%rax
je     11d6 <vi_tail+0x76>
mov    %rax,%r15
mov    %ebp,%ebp
lea    0x0(,%rbp,8),%rdx
mov    %rax,%rdi
mov    $0xff,%esi
call   1030 <memset@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ebx,%ebx
mov    (%r14,%rbx,8),%rdi
lea    (%r15,%rbx,8),%rsi
call   1080 <vi_tailIteration@plt>
add    $0x1,%rbx
cmp    %rbp,%rbx
jne    11a2 <vi_tail+0x42>
mov    $0x1,%edi
call   1070 <sleep@plt>
jmp    11a0 <vi_tail+0x40>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
jmp    11e6 <vi_tail+0x86>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"No files specified in tail-mode\0A\00"
@.str.1 = [15 x i8] c"Out of memory\0A\00"
define void @vi_tail(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i64*
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i32, i32* %3
%15 = call i64* @malloc(i32 %14)
store i64* %15, i64** %5
%16 = load i64*, i64** %5
%17 = icmp ne i64* %16, null
br i1 %17, label %22, label %18
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %13
store i32 0, i32* %6
br label %23
23: ; preds = %32, %22
%24 = load i32, i32* %6
%25 = load i32, i32* %3
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %35
27: ; preds = %23
%28 = load i64*, i64** %5
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i64, i64* %28, i64 %30
store i64 -1, i64* %31
br label %32
32: ; preds = %27
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %23
35: ; preds = %23
br label %36
36: ; preds = %35, %55
store i32 0, i32* %6
br label %37
37: ; preds = %52, %36
%38 = load i32, i32* %6
%39 = load i32, i32* %3
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %55
41: ; preds = %37
%42 = load i8**, i8*** %4
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = load i64*, i64** %5
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i64, i64* %47, i64 %49
%51 = call i32 @vi_tailIteration(i8* %46, i64* %50)
br label %52
52: ; preds = %41
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %37
55: ; preds = %37
%56 = call i32 @sleep(i32 1)
br label %36
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"No files specified in tail-mode\0A\00"
@.str.1 = [15 x i8] c"Out of memory\0A\00"
define void @vi_tail(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = tail call i64* @malloc(i32 %0)
%10 = icmp eq i64* %9, null
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %8
%16 = bitcast i64* %9 to i8*
%17 = zext i32 %0 to i64
%18 = shl nuw nsw i64 %17, 3
%19 = zext i32 %0 to i64
br label %20
20: ; preds = %28, %15
%21 = phi i64 [ 0, %15 ], [ %29, %28 ]
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i64, i64* %9, i64 %21
%25 = tail call i32 @vi_tailIteration(i8* %23, i64* %24)
%26 = add nuw nsw i64 %21, 1
%27 = icmp eq i64 %26, %19
br i1 %27, label %30, label %28
28: ; preds = %20, %30
%29 = phi i64 [ %26, %20 ], [ 0, %30 ]
br label %20
30: ; preds = %20
%31 = tail call i32 @sleep(i32 1)
br label %28
}