#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*/ SEEK_CUR;
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
void generate(float *array, int n, FILE *fp) {
  int i;
  fseek(fp, SEEK_CUR, sizeof(float));
  for (i = 0; i < n; i++) {
    fscanf(fp, "%f", (array + i));
  }
}


x86 assembly (clang, -O0):
<generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2eaa(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edx
call   1040 <fseek@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118a <generate+0x6a>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe89(%rip),%rsi
call   1030 <fscanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <generate+0x31>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2eb2(%rip),%rax
mov    (%rax),%esi
mov    %rdx,%rdi
mov    $0x4,%edx
call   1040 <fseek@plt>
test   %ebp,%ebp
jle    1178 <generate+0x58>
mov    %ebp,%ebp
lea    0xeae(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <fscanf@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%rbp
jne    1160 <generate+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_CUR = global i32 0
@.str = [3 x i8] c"%f\00"
define void @generate(float* %0, i32 %1, i32* %2) {
%4 = alloca float*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store float* %0, float** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%8 = load i32*, i32** %6
%9 = load i32, i32* @SEEK_CUR
%10 = call i32 @fseek(i32* %8, i32 %9, i32 4)
store i32 0, i32* %7
br label %11
11: ; preds = %22, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = load i32*, i32** %6
%17 = load float*, float** %4
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds float, float* %17, i64 %19
%21 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %20)
br label %22
22: ; preds = %15
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
br label %11
25: ; preds = %11
ret void
}

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