#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*/ isinf(double);
int /*<<< orphan*/ isnan(double);
void magcorr_sysrem(double *star_coeff, double *image_coeff, double **mag,
                    double **sig, int numlc, int numJD) {
  int j, k;
  for (j = 0; j < numlc; j++)
    for (k = 0; k < numJD; k++)
      if (!isnan(mag[j][k]) && !isinf(mag[j][k])) {
        mag[j][k] -= star_coeff[j] * image_coeff[k];
      }
}


x86 assembly (clang, -O0):
<magcorr_sysrem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1225 <magcorr_sysrem+0x105>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1212 <magcorr_sysrem+0xf2>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%eax
jne    11ff <magcorr_sysrem+0xdf>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <isinf@plt>
cmp    $0x0,%eax
jne    11ff <magcorr_sysrem+0xdf>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movq   %xmm0,%rdx
movabs $0x8000000000000000,%rsi
xor    %rsi,%rdx
movq   %rdx,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1204 <magcorr_sysrem+0xe4>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    115a <magcorr_sysrem+0x3a>
jmp    1217 <magcorr_sysrem+0xf7>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1147 <magcorr_sysrem+0x27>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<magcorr_sysrem>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0xc(%rsp)
test   %r8d,%r8d
jle    11d2 <magcorr_sysrem+0xb2>
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r13
mov    %r8d,%eax
mov    %rax,0x10(%rsp)
mov    0xc(%rsp),%ebp
xor    %r14d,%r14d
jmp    116b <magcorr_sysrem+0x4b>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    0x10(%rsp),%r14
je     11d2 <magcorr_sysrem+0xb2>
cmpl   $0x0,0xc(%rsp)
jle    1160 <magcorr_sysrem+0x40>
xor    %r12d,%r12d
jmp    1189 <magcorr_sysrem+0x69>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    %r12,%rbp
je     1160 <magcorr_sysrem+0x40>
mov    (%rbx,%r14,8),%rax
movsd  (%rax,%r12,8),%xmm0
call   1030 <isnan@plt>
test   %eax,%eax
jne    1180 <magcorr_sysrem+0x60>
mov    (%rbx,%r14,8),%rax
movsd  (%rax,%r12,8),%xmm0
call   1040 <isinf@plt>
test   %eax,%eax
jne    1180 <magcorr_sysrem+0x60>
movsd  0x0(%r13,%r14,8),%xmm0
mov    (%rbx,%r14,8),%rax
movsd  (%rax,%r12,8),%xmm1
mulsd  (%r15,%r12,8),%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rax,%r12,8)
jmp    1180 <magcorr_sysrem+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @magcorr_sysrem(double* %0, double* %1, double** %2, double** %3, i32 %4, i32 %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca double**
%10 = alloca double**
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store double* %0, double** %7
store double* %1, double** %8
store double** %2, double*** %9
store double** %3, double*** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
store i32 0, i32* %13
br label %15
15: ; preds = %75, %6
%16 = load i32, i32* %13
%17 = load i32, i32* %11
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %78
19: ; preds = %15
store i32 0, i32* %14
br label %20
20: ; preds = %71, %19
%21 = load i32, i32* %14
%22 = load i32, i32* %12
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %74
24: ; preds = %20
%25 = load double**, double*** %9
%26 = load i32, i32* %13
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double*, double** %25, i64 %27
%29 = load double*, double** %28
%30 = load i32, i32* %14
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = call i32 @isnan(double %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %70, label %36
36: ; preds = %24
%37 = load double**, double*** %9
%38 = load i32, i32* %13
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double*, double** %37, i64 %39
%41 = load double*, double** %40
%42 = load i32, i32* %14
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
%45 = load double, double* %44
%46 = call i32 @isinf(double %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %70, label %48
48: ; preds = %36
%49 = load double*, double** %7
%50 = load i32, i32* %13
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = load double*, double** %8
%55 = load i32, i32* %14
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %54, i64 %56
%58 = load double, double* %57
%59 = load double**, double*** %9
%60 = load i32, i32* %13
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double*, double** %59, i64 %61
%63 = load double*, double** %62
%64 = load i32, i32* %14
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = fneg double %53
%69 = call double @llvm.fmuladd.f64(double %68, double %58, double %67)
store double %69, double* %66
br label %70
70: ; preds = %48, %36, %24
br label %71
71: ; preds = %70
%72 = load i32, i32* %14
%73 = add nsw i32 %72, 1
store i32 %73, i32* %14
br label %20
74: ; preds = %20
br label %75
75: ; preds = %74
%76 = load i32, i32* %13
%77 = add nsw i32 %76, 1
store i32 %77, i32* %13
br label %15
78: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @magcorr_sysrem(double* nocapture %0, double* nocapture %1, double** nocapture %2, double** nocapture readnone %3, i32 %4, i32 %5) {
%7 = icmp sgt i32 %4, 0
br i1 %7, label %8, label %45
8: ; preds = %6
%9 = icmp sgt i32 %5, 0
%10 = zext i32 %4 to i64
%11 = zext i32 %5 to i64
br label %12
12: ; preds = %8, %42
%13 = phi i64 [ 0, %8 ], [ %43, %42 ]
br i1 %9, label %14, label %42
14: ; preds = %12
%15 = getelementptr inbounds double*, double** %2, i64 %13
%16 = getelementptr inbounds double, double* %0, i64 %13
br label %17
17: ; preds = %14, %39
%18 = phi i64 [ 0, %14 ], [ %40, %39 ]
%19 = load double*, double** %15
%20 = getelementptr inbounds double, double* %19, i64 %18
%21 = load double, double* %20
%22 = tail call i32 @isnan(double %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %39
24: ; preds = %17
%25 = load double*, double** %15
%26 = getelementptr inbounds double, double* %25, i64 %18
%27 = load double, double* %26
%28 = tail call i32 @isinf(double %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %39
30: ; preds = %24
%31 = load double, double* %16
%32 = getelementptr inbounds double, double* %1, i64 %18
%33 = load double, double* %32
%34 = load double*, double** %15
%35 = getelementptr inbounds double, double* %34, i64 %18
%36 = load double, double* %35
%37 = fneg double %31
%38 = tail call double @llvm.fmuladd.f64(double %37, double %33, double %36)
store double %38, double* %35
br label %39
39: ; preds = %17, %24, %30
%40 = add nuw nsw i64 %18, 1
%41 = icmp eq i64 %40, %11
br i1 %41, label %42, label %17
42: ; preds = %39, %12
%43 = add nuw nsw i64 %13, 1
%44 = icmp eq i64 %43, %10
br i1 %44, label %45, label %12
45: ; preds = %42, %6
ret void
}