#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*/ doubles_scalar_add(double *, double *, int, double,
                                      double *);
void doubles_2d_scalar_add(double **tdarr1, double **tdarr2, int rows, int cols,
                           double alpha, double **res_tdarr) {
  int i;
  for (i = 0; i < rows; i++)
    doubles_scalar_add(tdarr1[i], tdarr2[i], cols, alpha, res_tdarr[i]);
}


x86 assembly (clang, -O0):
<doubles_2d_scalar_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1181 <doubles_2d_scalar_add+0x71>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%edx
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
call   1030 <doubles_scalar_add@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1136 <doubles_2d_scalar_add+0x26>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubles_2d_scalar_add>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1163 <doubles_2d_scalar_add+0x53>
mov    %r8,%r14
mov    %ecx,%r15d
mov    %rsi,%r12
mov    %rdi,%r13
mov    %edx,%ebx
xor    %ebp,%ebp
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%r13,%rbp,8),%rdi
mov    (%r12,%rbp,8),%rsi
mov    (%r14,%rbp,8),%rcx
mov    %r15d,%edx
movsd  (%rsp),%xmm0
call   1030 <doubles_scalar_add@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1140 <doubles_2d_scalar_add+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @doubles_2d_scalar_add(double** nocapture %0, double** nocapture %1, i32 %2, i32 %3, double %4, double** nocapture %5) {
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %21
8: ; preds = %6
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %19, %10 ]
%12 = getelementptr inbounds double*, double** %0, i64 %11
%13 = load double*, double** %12
%14 = getelementptr inbounds double*, double** %1, i64 %11
%15 = load double*, double** %14
%16 = getelementptr inbounds double*, double** %5, i64 %11
%17 = load double*, double** %16
%18 = tail call i32 @doubles_scalar_add(double* %13, double* %15, i32 %3, double %4, double* %17)
%19 = add nuw nsw i64 %11, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %21, label %10
21: ; preds = %10, %6
ret void
}