#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 *, ...);
void printcoords(double *coords, int dim) {
  int i, j;
  printf("*****\n");
  for (i = 0; i < dim; i++) {
    for (j = 0; j < 3; j++)
      printf("%e ", coords[i * 3 + j]);
    printf("\n");
  }
  return;
}


x86 assembly (clang, -O0):
<printcoords>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119c <printcoords+0x8c>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1180 <printcoords+0x70>
mov    -0x8(%rbp),%rax
imul   $0x3,-0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe9c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1147 <printcoords+0x37>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <printcoords+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printcoords>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xec1(%rip),%rdi
call   1040 <puts@plt>
test   %ebp,%ebp
jle    11a2 <printcoords+0x72>
mov    %ebp,%eax
shl    $0x3,%rax
lea    (%rax,%rax,2),%r15
xor    %ebp,%ebp
lea    0xea1(%rip),%r14
nop
movsd  (%rbx,%rbp,1),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rbx,%rbp,1),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x10(%rbx,%rbp,1),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x18,%rbp
cmp    %rbp,%r15
jne    1160 <printcoords+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"*****\0A\00"
@.str.1 = [4 x i8] c"%e \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @printcoords(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %8
8: ; preds = %31, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %34
12: ; preds = %8
store i32 0, i32* %6
br label %13
13: ; preds = %26, %12
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %29
16: ; preds = %13
%17 = load double*, double** %3
%18 = load i32, i32* %5
%19 = mul nsw i32 %18, 3
%20 = load i32, i32* %6
%21 = add nsw i32 %19, %20
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %17, i64 %22
%24 = load double, double* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %24)
br label %26
26: ; preds = %16
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %13
29: ; preds = %13
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %8
34: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%e \00"
@str = [6 x i8] c"*****\00"
define void @printcoords(double* nocapture %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %24
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %22, %7 ]
%9 = mul nuw nsw i64 %8, 3
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = load double, double* %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %11)
%13 = add nuw nsw i64 %9, 1
%14 = getelementptr inbounds double, double* %0, i64 %13
%15 = load double, double* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %15)
%17 = add nuw nsw i64 %9, 2
%18 = getelementptr inbounds double, double* %0, i64 %17
%19 = load double, double* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %19)
%21 = tail call i32 @putchar(i32 10)
%22 = add nuw nsw i64 %8, 1
%23 = icmp eq i64 %22, %6
br i1 %23, label %24, label %7
24: ; preds = %7, %2
ret void
}