#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*/ assert(int /*<<< orphan*/);
double **createVars(int, int);
int /*<<< orphan*/ destroyVars(double **);
int /*<<< orphan*/ equals(double, double, double);
int /*<<< orphan*/ readNcFile(char *, double **, int, int);
int /*<<< orphan*/ submitCdoCommand(char *);
int /*<<< orphan*/ writeNcFile(char *, double const *, int);
void testWct() {
  const double array1[] = {-3.1102};
  const double array2[] = {1.9787};
  int nvars = 1;
  int nts = 1;
  double **vars = createVars(nvars, nts);
  writeNcFile("in1.nc", array1, 1);
  writeNcFile("in2.nc", array2, 1);
  submitCdoCommand("wct in1.nc in2.nc out.nc");
  readNcFile("out.nc", vars, nvars, nts);
  assert(equals(vars[0][0], -6.34597, 1.0e-5));
  destroyVars(vars);
}


x86 assembly (clang, -O0):
<testWct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xe91(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0xe8e(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <createVars@plt>
mov    %rax,-0x20(%rbp)
lea    -0x8(%rbp),%rsi
lea    0xe6a(%rip),%rdi
mov    $0x1,%edx
call   1070 <writeNcFile@plt>
lea    -0x10(%rbp),%rsi
lea    0xe5c(%rip),%rdi
mov    $0x1,%edx
call   1070 <writeNcFile@plt>
lea    0xe52(%rip),%rdi
call   1060 <submitCdoCommand@plt>
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe4e(%rip),%rdi
call   1080 <readNcFile@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movsd  (%rax),%xmm0
movsd  0xdf6(%rip),%xmm1
movsd  0xdf6(%rip),%xmm2
call   1090 <equals@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    -0x20(%rbp),%rdi
call   1040 <destroyVars@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testWct>:
push   %rbx
sub    $0x10,%rsp
movabs $0xc008e1b089a02752,%rax
e1 08 c0
mov    %rax,0x8(%rsp)
movabs $0x3fffa8c154c985f0,%rax
a8 ff 3f
mov    %rax,(%rsp)
mov    $0x1,%edi
mov    $0x1,%esi
call   1030 <createVars@plt>
mov    %rax,%rbx
lea    0xe65(%rip),%rdi
lea    0x8(%rsp),%rsi
mov    $0x1,%edx
call   1070 <writeNcFile@plt>
lea    0xe56(%rip),%rdi
mov    %rsp,%rsi
mov    $0x1,%edx
call   1070 <writeNcFile@plt>
lea    0xe49(%rip),%rdi
call   1060 <submitCdoCommand@plt>
lea    0xe4f(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1080 <readNcFile@plt>
mov    (%rbx),%rax
movsd  (%rax),%xmm0
movsd  0xdfe(%rip),%xmm1
movsd  0xdfe(%rip),%xmm2
call   1090 <equals@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1040 <destroyVars@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.testWct.array1 = [1 x double] [double -3.110200e+00]
@__const.testWct.array2 = [1 x double] [double 1.978700e+00]
@.str = [7 x i8] c"in1.nc\00"
@.str.1 = [7 x i8] c"in2.nc\00"
@.str.2 = [25 x i8] c"wct in1.nc in2.nc out.nc\00"
@.str.3 = [7 x i8] c"out.nc\00"
define void @testWct() {
%1 = alloca [1 x double]
%2 = alloca [1 x double]
%3 = alloca i32
%4 = alloca i32
%5 = alloca double**
%6 = bitcast [1 x double]* %1 to i8*
%7 = bitcast [1 x double]* %2 to i8*
store i32 1, i32* %3
store i32 1, i32* %4
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call double** @createVars(i32 %8, i32 %9)
store double** %10, double*** %5
%11 = getelementptr inbounds [1 x double], [1 x double]* %1, i64 0, i64 0
%12 = call i32 @writeNcFile(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double* %11, i32 1)
%13 = getelementptr inbounds [1 x double], [1 x double]* %2, i64 0, i64 0
%14 = call i32 @writeNcFile(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double* %13, i32 1)
%15 = call i32 @submitCdoCommand(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%16 = load double**, double*** %5
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = call i32 @readNcFile(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double** %16, i32 %17, i32 %18)
%20 = load double**, double*** %5
%21 = getelementptr inbounds double*, double** %20, i64 0
%22 = load double*, double** %21
%23 = getelementptr inbounds double, double* %22, i64 0
%24 = load double, double* %23
%25 = call i32 @equals(double %24, double -6.345970e+00, double 1.000000e-05)
%26 = call i32 @assert(i32 %25)
%27 = load double**, double*** %5
%28 = call i32 @destroyVars(double** %27)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"in1.nc\00"
@.str.1 = [7 x i8] c"in2.nc\00"
@.str.2 = [25 x i8] c"wct in1.nc in2.nc out.nc\00"
@.str.3 = [7 x i8] c"out.nc\00"
define void @testWct() {
%1 = alloca [1 x double]
%2 = alloca [1 x double]
%3 = bitcast [1 x double]* %1 to i8*
%4 = bitcast [1 x double]* %1 to i64*
store i64 -4609186070274234542, i64* %4
%5 = bitcast [1 x double]* %2 to i8*
%6 = bitcast [1 x double]* %2 to i64*
store i64 4611590091755324912, i64* %6
%7 = tail call double** @createVars(i32 1, i32 1)
%8 = getelementptr inbounds [1 x double], [1 x double]* %1, i64 0, i64 0
%9 = call i32 @writeNcFile(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double* %8, i32 1)
%10 = getelementptr inbounds [1 x double], [1 x double]* %2, i64 0, i64 0
%11 = call i32 @writeNcFile(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double* %10, i32 1)
%12 = call i32 @submitCdoCommand(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @readNcFile(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double** %7, i32 1, i32 1)
%14 = load double*, double** %7
%15 = load double, double* %14
%16 = call i32 @equals(double %15, double -6.345970e+00, double 1.000000e-05)
%17 = call i32 @assert(i32 %16)
%18 = call i32 @destroyVars(double** %7)
ret void
}