#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*/ FnMeanSigma_short(short *, long, int, short, long *,
                                     double *, double *, int *);
int /*<<< orphan*/ FnNoise1_short(short *, long, long, int, short, double *,
                                  int *);
int /*<<< orphan*/ FnNoise5_short(short *, long, long, int, short, long *,
                                  short *, short *, double *, double *,
                                  double *, int *);
int fits_img_stats_short(short *array, long nx, long ny, int nullcheck,
                         short nullvalue, long *ngoodpix, short *minvalue,
                         short *maxvalue, double *mean, double *sigma,
                         double *noise1, double *noise2, double *noise3,
                         double *noise5, int *status) {
  long ngood;
  short minval, maxval;
  double xmean = 0., xsigma = 0., xnoise = 0., xnoise2 = 0., xnoise3 = 0.,
         xnoise5 = 0.;
  if (mean || sigma) {
    FnMeanSigma_short(array, nx * ny, nullcheck, nullvalue, &ngood, &xmean,
                      &xsigma, status);
    if (ngoodpix)
      *ngoodpix = ngood;
    if (mean)
      *mean = xmean;
    if (sigma)
      *sigma = xsigma;
  }
  if (noise1) {
    FnNoise1_short(array, nx, ny, nullcheck, nullvalue, &xnoise, status);
    *noise1 = xnoise;
  }
  if (minvalue || maxvalue || noise3) {
    FnNoise5_short(array, nx, ny, nullcheck, nullvalue, &ngood, &minval,
                   &maxval, &xnoise2, &xnoise3, &xnoise5, status);
    if (ngoodpix)
      *ngoodpix = ngood;
    if (minvalue)
      *minvalue = minval;
    if (maxvalue)
      *maxvalue = maxval;
    if (noise2)
      *noise2 = xnoise2;
    if (noise3)
      *noise3 = xnoise3;
    if (noise5)
      *noise5 = xnoise5;
  }
  return (*status);
}


x86 assembly (clang, -O0):
<fits_img_stats_short>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    %r8w,%ax
mov    0x50(%rbp),%r8
mov    0x48(%rbp),%r8
mov    0x40(%rbp),%r8
mov    0x38(%rbp),%r8
mov    0x30(%rbp),%r8
mov    0x28(%rbp),%r8
mov    0x20(%rbp),%r8
mov    0x18(%rbp),%r8
mov    0x10(%rbp),%r8
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %ecx,-0x34(%rbp)
mov    %ax,-0x36(%rbp)
mov    %r9,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x78(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
cmpq   $0x0,0x20(%rbp)
jne    11c5 <fits_img_stats_short+0x95>
cmpq   $0x0,0x28(%rbp)
je     1245 <fits_img_stats_short+0x115>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
imul   -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
mov    -0x36(%rbp),%cx
mov    0x50(%rbp),%rax
lea    -0x48(%rbp),%r8
lea    -0x58(%rbp),%r9
lea    -0x60(%rbp),%r10
movswl %cx,%ecx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <FnMeanSigma_short@plt>
cmpq   $0x0,-0x40(%rbp)
je     1210 <fits_img_stats_short+0xe0>
mov    -0x48(%rbp),%rcx
mov    -0x40(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,0x20(%rbp)
je     1228 <fits_img_stats_short+0xf8>
movsd  -0x58(%rbp),%xmm0
mov    0x20(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,0x28(%rbp)
je     1240 <fits_img_stats_short+0x110>
movsd  -0x60(%rbp),%xmm0
mov    0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1245 <fits_img_stats_short+0x115>
cmpq   $0x0,0x30(%rbp)
je     1286 <fits_img_stats_short+0x156>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x36(%rbp),%r8w
mov    0x50(%rbp),%rax
lea    -0x68(%rbp),%r9
movswl %r8w,%r8d
mov    %rax,(%rsp)
call   1050 <FnNoise1_short@plt>
movsd  -0x68(%rbp),%xmm0
mov    0x30(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,0x10(%rbp)
jne    12a7 <fits_img_stats_short+0x177>
cmpq   $0x0,0x18(%rbp)
jne    12a7 <fits_img_stats_short+0x177>
cmpq   $0x0,0x40(%rbp)
je     138c <fits_img_stats_short+0x25c>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x36(%rbp),%r8w
mov    0x50(%rbp),%rax
lea    -0x48(%rbp),%r9
lea    -0x4a(%rbp),%r15
lea    -0x4c(%rbp),%r14
lea    -0x70(%rbp),%rbx
lea    -0x78(%rbp),%r11
lea    -0x80(%rbp),%r10
movswl %r8w,%r8d
mov    %r15,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1030 <FnNoise5_short@plt>
cmpq   $0x0,-0x40(%rbp)
je     1313 <fits_img_stats_short+0x1e3>
mov    -0x48(%rbp),%rcx
mov    -0x40(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,0x10(%rbp)
je     1329 <fits_img_stats_short+0x1f9>
mov    -0x4a(%rbp),%cx
mov    0x10(%rbp),%rax
mov    %cx,(%rax)
cmpq   $0x0,0x18(%rbp)
je     133f <fits_img_stats_short+0x20f>
mov    -0x4c(%rbp),%cx
mov    0x18(%rbp),%rax
mov    %cx,(%rax)
cmpq   $0x0,0x38(%rbp)
je     1357 <fits_img_stats_short+0x227>
movsd  -0x70(%rbp),%xmm0
mov    0x38(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,0x40(%rbp)
je     136f <fits_img_stats_short+0x23f>
movsd  -0x78(%rbp),%xmm0
mov    0x40(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,0x48(%rbp)
je     1387 <fits_img_stats_short+0x257>
movsd  -0x80(%rbp),%xmm0
mov    0x48(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    138c <fits_img_stats_short+0x25c>
mov    0x50(%rbp),%rax
mov    (%rax),%eax
add    $0x98,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<fits_img_stats_short>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,0x10(%rsp)
mov    %rdx,%rbp
mov    %rsi,%r13
mov    %rdi,%r15
mov    0x90(%rsp),%r14
movq   $0x0,0x40(%rsp)
movq   $0x0,0x38(%rsp)
movq   $0x0,0x30(%rsp)
movq   $0x0,0x28(%rsp)
movq   $0x0,0x20(%rsp)
movq   $0x0,0x18(%rsp)
mov    %r14,%rax
or     0x98(%rsp),%rax
movswl %r8w,%r12d
je     1207 <fits_img_stats_short+0xd7>
mov    %rbp,%rsi
imul   %r13,%rsi
lea    0x38(%rsp),%rax
lea    0x8(%rsp),%r8
lea    0x40(%rsp),%r9
mov    %r15,%rdi
mov    %ecx,%ebx
mov    %ecx,%edx
mov    %r12d,%ecx
push   0xc0(%rsp)
push   %rax
call   1040 <FnMeanSigma_short@plt>
add    $0x10,%rsp
mov    0x10(%rsp),%rcx
test   %rcx,%rcx
je     11de <fits_img_stats_short+0xae>
mov    0x8(%rsp),%rax
mov    %rax,(%rcx)
test   %r14,%r14
mov    0x98(%rsp),%rax
je     11f6 <fits_img_stats_short+0xc6>
movsd  0x40(%rsp),%xmm0
movsd  %xmm0,(%r14)
test   %rax,%rax
mov    %ebx,%ecx
je     1207 <fits_img_stats_short+0xd7>
movsd  0x38(%rsp),%xmm0
movsd  %xmm0,(%rax)
mov    0xa0(%rsp),%r14
test   %r14,%r14
je     124e <fits_img_stats_short+0x11e>
sub    $0x8,%rsp
lea    0x38(%rsp),%r9
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %rbp,%rbx
mov    %ecx,%ebp
mov    %r12d,%r8d
push   0xc8(%rsp)
call   1050 <FnNoise1_short@plt>
mov    %ebp,%ecx
mov    %rbx,%rbp
add    $0x10,%rsp
movsd  0x30(%rsp),%xmm0
movsd  %xmm0,(%r14)
mov    0x88(%rsp),%rbx
cmpq   $0x0,0x80(%rsp)
jne    1275 <fits_img_stats_short+0x145>
test   %rbx,%rbx
jne    1275 <fits_img_stats_short+0x145>
cmpq   $0x0,0xb0(%rsp)
je     1330 <fits_img_stats_short+0x200>
lea    0x18(%rsp),%rax
lea    0x20(%rsp),%r10
lea    0x28(%rsp),%r11
lea    0x4(%rsp),%r14
lea    0x8(%rsp),%r9
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %r12d,%r8d
push   0xc0(%rsp)
push   %rax
push   %r10
push   %r11
push   %r14
lea    0x2e(%rsp),%rax
push   %rax
call   1030 <FnNoise5_short@plt>
add    $0x30,%rsp
mov    0x10(%rsp),%rcx
test   %rcx,%rcx
je     12c9 <fits_img_stats_short+0x199>
mov    0x8(%rsp),%rax
mov    %rax,(%rcx)
mov    0x80(%rsp),%rcx
test   %rcx,%rcx
je     12de <fits_img_stats_short+0x1ae>
movzwl 0x6(%rsp),%eax
mov    %ax,(%rcx)
mov    0xa8(%rsp),%rax
test   %rbx,%rbx
je     12f3 <fits_img_stats_short+0x1c3>
movzwl 0x4(%rsp),%ecx
mov    %cx,(%rbx)
test   %rax,%rax
je     1302 <fits_img_stats_short+0x1d2>
movsd  0x28(%rsp),%xmm0
movsd  %xmm0,(%rax)
mov    0xb8(%rsp),%rax
mov    0xb0(%rsp),%rcx
test   %rcx,%rcx
je     1321 <fits_img_stats_short+0x1f1>
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%rcx)
test   %rax,%rax
je     1330 <fits_img_stats_short+0x200>
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rax)
mov    0xc0(%rsp),%rax
mov    (%rax),%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fits_img_stats_short(i16* %0, i64 %1, i64 %2, i32 %3, i16 signext %4, i64* %5, i16* %6, i16* %7, double* %8, double* %9, double* %10, double* %11, double* %12, double* %13, i32* %14) {
%16 = alloca i16*
%17 = alloca i64
%18 = alloca i64
%19 = alloca i32
%20 = alloca i16
%21 = alloca i64*
%22 = alloca i16*
%23 = alloca i16*
%24 = alloca double*
%25 = alloca double*
%26 = alloca double*
%27 = alloca double*
%28 = alloca double*
%29 = alloca double*
%30 = alloca i32*
%31 = alloca i64
%32 = alloca i16
%33 = alloca i16
%34 = alloca double
%35 = alloca double
%36 = alloca double
%37 = alloca double
%38 = alloca double
%39 = alloca double
store i16* %0, i16** %16
store i64 %1, i64* %17
store i64 %2, i64* %18
store i32 %3, i32* %19
store i16 %4, i16* %20
store i64* %5, i64** %21
store i16* %6, i16** %22
store i16* %7, i16** %23
store double* %8, double** %24
store double* %9, double** %25
store double* %10, double** %26
store double* %11, double** %27
store double* %12, double** %28
store double* %13, double** %29
store i32* %14, i32** %30
store double 0.000000e+00, double* %34
store double 0.000000e+00, double* %35
store double 0.000000e+00, double* %36
store double 0.000000e+00, double* %37
store double 0.000000e+00, double* %38
store double 0.000000e+00, double* %39
%40 = load double*, double** %24
%41 = icmp ne double* %40, null
br i1 %41, label %45, label %42
42: ; preds = %15
%43 = load double*, double** %25
%44 = icmp ne double* %43, null
br i1 %44, label %45, label %72
45: ; preds = %42, %15
%46 = load i16*, i16** %16
%47 = load i64, i64* %17
%48 = load i64, i64* %18
%49 = mul nsw i64 %47, %48
%50 = load i32, i32* %19
%51 = load i16, i16* %20
%52 = load i32*, i32** %30
%53 = call i32 @FnMeanSigma_short(i16* %46, i64 %49, i32 %50, i16 signext %51, i64* %31, double* %34, double* %35, i32* %52)
%54 = load i64*, i64** %21
%55 = icmp ne i64* %54, null
br i1 %55, label %56, label %59
56: ; preds = %45
%57 = load i64, i64* %31
%58 = load i64*, i64** %21
store i64 %57, i64* %58
br label %59
59: ; preds = %56, %45
%60 = load double*, double** %24
%61 = icmp ne double* %60, null
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = load double, double* %34
%64 = load double*, double** %24
store double %63, double* %64
br label %65
65: ; preds = %62, %59
%66 = load double*, double** %25
%67 = icmp ne double* %66, null
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = load double, double* %35
%70 = load double*, double** %25
store double %69, double* %70
br label %71
71: ; preds = %68, %65
br label %72
72: ; preds = %71, %42
%73 = load double*, double** %26
%74 = icmp ne double* %73, null
br i1 %74, label %75, label %85
75: ; preds = %72
%76 = load i16*, i16** %16
%77 = load i64, i64* %17
%78 = load i64, i64* %18
%79 = load i32, i32* %19
%80 = load i16, i16* %20
%81 = load i32*, i32** %30
%82 = call i32 @FnNoise1_short(i16* %76, i64 %77, i64 %78, i32 %79, i16 signext %80, double* %36, i32* %81)
%83 = load double, double* %36
%84 = load double*, double** %26
store double %83, double* %84
br label %85
85: ; preds = %75, %72
%86 = load i16*, i16** %22
%87 = icmp ne i16* %86, null
br i1 %87, label %94, label %88
88: ; preds = %85
%89 = load i16*, i16** %23
%90 = icmp ne i16* %89, null
br i1 %90, label %94, label %91
91: ; preds = %88
%92 = load double*, double** %28
%93 = icmp ne double* %92, null
br i1 %93, label %94, label %138
94: ; preds = %91, %88, %85
%95 = load i16*, i16** %16
%96 = load i64, i64* %17
%97 = load i64, i64* %18
%98 = load i32, i32* %19
%99 = load i16, i16* %20
%100 = load i32*, i32** %30
%101 = call i32 @FnNoise5_short(i16* %95, i64 %96, i64 %97, i32 %98, i16 signext %99, i64* %31, i16* %32, i16* %33, double* %37, double* %38, double* %39, i32* %100)
%102 = load i64*, i64** %21
%103 = icmp ne i64* %102, null
br i1 %103, label %104, label %107
104: ; preds = %94
%105 = load i64, i64* %31
%106 = load i64*, i64** %21
store i64 %105, i64* %106
br label %107
107: ; preds = %104, %94
%108 = load i16*, i16** %22
%109 = icmp ne i16* %108, null
br i1 %109, label %110, label %113
110: ; preds = %107
%111 = load i16, i16* %32
%112 = load i16*, i16** %22
store i16 %111, i16* %112
br label %113
113: ; preds = %110, %107
%114 = load i16*, i16** %23
%115 = icmp ne i16* %114, null
br i1 %115, label %116, label %119
116: ; preds = %113
%117 = load i16, i16* %33
%118 = load i16*, i16** %23
store i16 %117, i16* %118
br label %119
119: ; preds = %116, %113
%120 = load double*, double** %27
%121 = icmp ne double* %120, null
br i1 %121, label %122, label %125
122: ; preds = %119
%123 = load double, double* %37
%124 = load double*, double** %27
store double %123, double* %124
br label %125
125: ; preds = %122, %119
%126 = load double*, double** %28
%127 = icmp ne double* %126, null
br i1 %127, label %128, label %131
128: ; preds = %125
%129 = load double, double* %38
%130 = load double*, double** %28
store double %129, double* %130
br label %131
131: ; preds = %128, %125
%132 = load double*, double** %29
%133 = icmp ne double* %132, null
br i1 %133, label %134, label %137
134: ; preds = %131
%135 = load double, double* %39
%136 = load double*, double** %29
store double %135, double* %136
br label %137
137: ; preds = %134, %131
br label %138
138: ; preds = %137, %91
%139 = load i32*, i32** %30
%140 = load i32, i32* %139
ret i32 %140
}

LLVM IR (-O2):
define i32 @fits_img_stats_short(i16* %0, i64 %1, i64 %2, i32 %3, i16 signext %4, i64* writeonly %5, i16* writeonly %6, i16* writeonly %7, double* writeonly %8, double* writeonly %9, double* writeonly %10, double* writeonly %11, double* writeonly %12, double* writeonly %13, i32* %14) {
%16 = alloca i64
%17 = alloca i16
%18 = alloca i16
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = bitcast i64* %16 to i8*
%26 = bitcast i16* %17 to i8*
%27 = bitcast i16* %18 to i8*
%28 = bitcast double* %19 to i8*
store double 0.000000e+00, double* %19
%29 = bitcast double* %20 to i8*
store double 0.000000e+00, double* %20
%30 = bitcast double* %21 to i8*
store double 0.000000e+00, double* %21
%31 = bitcast double* %22 to i8*
store double 0.000000e+00, double* %22
%32 = bitcast double* %23 to i8*
store double 0.000000e+00, double* %23
%33 = bitcast double* %24 to i8*
store double 0.000000e+00, double* %24
%34 = icmp ne double* %8, null
%35 = icmp ne double* %9, null
%36 = or i1 %34, %35
br i1 %36, label %37, label %49
37: ; preds = %15
%38 = mul nsw i64 %2, %1
%39 = call i32 @FnMeanSigma_short(i16* %0, i64 %38, i32 %3, i16 signext %4, i64* %16, double* %19, double* %20, i32* %14)
%40 = icmp eq i64* %5, null
br i1 %40, label %43, label %41
41: ; preds = %37
%42 = load i64, i64* %16
store i64 %42, i64* %5
br label %43
43: ; preds = %41, %37
br i1 %34, label %44, label %46
44: ; preds = %43
%45 = load double, double* %19
store double %45, double* %8
br label %46
46: ; preds = %44, %43
br i1 %35, label %47, label %49
47: ; preds = %46
%48 = load double, double* %20
store double %48, double* %9
br label %49
49: ; preds = %46, %47, %15
%50 = icmp eq double* %10, null
br i1 %50, label %54, label %51
51: ; preds = %49
%52 = call i32 @FnNoise1_short(i16* %0, i64 %1, i64 %2, i32 %3, i16 signext %4, double* %21, i32* %14)
%53 = load double, double* %21
store double %53, double* %10
br label %54
54: ; preds = %51, %49
%55 = icmp ne i16* %6, null
%56 = icmp ne i16* %7, null
%57 = or i1 %55, %56
%58 = icmp ne double* %12, null
%59 = or i1 %57, %58
br i1 %59, label %60, label %82
60: ; preds = %54
%61 = call i32 @FnNoise5_short(i16* %0, i64 %1, i64 %2, i32 %3, i16 signext %4, i64* %16, i16* %17, i16* %18, double* %22, double* %23, double* %24, i32* %14)
%62 = icmp eq i64* %5, null
br i1 %62, label %65, label %63
63: ; preds = %60
%64 = load i64, i64* %16
store i64 %64, i64* %5
br label %65
65: ; preds = %63, %60
br i1 %55, label %66, label %68
66: ; preds = %65
%67 = load i16, i16* %17
store i16 %67, i16* %6
br label %68
68: ; preds = %66, %65
br i1 %56, label %69, label %71
69: ; preds = %68
%70 = load i16, i16* %18
store i16 %70, i16* %7
br label %71
71: ; preds = %69, %68
%72 = icmp eq double* %11, null
br i1 %72, label %75, label %73
73: ; preds = %71
%74 = load double, double* %22
store double %74, double* %11
br label %75
75: ; preds = %73, %71
br i1 %58, label %76, label %78
76: ; preds = %75
%77 = load double, double* %23
store double %77, double* %12
br label %78
78: ; preds = %76, %75
%79 = icmp eq double* %13, null
br i1 %79, label %82, label %80
80: ; preds = %78
%81 = load double, double* %24
store double %81, double* %13
br label %82
82: ; preds = %78, %80, %54
%83 = load i32, i32* %14
ret i32 %83
}