#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 *, ...);
void blockWriteREAL(FILE *output, char *label, double *myvector, int first,
                    int last) {
  int i, k = 0;
  fprintf(output, "%s", label);
  fprintf(output, "\n");
  for (i = first; i <= last; i++) {
    fprintf(output, " %18g", myvector[i]);
    k++;
    if (k % 4 == 0) {
      fprintf(output, "\n");
      k = 0;
    }
  }
  if (k % 4 != 0)
    fprintf(output, "\n");
}


x86 assembly (clang, -O0):
<blockWriteREAL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xebf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11d4 <blockWriteREAL+0xc4>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe81(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c1 <blockWriteREAL+0xb1>
mov    -0x8(%rbp),%rdi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x28(%rbp)
jmp    11c6 <blockWriteREAL+0xb6>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1160 <blockWriteREAL+0x50>
mov    -0x28(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11fa <blockWriteREAL+0xea>
mov    -0x8(%rbp),%rdi
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blockWriteREAL>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%ebx
mov    %rdx,%r15
mov    %rdi,%r12
mov    %rsi,%rdi
mov    %r12,%rsi
call   1030 <fputs@plt>
mov    $0xa,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
cmp    %r14d,%ebx
jg     11d6 <blockWriteREAL+0xa6>
movslq %ebx,%rax
lea    (%r15,%rax,8),%r13
sub    %ebx,%r14d
add    $0x1,%r14d
xor    %ebp,%ebp
lea    0xe86(%rip),%r15
xor    %ebx,%ebx
jmp    1189 <blockWriteREAL+0x59>
xchg   %ax,%ax
add    $0x1,%rbp
cmp    %ebp,%r14d
je     11b6 <blockWriteREAL+0x86>
movsd  0x0(%r13,%rbp,8),%xmm0
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
add    $0x1,%ebx
test   $0x3,%bl
jne    1180 <blockWriteREAL+0x50>
mov    $0xa,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
xor    %ebx,%ebx
jmp    1180 <blockWriteREAL+0x50>
test   $0x3,%bl
je     11d6 <blockWriteREAL+0xa6>
mov    $0xa,%edi
mov    %r12,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fputc@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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