#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*/ pstreamDefRecord(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ pstreamWriteRecord(int, double *, int);
void write_data(int streamID, int nvars, double *data[], int *nmiss) {
  int varID;
  for (varID = 0; varID < nvars; ++varID) {
    pstreamDefRecord(streamID, varID, 0);
    pstreamWriteRecord(streamID, data[varID], nmiss[varID]);
  }
}


x86 assembly (clang, -O0):
<write_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1183 <write_data+0x63>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
xor    %edx,%edx
call   1030 <pstreamDefRecord@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
call   1040 <pstreamWriteRecord@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113d <write_data+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_data>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    1163 <write_data+0x43>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %edi,%ebp
mov    %esi,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %ebx,%esi
xor    %edx,%edx
call   1030 <pstreamDefRecord@plt>
mov    (%r15,%rbx,8),%rsi
mov    (%r14,%rbx,4),%edx
mov    %ebp,%edi
call   1040 <pstreamWriteRecord@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <write_data+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @write_data(i32 %0, i32 %1, double** %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double**
%8 = alloca i32*
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store double** %2, double*** %7
store i32* %3, i32** %8
store i32 0, i32* %9
br label %10
10: ; preds = %30, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %33
14: ; preds = %10
%15 = load i32, i32* %5
%16 = load i32, i32* %9
%17 = call i32 @pstreamDefRecord(i32 %15, i32 %16, i32 0)
%18 = load i32, i32* %5
%19 = load double**, double*** %7
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double*, double** %19, i64 %21
%23 = load double*, double** %22
%24 = load i32*, i32** %8
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = call i32 @pstreamWriteRecord(i32 %18, double* %23, i32 %28)
br label %30
30: ; preds = %14
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 1
store i32 %32, i32* %9
br label %10
33: ; preds = %10
ret void
}

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