#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 */
double get_bij(int, int, double *, double *);
void get_bmatrix(double *B, int row_dim, int col_dim, double *adirissa,
                 double *weight) {
  int i, j;
  for (i = 0; i < row_dim; i++)
    for (j = 0; j < col_dim; j++)
      B[i * col_dim + j] = get_bij(i, j, adirissa, weight);
}


x86 assembly (clang, -O0):
<get_bmatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119a <get_bmatrix+0x8a>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1187 <get_bmatrix+0x77>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <get_bij@plt>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1144 <get_bmatrix+0x34>
jmp    118c <get_bmatrix+0x7c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1131 <get_bmatrix+0x21>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_bmatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0x4(%rsp)
test   %esi,%esi
jle    1191 <get_bmatrix+0x81>
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdi,%r13
movslq 0x4(%rsp),%rax
mov    %esi,%ecx
mov    %rcx,0x8(%rsp)
mov    %eax,%r15d
shl    $0x3,%rax
mov    %rax,0x10(%rsp)
xor    %ebx,%ebx
jmp    1160 <get_bmatrix+0x50>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
add    0x10(%rsp),%r13
cmp    0x8(%rsp),%rbx
je     1191 <get_bmatrix+0x81>
cmpl   $0x0,0x4(%rsp)
jle    1150 <get_bmatrix+0x40>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r12,%rdx
mov    %r14,%rcx
call   1030 <get_bij@plt>
movsd  %xmm0,0x0(%r13,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1170 <get_bmatrix+0x60>
jmp    1150 <get_bmatrix+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @get_bmatrix(double* %0, i32 %1, i32 %2, double* %3, double* %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
store double* %0, double** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double* %3, double** %9
store double* %4, double** %10
store i32 0, i32* %11
br label %13
13: ; preds = %40, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %7
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %43
17: ; preds = %13
store i32 0, i32* %12
br label %18
18: ; preds = %36, %17
%19 = load i32, i32* %12
%20 = load i32, i32* %8
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %39
22: ; preds = %18
%23 = load i32, i32* %11
%24 = load i32, i32* %12
%25 = load double*, double** %9
%26 = load double*, double** %10
%27 = call double @get_bij(i32 %23, i32 %24, double* %25, double* %26)
%28 = load double*, double** %6
%29 = load i32, i32* %11
%30 = load i32, i32* %8
%31 = mul nsw i32 %29, %30
%32 = load i32, i32* %12
%33 = add nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %28, i64 %34
store double %27, double* %35
br label %36
36: ; preds = %22
%37 = load i32, i32* %12
%38 = add nsw i32 %37, 1
store i32 %38, i32* %12
br label %18
39: ; preds = %18
br label %40
40: ; preds = %39
%41 = load i32, i32* %11
%42 = add nsw i32 %41, 1
store i32 %42, i32* %11
br label %13
43: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @get_bmatrix(double* nocapture writeonly %0, i32 %1, i32 %2, double* %3, double* %4) {
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %28
7: ; preds = %5
%8 = icmp sgt i32 %2, 0
%9 = sext i32 %2 to i64
%10 = zext i32 %1 to i64
%11 = zext i32 %2 to i64
br label %12
12: ; preds = %7, %25
%13 = phi i64 [ 0, %7 ], [ %26, %25 ]
br i1 %8, label %14, label %25
14: ; preds = %12
%15 = mul nsw i64 %13, %9
%16 = trunc i64 %13 to i32
br label %17
17: ; preds = %14, %17
%18 = phi i64 [ 0, %14 ], [ %23, %17 ]
%19 = trunc i64 %18 to i32
%20 = tail call double @get_bij(i32 %16, i32 %19, double* %3, double* %4)
%21 = add nsw i64 %18, %15
%22 = getelementptr inbounds double, double* %0, i64 %21
store double %20, double* %22
%23 = add nuw nsw i64 %18, 1
%24 = icmp eq i64 %23, %11
br i1 %24, label %25, label %17
25: ; preds = %17, %12
%26 = add nuw nsw i64 %13, 1
%27 = icmp eq i64 %26, %10
br i1 %27, label %28, label %12
28: ; preds = %25, %5
ret void
}