#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *);
int /*<<< orphan*/ printf(char *);
void generate(float *array, int n, FILE *fp) {
  int i, j;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (!fscanf(fp, "%f", (array + (2 * n * i + j)))) {
        printf("Input file is not in the prescribed format\n");
        exit(0);
      }
}


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)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d5 <generate+0xa5>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c2 <generate+0x92>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
imul   -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe72(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x0,%eax
jne    11af <generate+0x7f>
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    11b4 <generate+0x84>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115d <generate+0x2d>
jmp    11c7 <generate+0x97>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <generate+0x1a>
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
test   %esi,%esi
jle    11af <generate+0x7f>
mov    %rdx,%r12
mov    %rdi,%r14
lea    (%rsi,%rsi,1),%eax
cltq
mov    %esi,%ebp
shl    $0x2,%rax
mov    %rax,0x10(%rsp)
xor    %r13d,%r13d
lea    0xe9e(%rip),%r15
mov    %rbp,0x8(%rsp)
nopw   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   1040 <fscanf@plt>
test   %eax,%eax
je     11be <generate+0x8e>
add    $0x4,%rbx
add    $0xffffffffffffffff,%rbp
jne    1180 <generate+0x50>
add    $0x1,%r13
add    0x10(%rsp),%r14
mov    0x8(%rsp),%rbp
cmp    %rbp,%r13
jne    1170 <generate+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe3e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <exit@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@str = [43 x i8] c"Input file is not in the prescribed format\00"
define void @generate(float* %0, i32 %1, i32* nocapture %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %27
5: ; preds = %3
%6 = shl nuw nsw i32 %1, 1
%7 = sext i32 %6 to i64
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %24, %5
%10 = phi i64 [ 0, %5 ], [ %25, %24 ]
%11 = mul nsw i64 %10, %7
br label %14
12: ; preds = %14
%13 = icmp eq i64 %20, %8
br i1 %13, label %24, label %14
14: ; preds = %9, %12
%15 = phi i64 [ 0, %9 ], [ %20, %12 ]
%16 = add nsw i64 %15, %11
%17 = getelementptr inbounds float, float* %0, i64 %16
%18 = tail call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %17)
%19 = icmp eq i32 %18, 0
%20 = add nuw nsw i64 %15, 1
br i1 %19, label %21, label %12
21: ; preds = %14
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 @exit(i32 0)
unreachable
24: ; preds = %12
%25 = add nuw nsw i64 %10, 1
%26 = icmp eq i64 %25, %8
br i1 %26, label %27, label %9
27: ; preds = %24, %3
ret void
}