#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
void printSBAStructureData(FILE *fp, double *motstruct, int ncams, int n3Dpts,
                           int cnp, int pnp) {
  register int i;
  motstruct += ncams * cnp;
  fputs("\n\nStructure parameters:\n", fp);
  for (i = 0; i < n3Dpts * pnp; ++i) {
    fprintf(fp, "%.10e ", motstruct[i]);
    if ((i + 1) % pnp == 0)
      fputc('\n', fp);
  }
}


x86 assembly (clang, -O0):
<printSBAStructureData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x14(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1030 <fputs@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%ecx
imul   -0x20(%rbp),%ecx
cmp    %ecx,%eax
jge    11e1 <printSBAStructureData+0xb1>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe71(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x20(%rbp)
cmp    $0x0,%edx
jne    11ce <printSBAStructureData+0x9e>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1040 <fputc@plt>
jmp    11d3 <printSBAStructureData+0xa3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117e <printSBAStructureData+0x4e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printSBAStructureData>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %ecx,%ebp
mov    %edx,%r13d
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0xead(%rip),%rdi
mov    $0x18,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
imul   %r14d,%ebp
test   %ebp,%ebp
jle    11c3 <printSBAStructureData+0x93>
imul   %r13d,%r15d
movslq %r15d,%rax
lea    (%r12,%rax,8),%r12
mov    %ebp,%r13d
xor    %ebp,%ebp
lea    0xe95(%rip),%r15
jmp    1195 <printSBAStructureData+0x65>
cs nopw 0x0(%rax,%rax,1)
cmp    %rbp,%r13
je     11c3 <printSBAStructureData+0x93>
movsd  (%r12,%rbp,8),%xmm0
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbp
mov    %ebp,%eax
cltd
idiv   %r14d
test   %edx,%edx
jne    1190 <printSBAStructureData+0x60>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
jmp    1190 <printSBAStructureData+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\0A\0AStructure parameters:\0A\00"
@.str.1 = [7 x i8] c"%.10e \00"
define void @printSBAStructureData(i32* %0, double* %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %7
store double* %1, double** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%14 = load i32, i32* %9
%15 = load i32, i32* %11
%16 = mul nsw i32 %14, %15
%17 = load double*, double** %8
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds double, double* %17, i64 %18
store double* %19, double** %8
%20 = load i32*, i32** %7
%21 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* %20)
store i32 0, i32* %13
br label %22
22: ; preds = %45, %6
%23 = load i32, i32* %13
%24 = load i32, i32* %10
%25 = load i32, i32* %12
%26 = mul nsw i32 %24, %25
%27 = icmp slt i32 %23, %26
br i1 %27, label %28, label %48
28: ; preds = %22
%29 = load i32*, i32** %7
%30 = load double*, double** %8
%31 = load i32, i32* %13
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = call i32 @fprintf(i32* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %34)
%36 = load i32, i32* %13
%37 = add nsw i32 %36, 1
%38 = load i32, i32* %12
%39 = srem i32 %37, %38
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %28
%42 = load i32*, i32** %7
%43 = call i32 @fputc(i8 signext 10, i32* %42)
br label %44
44: ; preds = %41, %28
br label %45
45: ; preds = %44
%46 = load i32, i32* %13
%47 = add nsw i32 %46, 1
store i32 %47, i32* %13
br label %22
48: ; preds = %22
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"\0A\0AStructure parameters:\0A\00"
@.str.1 = [7 x i8] c"%.10e \00"
define void @printSBAStructureData(i32* nocapture %0, double* nocapture %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = mul nsw i32 %4, %2
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds double, double* %1, i64 %8
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 24, i64 1, i32* %0)
%11 = mul i32 %5, %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %6
%14 = zext i32 %11 to i64
br label %15
15: ; preds = %13, %26
%16 = phi i64 [ 0, %13 ], [ %20, %26 ]
%17 = getelementptr inbounds double, double* %9, i64 %16
%18 = load double, double* %17
%19 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %18)
%20 = add nuw nsw i64 %16, 1
%21 = trunc i64 %20 to i32
%22 = srem i32 %21, %5
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %15
%25 = tail call i32 @fputc(i8 signext 10, i32* %0)
br label %26
26: ; preds = %15, %24
%27 = icmp eq i64 %20, %14
br i1 %27, label %28, label %15
28: ; preds = %26, %6
ret void
}