#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 fscanf(int /*<<< orphan*/ *, char *, char *);
int skip_lines(FILE *fp, int k) {
  char c;
  int go_on = 1;
  int cnt = k;
  do {
    go_on = fscanf(fp, "%c", &c);
    if (go_on != 1)
      break;
    if (c == '\n')
      cnt = cnt - 1;
    go_on = (cnt > 0);
  } while (go_on == 1);
  return cnt;
}


x86 assembly (clang, -O0):
<skip_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
lea    -0xd(%rbp),%rdx
call   1030 <fscanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     1152 <skip_lines+0x42>
jmp    1181 <skip_lines+0x71>
movsbl -0xd(%rbp),%eax
cmp    $0xa,%eax
jne    1168 <skip_lines+0x58>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     112c <skip_lines+0x1c>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_lines>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xedc(%rip),%r15
lea    0x7(%rsp),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <fscanf@plt>
cmp    $0x1,%eax
jne    1153 <skip_lines+0x43>
xor    %eax,%eax
cmpb   $0xa,0x7(%rsp)
sete   %al
sub    %eax,%ebx
test   %ebx,%ebx
jg     1130 <skip_lines+0x20>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define i32 @skip_lines(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 1, i32* %6
%8 = load i32, i32* %4
store i32 %8, i32* %7
br label %9
9: ; preds = %26, %2
%10 = load i32*, i32** %3
%11 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %9
br label %29
15: ; preds = %9
%16 = load i8, i8* %5
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %7
%21 = sub nsw i32 %20, 1
store i32 %21, i32* %7
br label %22
22: ; preds = %19, %15
%23 = load i32, i32* %7
%24 = icmp sgt i32 %23, 0
%25 = zext i1 %24 to i32
store i32 %25, i32* %6
br label %26
26: ; preds = %22
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 1
br i1 %28, label %9, label %29
29: ; preds = %26, %14
%30 = load i32, i32* %7
ret i32 %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define i32 @skip_lines(i32* nocapture %0, i32 %1) {
%3 = alloca i8
br label %4
4: ; preds = %8, %2
%5 = phi i32 [ %1, %2 ], [ %12, %8 ]
%6 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = load i8, i8* %3
%10 = icmp eq i8 %9, 10
%11 = sext i1 %10 to i32
%12 = add nsw i32 %5, %11
%13 = icmp sgt i32 %12, 0
br i1 %13, label %4, label %14
14: ; preds = %4, %8
%15 = phi i32 [ %5, %4 ], [ %12, %8 ]
ret i32 %15
}