#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 */
scalar_t__ malloc(int);
double **assign_null_reactions(double **s_locked, double *lock_v, int n_null,
                               int n_locked) {
  double **s_null = (double **)malloc(n_null * sizeof(double *)), **dummy_s,
         **dummy_s_null, *dummy_v;
  dummy_s = s_locked;
  dummy_s_null = s_null;
  for (dummy_v = lock_v; dummy_v < lock_v + n_locked; dummy_v++) {
    if (*dummy_v == 0.) {
      *dummy_s_null = *dummy_s;
      dummy_s_null++;
    }
    dummy_s++;
  }
  return s_null;
}


x86 assembly (clang, -O0):
<assign_null_reactions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
shl    $0x3,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    11bf <assign_null_reactions+0xaf>
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a2 <assign_null_reactions+0x92>
jp     11a2 <assign_null_reactions+0x92>
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
jmp    1151 <assign_null_reactions+0x41>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assign_null_reactions>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x0(,%rdx,8),%edi
call   1030 <malloc@plt>
test   %ebp,%ebp
jle    1165 <assign_null_reactions+0x55>
movslq %ebp,%rcx
lea    (%rbx,%rcx,8),%rcx
xorpd  %xmm0,%xmm0
mov    %rax,%rdx
jmp    114d <assign_null_reactions+0x3d>
nopl   0x0(%rax)
add    $0x8,%r14
add    $0x8,%rbx
cmp    %rcx,%rbx
jae    1165 <assign_null_reactions+0x55>
movsd  (%rbx),%xmm1
ucomisd %xmm0,%xmm1
jne    1140 <assign_null_reactions+0x30>
jp     1140 <assign_null_reactions+0x30>
mov    (%r14),%rsi
mov    %rsi,(%rdx)
add    $0x8,%rdx
jmp    1140 <assign_null_reactions+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double** @assign_null_reactions(double** %0, double* %1, i32 %2, i32 %3) {
%5 = alloca double**
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double**
%10 = alloca double**
%11 = alloca double**
%12 = alloca double*
store double** %0, double*** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 8
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to double**
store double** %18, double*** %9
%19 = load double**, double*** %5
store double** %19, double*** %10
%20 = load double**, double*** %9
store double** %20, double*** %11
%21 = load double*, double** %6
store double* %21, double** %12
br label %22
22: ; preds = %42, %4
%23 = load double*, double** %12
%24 = load double*, double** %6
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = icmp ult double* %23, %27
br i1 %28, label %29, label %45
29: ; preds = %22
%30 = load double*, double** %12
%31 = load double, double* %30
%32 = fcmp oeq double %31, 0.000000e+00
br i1 %32, label %33, label %39
33: ; preds = %29
%34 = load double**, double*** %10
%35 = load double*, double** %34
%36 = load double**, double*** %11
store double* %35, double** %36
%37 = load double**, double*** %11
%38 = getelementptr inbounds double*, double** %37, i32 1
store double** %38, double*** %11
br label %39
39: ; preds = %33, %29
%40 = load double**, double*** %10
%41 = getelementptr inbounds double*, double** %40, i32 1
store double** %41, double*** %10
br label %42
42: ; preds = %39
%43 = load double*, double** %12
%44 = getelementptr inbounds double, double* %43, i32 1
store double* %44, double** %12
br label %22
45: ; preds = %22
%46 = load double**, double*** %9
ret double** %46
}

LLVM IR (-O2):
define double** @assign_null_reactions(double** nocapture %0, double* %1, i32 %2, i32 %3) {
%5 = shl i32 %2, 3
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to double**
%8 = sext i32 %3 to i64
%9 = getelementptr inbounds double, double* %1, i64 %8
%10 = icmp sgt i32 %3, 0
br i1 %10, label %11, label %25
11: ; preds = %4, %20
%12 = phi double* [ %23, %20 ], [ %1, %4 ]
%13 = phi double** [ %21, %20 ], [ %7, %4 ]
%14 = phi double** [ %22, %20 ], [ %0, %4 ]
%15 = load double, double* %12
%16 = fcmp oeq double %15, 0.000000e+00
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load double*, double** %14
store double* %18, double** %13
%19 = getelementptr inbounds double*, double** %13, i64 1
br label %20
20: ; preds = %17, %11
%21 = phi double** [ %19, %17 ], [ %13, %11 ]
%22 = getelementptr inbounds double*, double** %14, i64 1
%23 = getelementptr inbounds double, double* %12, i64 1
%24 = icmp ult double* %23, %9
br i1 %24, label %11, label %25
25: ; preds = %20, %4
ret double** %7
}