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


x86 assembly (clang, -O0):
<generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
mov    $0xc,%edx
call   1040 <fseek@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c0 <generate+0xa0>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ad <generate+0x8d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe66(%rip),%rsi
call   1030 <fscanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1164 <generate+0x44>
jmp    11b2 <generate+0x92>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1151 <generate+0x31>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x2ea3(%rip),%rax
mov    (%rax),%esi
mov    $0xc,%edx
call   1040 <fseek@plt>
test   %ebx,%ebx
jle    11ab <generate+0x8b>
mov    %ebx,%r13d
lea    0x0(,%r13,4),%rax
mov    %rax,0x8(%rsp)
xor    %ebp,%ebp
lea    0xe9a(%rip),%r15
mov    %r13,0x10(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <fscanf@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%r13
jne    1180 <generate+0x60>
add    $0x1,%rbp
add    0x8(%rsp),%r14
mov    0x10(%rsp),%r13
cmp    %r13,%rbp
jne    1170 <generate+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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