#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 */
char *bh_fgetline(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int bh_fskipline(FILE *f, int nb_lines) {
  int i;
  char *line = NULL;
  for (i = 0; i < nb_lines; ++i) {
    line = bh_fgetline(f);
    if (line == NULL) {
      rewind(f);
      line = bh_fgetline(f);
    }
    {
      if (line) {
        free(line);
        (line) = NULL;
      }
    };
  }
  return 0;
}


x86 assembly (clang, -O0):
<bh_fskipline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b7 <bh_fskipline+0x87>
mov    -0x8(%rbp),%rdi
call   1050 <bh_fgetline@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1188 <bh_fskipline+0x58>
mov    -0x8(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x8(%rbp),%rdi
call   1050 <bh_fgetline@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a4 <bh_fskipline+0x74>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
jmp    11a9 <bh_fskipline+0x79>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114e <bh_fskipline+0x1e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bh_fskipline>:
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1171 <bh_fskipline+0x41>
mov    %esi,%ebx
mov    %rdi,%r14
jmp    114d <bh_fskipline+0x1d>
nop
mov    %rax,%rdi
call   1030 <free@plt>
add    $0xffffffff,%ebx
je     1171 <bh_fskipline+0x41>
mov    %r14,%rdi
call   1050 <bh_fgetline@plt>
test   %rax,%rax
jne    1140 <bh_fskipline+0x10>
mov    %r14,%rdi
call   1040 <rewind@plt>
mov    %r14,%rdi
call   1050 <bh_fgetline@plt>
test   %rax,%rax
jne    1140 <bh_fskipline+0x10>
jmp    1148 <bh_fskipline+0x18>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @bh_fskipline(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32* %0, i32** %3
store i32 %1, i32* %4
store i8* null, i8** %6
store i32 0, i32* %5
br label %7
7: ; preds = %28, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %31
11: ; preds = %7
%12 = load i32*, i32** %3
%13 = call i8* @bh_fgetline(i32* %12)
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32*, i32** %3
%18 = call i32 @rewind(i32* %17)
%19 = load i32*, i32** %3
%20 = call i8* @bh_fgetline(i32* %19)
store i8* %20, i8** %6
br label %21
21: ; preds = %16, %11
%22 = load i8*, i8** %6
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i8*, i8** %6
%26 = call i32 @free(i8* %25)
store i8* null, i8** %6
br label %27
27: ; preds = %24, %21
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %7
31: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
define i32 @bh_fskipline(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %18
4: ; preds = %2, %15
%5 = phi i32 [ %16, %15 ], [ 0, %2 ]
%6 = tail call i8* @bh_fgetline(i32* %0)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = tail call i32 @rewind(i32* %0)
%10 = tail call i8* @bh_fgetline(i32* %0)
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %4, %8
%13 = phi i8* [ %10, %8 ], [ %6, %4 ]
%14 = tail call i32 @free(i8* %13)
br label %15
15: ; preds = %8, %12
%16 = add nuw nsw i32 %5, 1
%17 = icmp eq i32 %16, %1
br i1 %17, label %18, label %4
18: ; preds = %15, %2
ret i32 0
}