#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*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
void print_double(double *p, int n) {
  const int w = 8;
  int num_rows = (n + 7) / w;
  int reg_size = 4;
  int range = 10;
  int i = 0;
  while (i < n) {
    int j;
    printf("%04X(%5d):\t", i, i);
    for (j = 0; j < w && i < n; j++) {
      printf("%10.3f,", *p++);
      i++;
    }
    printf("\n");
  }
  puts("");
}


x86 assembly (clang, -O0):
<print_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x8,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x7,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
movl   $0x4,-0x18(%rbp)
movl   $0xa,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f9 <print_double+0xd9>
mov    -0x20(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
xor    %eax,%eax
cmpl   $0x8,-0x24(%rbp)
mov    %al,-0x25(%rbp)
jge    119e <print_double+0x7e>
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11ae <print_double+0x8e>
jmp    11e6 <print_double+0xc6>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
movsd  (%rax),%xmm0
lea    0xe44(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1183 <print_double+0x63>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    115c <print_double+0x3c>
lea    0xe0b(%rip),%rdi
call   1030 <puts@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_double>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11a8 <print_double+0x88>
mov    %esi,%r12d
mov    %rdi,%rbx
lea    0xec4(%rip),%r14
lea    0xec9(%rip),%r15
xor    %r13d,%r13d
jmp    1162 <print_double+0x42>
nopl   0x0(%rax,%rax,1)
add    %eax,%r13d
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r12d,%r13d
jge    11a8 <print_double+0x88>
mov    %r14,%rdi
mov    %r13d,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12d,%r13d
jge    1153 <print_double+0x33>
xor    %ebp,%ebp
nopl   0x0(%rax)
movsd  (%rbx),%xmm0
add    $0x8,%rbx
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0x1(%rbp),%eax
cmp    $0x6,%ebp
ja     1150 <print_double+0x30>
lea    0x1(%r13,%rbp,1),%ecx
mov    %eax,%ebp
cmp    %r12d,%ecx
jl     1180 <print_double+0x60>
jmp    1150 <print_double+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"%04X(%5d):\09\00"
@.str.1 = [8 x i8] c"%10.3f,\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [1 x i8] zeroinitializer
define void @print_double(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store i32 8, i32* %5
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 7
%13 = sdiv i32 %12, 8
store i32 %13, i32* %6
store i32 4, i32* %7
store i32 10, i32* %8
store i32 0, i32* %9
br label %14
14: ; preds = %41, %2
%15 = load i32, i32* %9
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %43
18: ; preds = %14
%19 = load i32, i32* %9
%20 = load i32, i32* %9
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %20)
store i32 0, i32* %10
br label %22
22: ; preds = %38, %18
%23 = load i32, i32* %10
%24 = icmp slt i32 %23, 8
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32, i32* %9
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br label %29
29: ; preds = %25, %22
%30 = phi i1 [ false, %22 ], [ %28, %25 ]
br i1 %30, label %31, label %41
31: ; preds = %29
%32 = load double*, double** %3
%33 = getelementptr inbounds double, double* %32, i32 1
store double* %33, double** %3
%34 = load double, double* %32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %34)
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %38
38: ; preds = %31
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
store i32 %40, i32* %10
br label %22
41: ; preds = %29
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %14
43: ; preds = %14
%44 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"%04X(%5d):\09\00"
@.str.1 = [8 x i8] c"%10.3f,\00"
define void @print_double(double* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %26
4: ; preds = %2, %21
%5 = phi i32 [ %23, %21 ], [ 0, %2 ]
%6 = phi double* [ %22, %21 ], [ %0, %2 ]
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %5)
%8 = icmp slt i32 %5, %1
br i1 %8, label %9, label %21
9: ; preds = %4, %9
%10 = phi i32 [ %17, %9 ], [ 0, %4 ]
%11 = phi i32 [ %16, %9 ], [ %5, %4 ]
%12 = phi double* [ %13, %9 ], [ %6, %4 ]
%13 = getelementptr inbounds double, double* %12, i64 1
%14 = load double, double* %12
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %14)
%16 = add nsw i32 %11, 1
%17 = add nuw nsw i32 %10, 1
%18 = icmp ult i32 %10, 7
%19 = icmp slt i32 %16, %1
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %9, label %21
21: ; preds = %9, %4
%22 = phi double* [ %6, %4 ], [ %13, %9 ]
%23 = phi i32 [ %5, %4 ], [ %16, %9 ]
%24 = tail call i32 @putchar(i32 10)
%25 = icmp slt i32 %23, %1
br i1 %25, label %4, label %26
26: ; preds = %21, %2
%27 = tail call i32 @putchar(i32 10)
ret void
}