#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*/ mpfr_t;
typedef int /*<<< orphan*/ gmp_randstate_t;

/* Variables and functions */
int /*<<< orphan*/ gmp_randinit_default(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_get_default_rounding_mode();
scalar_t__ mpfr_urandom(int /*<<< orphan*/, int /*<<< orphan*/,
                        int /*<<< orphan*/);
int fillMatrixRandomly(const size_t m, const size_t n, mpfr_t array[m][n]) {
  int res = 0;
  gmp_randstate_t randState;
  gmp_randinit_default(randState);
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      res += mpfr_urandom(array[i][j], randState,
                          mpfr_get_default_rounding_mode());
    }
  }
  return res;
}


x86 assembly (clang, -O0):
<fillMatrixRandomly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
call   1050 <gmp_randinit_default@plt>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11ee <fillMatrixRandomly+0xbe>
movl   $0x0,-0x28(%rbp)
movslq -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11db <fillMatrixRandomly+0xab>
mov    -0x30(%rbp),%rdx
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1030 <mpfr_get_default_rounding_mode@plt>
mov    -0x38(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    %eax,%edx
call   1040 <mpfr_urandom@plt>
mov    %rax,%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1177 <fillMatrixRandomly+0x47>
jmp    11e0 <fillMatrixRandomly+0xb0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1162 <fillMatrixRandomly+0x32>
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fillMatrixRandomly>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <gmp_randinit_default@plt>
mov    %rbx,0x10(%rsp)
test   %rbx,%rbx
je     11b1 <fillMatrixRandomly+0x81>
lea    0x0(,%r14,4),%rax
mov    %rax,0x8(%rsp)
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    1180 <fillMatrixRandomly+0x50>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15
add    0x8(%rsp),%r12
cmp    0x10(%rsp),%r15
je     11b3 <fillMatrixRandomly+0x83>
test   %r14,%r14
je     1170 <fillMatrixRandomly+0x40>
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    (%r12,%r13,4),%ebx
xor    %eax,%eax
call   1030 <mpfr_get_default_rounding_mode@plt>
mov    %ebx,%edi
mov    %eax,%edx
call   1040 <mpfr_urandom@plt>
add    %eax,%ebp
add    $0x1,%r13
cmp    %r13,%r14
jne    1190 <fillMatrixRandomly+0x60>
jmp    1170 <fillMatrixRandomly+0x40>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fillMatrixRandomly(i64 %0, i64 %1, i32* %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i64 %0, i64* %4
store i64 %1, i64* %5
store i32* %2, i32** %6
%11 = load i64, i64* %4
%12 = load i64, i64* %5
store i32 0, i32* %7
%13 = load i32, i32* %8
%14 = call i32 @gmp_randinit_default(i32 %13)
store i32 0, i32* %9
br label %15
15: ; preds = %47, %3
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = load i64, i64* %4
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %50
20: ; preds = %15
store i32 0, i32* %10
br label %21
21: ; preds = %43, %20
%22 = load i32, i32* %10
%23 = sext i32 %22 to i64
%24 = load i64, i64* %5
%25 = icmp ult i64 %23, %24
br i1 %25, label %26, label %46
26: ; preds = %21
%27 = load i32*, i32** %6
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = mul nsw i64 %29, %12
%31 = getelementptr inbounds i32, i32* %27, i64 %30
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = load i32, i32* %8
%37 = call i32 (...) @mpfr_get_default_rounding_mode()
%38 = call i64 @mpfr_urandom(i32 %35, i32 %36, i32 %37)
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = add nsw i64 %40, %38
%42 = trunc i64 %41 to i32
store i32 %42, i32* %7
br label %43
43: ; preds = %26
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
store i32 %45, i32* %10
br label %21
46: ; preds = %21
br label %47
47: ; preds = %46
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %15
50: ; preds = %15
%51 = load i32, i32* %7
ret i32 %51
}

LLVM IR (-O2):
define i32 @fillMatrixRandomly(i64 %0, i64 %1, i32* nocapture %2) {
%4 = tail call i32 @gmp_randinit_default(i32 undef)
%5 = icmp eq i64 %0, 0
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = icmp eq i64 %1, 0
br label %8
8: ; preds = %6, %16
%9 = phi i64 [ 0, %6 ], [ %18, %16 ]
%10 = phi i32 [ 0, %6 ], [ %17, %16 ]
br i1 %7, label %16, label %11
11: ; preds = %8
%12 = mul nsw i64 %9, %1
%13 = getelementptr inbounds i32, i32* %2, i64 %12
br label %20
14: ; preds = %16, %3
%15 = phi i32 [ 0, %3 ], [ %17, %16 ]
ret i32 %15
16: ; preds = %20, %8
%17 = phi i32 [ %10, %8 ], [ %28, %20 ]
%18 = add nuw i64 %9, 1
%19 = icmp eq i64 %18, %0
br i1 %19, label %14, label %8
20: ; preds = %11, %20
%21 = phi i64 [ 0, %11 ], [ %29, %20 ]
%22 = phi i32 [ %10, %11 ], [ %28, %20 ]
%23 = getelementptr inbounds i32, i32* %13, i64 %21
%24 = load i32, i32* %23
%25 = tail call i32 (...) @mpfr_get_default_rounding_mode()
%26 = tail call i64 @mpfr_urandom(i32 %24, i32 undef, i32 %25)
%27 = trunc i64 %26 to i32
%28 = add i32 %22, %27
%29 = add nuw i64 %21, 1
%30 = icmp eq i64 %29, %1
br i1 %30, label %16, label %20
}