#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 EOF;
scalar_t__ ferror(int /*<<< orphan*/ *);
int fscanf(int /*<<< orphan*/ *, char *);
int skipNDoubles(FILE *fp, int nvals) {
  register int i;
  int j;
  for (i = 0; i < nvals; ++i) {
    j = fscanf(fp, "%*f");
    if (j == EOF)
      return EOF;
    if (ferror(fp))
      return EOF - 1;
  }
  return nvals;
}


x86 assembly (clang, -O0):
<skipNDoubles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b2 <skipNDoubles+0x92>
mov    -0x10(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1040 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e89(%rip),%rcx
cmp    (%rcx),%eax
jne    1178 <skipNDoubles+0x58>
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11b8 <skipNDoubles+0x98>
mov    -0x10(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     119f <skipNDoubles+0x7f>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11b8 <skipNDoubles+0x98>
jmp    11a4 <skipNDoubles+0x84>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1136 <skipNDoubles+0x16>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skipNDoubles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
test   %esi,%esi
jle    1182 <skipNDoubles+0x62>
mov    %rdi,%r13
lea    0xec4(%rip),%r15
mov    0x2ea5(%rip),%r12
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <fscanf@plt>
mov    (%r12),%ebx
cmp    %ebx,%eax
je     1177 <skipNDoubles+0x57>
mov    %r13,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    117c <skipNDoubles+0x5c>
add    $0xffffffff,%ebp
jne    1150 <skipNDoubles+0x30>
jmp    1182 <skipNDoubles+0x62>
mov    %eax,%r14d
jmp    1182 <skipNDoubles+0x62>
add    $0xffffffff,%ebx
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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