#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, double *);
void Read_matrix(char prompt[], double A[], int m, int n) {
  int i, j;
  printf("Enter the matrix %s\n", prompt);
  for (i = 0; i < m; i++)
    for (j = 0; j < n; j++)
      scanf("%lf", &A[i * n + j]);
}


x86 assembly (clang, -O0):
<Read_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b0 <Read_matrix+0x90>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    119d <Read_matrix+0x7d>
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%eax
imul   -0x18(%rbp),%eax
add    -0x20(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe8b(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1160 <Read_matrix+0x40>
jmp    11a2 <Read_matrix+0x82>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114d <Read_matrix+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Read_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,0x4(%rsp)
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%rsi
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
test   %ebx,%ebx
jle    11a7 <Read_matrix+0x87>
movslq 0x4(%rsp),%r12
mov    %ebx,%eax
mov    %rax,0x10(%rsp)
mov    %r12d,%eax
mov    %rax,0x8(%rsp)
shl    $0x3,%r12
xor    %r14d,%r14d
lea    0xea9(%rip),%rbp
jmp    117e <Read_matrix+0x5e>
xchg   %ax,%ax
add    $0x1,%r14
add    %r12,%r15
cmp    0x10(%rsp),%r14
je     11a7 <Read_matrix+0x87>
cmpl   $0x0,0x4(%rsp)
jle    1170 <Read_matrix+0x50>
mov    0x8(%rsp),%r13
mov    %r15,%rbx
nopl   (%rax)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x8,%rbx
add    $0xffffffffffffffff,%r13
jne    1190 <Read_matrix+0x70>
jmp    1170 <Read_matrix+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [21 x i8] c"Enter the matrix %s\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
define void @Read_matrix(i8* %0, double* %1, i32 %2, i32 %3) {
%5 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %26
7: ; preds = %4
%8 = icmp sgt i32 %3, 0
%9 = sext i32 %3 to i64
%10 = zext i32 %2 to i64
%11 = zext i32 %3 to i64
br label %12
12: ; preds = %7, %23
%13 = phi i64 [ 0, %7 ], [ %24, %23 ]
br i1 %8, label %14, label %23
14: ; preds = %12
%15 = mul nsw i64 %13, %9
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 0, %14 ], [ %21, %16 ]
%18 = add nsw i64 %17, %15
%19 = getelementptr inbounds double, double* %1, i64 %18
%20 = tail call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %19)
%21 = add nuw nsw i64 %17, 1
%22 = icmp eq i64 %21, %11
br i1 %22, label %23, label %16
23: ; preds = %16, %12
%24 = add nuw nsw i64 %13, 1
%25 = icmp eq i64 %24, %10
br i1 %25, label %26, label %12
26: ; preds = %23, %4
ret void
}