#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 + (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    11d2 <generate+0xa2>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bf <generate+0x8f>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%eax
imul   -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe75(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x0,%eax
jne    11ac <generate+0x7c>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    11b1 <generate+0x81>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115d <generate+0x2d>
jmp    11c4 <generate+0x94>
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
mov    %esi,%r13d
lea    0x0(,%r13,4),%rax
mov    %rax,0x8(%rsp)
xor    %ebp,%ebp
lea    0xe9f(%rip),%r15
mov    %r13,0x10(%rsp)
cs 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,%r13
jne    1180 <generate+0x50>
add    $0x1,%rbp
add    0x8(%rsp),%r14
mov    0x10(%rsp),%r13
cmp    %r13,%rbp
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 = %38, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %41
13: ; preds = %9
store i32 0, i32* %8
br label %14
14: ; preds = %34, %13
%15 = load i32, i32* %8
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %37
18: ; preds = %14
%19 = load i32*, i32** %6
%20 = load float*, float** %4
%21 = load i32, i32* %5
%22 = load i32, i32* %7
%23 = mul nsw i32 %21, %22
%24 = load i32, i32* %8
%25 = add nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float, float* %20, i64 %26
%28 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %18
%31 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @exit(i32 0)
unreachable
33: ; preds = %18
br label %34
34: ; preds = %33
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %14
37: ; preds = %14
br label %38
38: ; preds = %37
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %9
41: ; 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 %26
5: ; preds = %3
%6 = zext i32 %1 to i64
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %23, %5
%9 = phi i64 [ 0, %5 ], [ %24, %23 ]
%10 = mul nsw i64 %9, %6
br label %13
11: ; preds = %13
%12 = icmp eq i64 %19, %7
br i1 %12, label %23, label %13
13: ; preds = %8, %11
%14 = phi i64 [ 0, %8 ], [ %19, %11 ]
%15 = add nuw nsw i64 %14, %10
%16 = getelementptr inbounds float, float* %0, i64 %15
%17 = tail call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %16)
%18 = icmp eq i32 %17, 0
%19 = add nuw nsw i64 %14, 1
br i1 %18, label %20, label %11
20: ; preds = %13
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%22 = tail call i32 @exit(i32 0)
unreachable
23: ; preds = %11
%24 = add nuw nsw i64 %9, 1
%25 = icmp eq i64 %24, %7
br i1 %25, label %26, label %8
26: ; preds = %23, %3
ret void
}