#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 */
scalar_t__ ceil(double);
double fabs(double);
double log(double);
double pow(double, scalar_t__);
int /*<<< orphan*/ printf(char *, ...);
void write50(double *v, int n) {
  int cols = 15;
  double vmax = 0;
  int i;
  double vmaxscale;
  for (i = 0; i < n; ++i)
    if (fabs(v[i]) > vmax)
      vmax = v[i];
  vmaxscale = log(fabs(vmax)) / log(10.0);
  vmaxscale = pow(10.0, ceil(vmaxscale) - 1);
  if (vmaxscale != 1.0)
    printf("  %e x\n", vmaxscale);
  for (i = 0; i < n; ++i) {
    if (i > 0 && i % cols == 0)
      printf("\n");
    printf(" %10.5f", v[i] / vmaxscale);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<write50>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0xf,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b9 <write50+0x79>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe8b(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11a6 <write50+0x66>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11ab <write50+0x6b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1165 <write50+0x25>
movsd  -0x18(%rbp),%xmm0
movaps 0xe4b(%rip),%xmm1
pand   %xmm1,%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe2d(%rip),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <ceil@plt>
mov    %rax,%rdi
sub    $0x1,%rdi
movsd  0xdfe(%rip),%xmm0
call   1060 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xddf(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1236 <write50+0xf6>
jp     1236 <write50+0xf6>
jmp    1249 <write50+0x109>
movsd  -0x28(%rbp),%xmm0
lea    0xdde(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12b2 <write50+0x172>
cmpl   $0x0,-0x1c(%rbp)
jle    1284 <write50+0x144>
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1284 <write50+0x144>
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x28(%rbp),%xmm0
lea    0xd8b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1250 <write50+0x110>
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write50>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r13
mov    %esi,%r12d
test   %esi,%esi
jle    1183 <write50+0x33>
lea    -0x1(%r12),%rcx
mov    %r12d,%eax
and    $0x3,%eax
cmp    $0x3,%rcx
jae    118c <write50+0x3c>
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
jmp    1249 <write50+0xf9>
xorpd  %xmm0,%xmm0
jmp    129b <write50+0x14b>
mov    %r12d,%edx
and    $0xfffffffc,%edx
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
movapd 0xe60(%rip),%xmm0
movsd  0x0(%r13,%rcx,8),%xmm3
movsd  0x8(%r13,%rcx,8),%xmm4
movsd  0x10(%r13,%rcx,8),%xmm5
movsd  0x18(%r13,%rcx,8),%xmm2
movapd %xmm3,%xmm6
andpd  %xmm0,%xmm6
movapd %xmm1,%xmm7
cmpltsd %xmm6,%xmm7
andpd  %xmm7,%xmm3
andnpd %xmm1,%xmm7
orpd   %xmm3,%xmm7
movapd %xmm4,%xmm1
andpd  %xmm0,%xmm1
movapd %xmm7,%xmm3
cmpltsd %xmm1,%xmm3
movapd %xmm3,%xmm1
andnpd %xmm7,%xmm1
andpd  %xmm4,%xmm3
orpd   %xmm1,%xmm3
movapd %xmm5,%xmm1
andpd  %xmm0,%xmm1
movapd %xmm3,%xmm4
cmpltsd %xmm1,%xmm4
movapd %xmm4,%xmm1
andnpd %xmm3,%xmm1
andpd  %xmm5,%xmm4
orpd   %xmm1,%xmm4
movapd %xmm2,%xmm3
andpd  %xmm0,%xmm3
movapd %xmm4,%xmm1
cmpltsd %xmm3,%xmm1
movapd %xmm1,%xmm3
andnpd %xmm4,%xmm3
andpd  %xmm2,%xmm1
orpd   %xmm3,%xmm1
add    $0x4,%rcx
cmp    %rcx,%rdx
jne    11a0 <write50+0x50>
movapd %xmm1,%xmm0
test   %rax,%rax
je     129b <write50+0x14b>
lea    0x0(,%rcx,8),%rcx
add    %r13,%rcx
xor    %edx,%edx
movapd 0xd99(%rip),%xmm2
movapd %xmm1,%xmm0
nopl   0x0(%rax,%rax,1)
movsd  (%rcx,%rdx,8),%xmm3
movapd %xmm3,%xmm4
andpd  %xmm2,%xmm4
cmpltsd %xmm4,%xmm0
andpd  %xmm0,%xmm3
andnpd %xmm1,%xmm0
orpd   %xmm3,%xmm0
add    $0x1,%rdx
movapd %xmm0,%xmm1
cmp    %rdx,%rax
jne    1270 <write50+0x120>
andpd  0xd5d(%rip),%xmm0
call   1060 <log@plt>
divsd  0xd60(%rip),%xmm0
call   1040 <ceil@plt>
lea    -0x1(%rax),%rdi
movsd  0xd57(%rip),%xmm0
call   1070 <pow@plt>
movapd %xmm0,%xmm1
ucomisd 0xd4e(%rip),%xmm0
movsd  %xmm0,(%rsp)
jne    12db <write50+0x18b>
jnp    12f2 <write50+0x1a2>
lea    0xd46(%rip),%rdi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
movsd  (%rsp),%xmm1
test   %ebp,%ebp
jle    1368 <write50+0x218>
shl    $0x3,%r12
xor    %ebp,%ebp
lea    0xd2d(%rip),%r15
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    1339 <write50+0x1e9>
nopw   0x0(%rax,%rax,1)
movsd  0x0(%r13,%r14,1),%xmm0
divsd  %xmm1,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  (%rsp),%xmm1
add    $0x8,%r14
add    $0xffffffff,%ebx
add    $0x1,%ebp
cmp    %r14,%r12
je     1368 <write50+0x218>
test   %r14,%r14
je     1310 <write50+0x1c0>
mov    %ebp,%eax
mov    $0x88888889,%ecx
imul   %rcx,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,2),%eax
add    %ebx,%eax
jne    1310 <write50+0x1c0>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsd  (%rsp),%xmm1
jmp    1310 <write50+0x1c0>
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 = [8 x i8] c" %e x\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [8 x i8] c" %10.5f\00"
define void @write50(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
%8 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
store i32 15, i32* %5
store double 0.000000e+00, double* %6
store i32 0, i32* %7
br label %9
9: ; preds = %29, %2
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %32
13: ; preds = %9
%14 = load double*, double** %3
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
%19 = call double @llvm.fabs.f64(double %18)
%20 = load double, double* %6
%21 = fcmp ogt double %19, %20
br i1 %21, label %22, label %28
22: ; preds = %13
%23 = load double*, double** %3
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
store double %27, double* %6
br label %28
28: ; preds = %22, %13
br label %29
29: ; preds = %28
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %9
32: ; preds = %9
%33 = load double, double* %6
%34 = call double @llvm.fabs.f64(double %33)
%35 = call double @log(double %34)
%36 = call double @log(double 1.000000e+01)
%37 = fdiv double %35, %36
store double %37, double* %8
%38 = load double, double* %8
%39 = call i64 @ceil(double %38)
%40 = sub nsw i64 %39, 1
%41 = call double @pow(double 1.000000e+01, i64 %40)
store double %41, double* %8
%42 = load double, double* %8
%43 = fcmp une double %42, 1.000000e+00
br i1 %43, label %44, label %47
44: ; preds = %32
%45 = load double, double* %8
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %45)
br label %47
47: ; preds = %44, %32
store i32 0, i32* %7
br label %48
48: ; preds = %71, %47
%49 = load i32, i32* %7
%50 = load i32, i32* %4
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %74
52: ; preds = %48
%53 = load i32, i32* %7
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %62
55: ; preds = %52
%56 = load i32, i32* %7
%57 = load i32, i32* %5
%58 = srem i32 %56, %57
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %55
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %62
62: ; preds = %60, %55, %52
%63 = load double*, double** %3
%64 = load i32, i32* %7
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = load double, double* %8
%69 = fdiv double %67, %68
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %69)
br label %71
71: ; preds = %62
%72 = load i32, i32* %7
%73 = add nsw i32 %72, 1
store i32 %73, i32* %7
br label %48
74: ; preds = %48
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c" %e x\0A\00"
@.str.2 = [8 x i8] c" %10.5f\00"
define void @write50(double* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %58
4: ; preds = %2
%5 = zext i32 %1 to i64
%6 = add nsw i64 %5, -1
%7 = and i64 %5, 3
%8 = icmp ult i64 %6, 3
br i1 %8, label %41, label %9
9: ; preds = %4
%10 = and i64 %5, 4294967292
br label %11
11: ; preds = %11, %9
%12 = phi i64 [ 0, %9 ], [ %38, %11 ]
%13 = phi double [ 0.000000e+00, %9 ], [ %37, %11 ]
%14 = phi i64 [ 0, %9 ], [ %39, %11 ]
%15 = getelementptr inbounds double, double* %0, i64 %12
%16 = load double, double* %15
%17 = tail call double @llvm.fabs.f64(double %16)
%18 = fcmp ogt double %17, %13
%19 = select i1 %18, double %16, double %13
%20 = or i64 %12, 1
%21 = getelementptr inbounds double, double* %0, i64 %20
%22 = load double, double* %21
%23 = tail call double @llvm.fabs.f64(double %22)
%24 = fcmp ogt double %23, %19
%25 = select i1 %24, double %22, double %19
%26 = or i64 %12, 2
%27 = getelementptr inbounds double, double* %0, i64 %26
%28 = load double, double* %27
%29 = tail call double @llvm.fabs.f64(double %28)
%30 = fcmp ogt double %29, %25
%31 = select i1 %30, double %28, double %25
%32 = or i64 %12, 3
%33 = getelementptr inbounds double, double* %0, i64 %32
%34 = load double, double* %33
%35 = tail call double @llvm.fabs.f64(double %34)
%36 = fcmp ogt double %35, %31
%37 = select i1 %36, double %34, double %31
%38 = add nuw nsw i64 %12, 4
%39 = add i64 %14, 4
%40 = icmp eq i64 %39, %10
br i1 %40, label %41, label %11
41: ; preds = %11, %4
%42 = phi double [ undef, %4 ], [ %37, %11 ]
%43 = phi i64 [ 0, %4 ], [ %38, %11 ]
%44 = phi double [ 0.000000e+00, %4 ], [ %37, %11 ]
%45 = icmp eq i64 %7, 0
br i1 %45, label %58, label %46
46: ; preds = %41, %46
%47 = phi i64 [ %55, %46 ], [ %43, %41 ]
%48 = phi double [ %54, %46 ], [ %44, %41 ]
%49 = phi i64 [ %56, %46 ], [ 0, %41 ]
%50 = getelementptr inbounds double, double* %0, i64 %47
%51 = load double, double* %50
%52 = tail call double @llvm.fabs.f64(double %51)
%53 = fcmp ogt double %52, %48
%54 = select i1 %53, double %51, double %48
%55 = add nuw nsw i64 %47, 1
%56 = add i64 %49, 1
%57 = icmp eq i64 %56, %7
br i1 %57, label %58, label %46
58: ; preds = %41, %46, %2
%59 = phi double [ 0.000000e+00, %2 ], [ %42, %41 ], [ %54, %46 ]
%60 = tail call double @llvm.fabs.f64(double %59)
%61 = tail call double @log(double %60)
%62 = fdiv double %61, 0x40026BB1BBB55516
%63 = tail call i64 @ceil(double %62)
%64 = add nsw i64 %63, -1
%65 = tail call double @pow(double 1.000000e+01, i64 %64)
%66 = fcmp une double %65, 1.000000e+00
br i1 %66, label %67, label %69
67: ; preds = %58
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %65)
br label %69
69: ; preds = %67, %58
br i1 %3, label %70, label %88
70: ; preds = %69
%71 = zext i32 %1 to i64
br label %72
72: ; preds = %70, %81
%73 = phi i64 [ 0, %70 ], [ %86, %81 ]
%74 = icmp ne i64 %73, 0
%75 = trunc i64 %73 to i32
%76 = urem i32 %75, 15
%77 = icmp eq i32 %76, 0
%78 = and i1 %74, %77
br i1 %78, label %79, label %81
79: ; preds = %72
%80 = tail call i32 @putchar(i32 10)
br label %81
81: ; preds = %79, %72
%82 = getelementptr inbounds double, double* %0, i64 %73
%83 = load double, double* %82
%84 = fdiv double %83, %65
%85 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %84)
%86 = add nuw nsw i64 %73, 1
%87 = icmp eq i64 %86, %71
br i1 %87, label %88, label %72
88: ; preds = %81, %69
%89 = tail call i32 @putchar(i32 10)
ret void
}