#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*/ memset(double *, double, int);
int setMatrixValue(double **x, unsigned long rows, unsigned long columns,
                   double value) {
  unsigned long i;
  for (i = 0; i < rows; i++) {
    memset(x[i], value, sizeof(double) * columns);
  }
  return 0;
}


x86 assembly (clang, -O0):
<setMatrixValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1170 <setMatrixValue+0x60>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1030 <memset@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1131 <setMatrixValue+0x21>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setMatrixValue>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     115a <setMatrixValue+0x4a>
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
shl    $0x3,%r14d
xor    %ebx,%ebx
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
movsd  (%rsp),%xmm0
mov    %r14d,%esi
call   1030 <memset@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <setMatrixValue+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @setMatrixValue(double** %0, i64 %1, i64 %2, double %3) {
%5 = alloca double**
%6 = alloca i64
%7 = alloca i64
%8 = alloca double
%9 = alloca i64
store double** %0, double*** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store double %3, double* %8
store i64 0, i64* %9
br label %10
10: ; preds = %24, %4
%11 = load i64, i64* %9
%12 = load i64, i64* %6
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load double**, double*** %5
%16 = load i64, i64* %9
%17 = getelementptr inbounds double*, double** %15, i64 %16
%18 = load double*, double** %17
%19 = load double, double* %8
%20 = load i64, i64* %7
%21 = mul i64 8, %20
%22 = trunc i64 %21 to i32
%23 = call i32 @memset(double* %18, double %19, i32 %22)
br label %24
24: ; preds = %14
%25 = load i64, i64* %9
%26 = add i64 %25, 1
store i64 %26, i64* %9
br label %10
27: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
define i32 @setMatrixValue(double** nocapture %0, i64 %1, i64 %2, double %3) {
%5 = icmp eq i64 %1, 0
br i1 %5, label %16, label %6
6: ; preds = %4
%7 = trunc i64 %2 to i32
%8 = shl i32 %7, 3
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %14, %9 ]
%11 = getelementptr inbounds double*, double** %0, i64 %10
%12 = load double*, double** %11
%13 = tail call i32 @memset(double* %12, double %3, i32 %8)
%14 = add nuw i64 %10, 1
%15 = icmp eq i64 %14, %1
br i1 %15, label %16, label %9
16: ; preds = %9, %4
ret i32 0
}