#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 DBL_DIG;
char get_length(double, int /*<<< orphan*/ *);
int /*<<< orphan*/ print_value(double, int, char, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
void print_xvector(double *x, int n) {
  char lena[16];
  int i, length;
  length = 0;
  for (i = 0; i < n; i++)
    if ((lena[i] = get_length(*(x + i), NULL)) > length)
      length = lena[i];
  if (length < DBL_DIG / 3)
    length = DBL_DIG / 3;
  else if (length < DBL_DIG)
    length += 2;
  for (i = 0; i < n; i++) {
    printf(" x[%u] = ", i + 1);
    print_value(*(x + i), length, lena[i], 0);
    putchar(';');
  }
}


x86 assembly (clang, -O0):
<print_xvector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b2 <print_xvector+0x72>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xor    %eax,%eax
mov    %eax,%edi
call   1060 <get_length@plt>
movslq -0x24(%rbp),%rcx
mov    %al,-0x20(%rbp,%rcx,1)
movsbl %al,%eax
cmp    -0x28(%rbp),%eax
jle    119f <print_xvector+0x5f>
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
mov    %eax,-0x28(%rbp)
jmp    11a4 <print_xvector+0x64>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115d <print_xvector+0x1d>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    11ef <print_xvector+0xaf>
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
jmp    120f <print_xvector+0xcf>
mov    -0x28(%rbp),%eax
mov    0x2def(%rip),%rcx
cmp    (%rcx),%eax
jge    120a <print_xvector+0xca>
mov    -0x28(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x28(%rbp)
jmp    120f <print_xvector+0xcf>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    126c <print_xvector+0x12c>
mov    -0x24(%rbp),%esi
add    $0x1,%esi
lea    0xdd1(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%edi
movslq -0x24(%rbp),%rax
xor    %edx,%edx
movsbl -0x20(%rbp,%rax,1),%esi
call   1040 <print_value@plt>
mov    $0x3b,%edi
call   1030 <putchar@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1216 <print_xvector+0xd6>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_xvector>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
mov    %rdi,%r15
mov    %esi,%r12d
test   %esi,%esi
jle    1183 <print_xvector+0x43>
xor    %ebp,%ebp
xor    %ebx,%ebx
nop
movsd  (%r15,%rbp,8),%xmm0
xor    %edi,%edi
call   1060 <get_length@plt>
mov    %al,(%rsp,%rbp,1)
movsbl %al,%eax
cmp    %eax,%ebx
cmovl  %eax,%ebx
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1160 <print_xvector+0x20>
jmp    1185 <print_xvector+0x45>
xor    %ebx,%ebx
mov    0x2e5c(%rip),%rax
movslq (%rax),%rax
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    0x2(%rbx),%r13d
cmp    %eax,%ebx
cmovge %ebx,%r13d
cmp    %ecx,%ebx
cmovl  %ecx,%r13d
test   %r14d,%r14d
jle    1204 <print_xvector+0xc4>
xor    %ebx,%ebx
lea    0xe3f(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%rbp
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
movsd  (%r15,%rbx,8),%xmm0
movsbl (%rsp,%rbx,1),%esi
mov    %r13d,%edi
xor    %edx,%edx
call   1040 <print_value@plt>
mov    $0x3b,%edi
call   1030 <putchar@plt>
mov    %rbp,%rbx
cmp    %rbp,%r12
jne    11d0 <print_xvector+0x90>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@DBL_DIG = global i32 0
@.str = [10 x i8] c" x[%u] = \00"
define void @print_xvector(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca [16 x i8]
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %7
store i32 0, i32* %6
br label %8
8: ; preds = %32, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %35
12: ; preds = %8
%13 = load double*, double** %3
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = call signext i8 @get_length(double %17, i32* null)
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %20
store i8 %18, i8* %21
%22 = sext i8 %18 to i32
%23 = load i32, i32* %7
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %31
25: ; preds = %12
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
store i32 %30, i32* %7
br label %31
31: ; preds = %25, %12
br label %32
32: ; preds = %31
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %8
35: ; preds = %8
%36 = load i32, i32* %7
%37 = load i32, i32* @DBL_DIG
%38 = sdiv i32 %37, 3
%39 = icmp slt i32 %36, %38
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load i32, i32* @DBL_DIG
%42 = sdiv i32 %41, 3
store i32 %42, i32* %7
br label %51
43: ; preds = %35
%44 = load i32, i32* %7
%45 = load i32, i32* @DBL_DIG
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 2
store i32 %49, i32* %7
br label %50
50: ; preds = %47, %43
br label %51
51: ; preds = %50, %40
store i32 0, i32* %6
br label %52
52: ; preds = %72, %51
%53 = load i32, i32* %6
%54 = load i32, i32* %4
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %75
56: ; preds = %52
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
%59 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %58)
%60 = load double*, double** %3
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
%64 = load double, double* %63
%65 = load i32, i32* %7
%66 = load i32, i32* %6
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %67
%69 = load i8, i8* %68
%70 = call i32 @print_value(double %64, i32 %65, i8 signext %69, i32 0)
%71 = call i32 @putchar(i8 signext 59)
br label %72
72: ; preds = %56
%73 = load i32, i32* %6
%74 = add nsw i32 %73, 1
store i32 %74, i32* %6
br label %52
75: ; preds = %52
ret void
}

LLVM IR (-O2):
@DBL_DIG = global i32 0
@.str = [10 x i8] c" x[%u] = \00"
define void @print_xvector(double* nocapture %0, i32 %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %20
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %18, %8 ]
%10 = phi i32 [ 0, %6 ], [ %17, %8 ]
%11 = getelementptr inbounds double, double* %0, i64 %9
%12 = load double, double* %11
%13 = tail call signext i8 @get_length(double %12, i32* null)
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %9
store i8 %13, i8* %14
%15 = sext i8 %13 to i32
%16 = icmp slt i32 %10, %15
%17 = select i1 %16, i32 %15, i32 %10
%18 = add nuw nsw i64 %9, 1
%19 = icmp eq i64 %18, %7
br i1 %19, label %20, label %8
20: ; preds = %8, %2
%21 = phi i32 [ 0, %2 ], [ %17, %8 ]
%22 = load i32, i32* @DBL_DIG
%23 = sdiv i32 %22, 3
%24 = icmp slt i32 %21, %23
%25 = icmp slt i32 %21, %22
%26 = add nsw i32 %21, 2
%27 = select i1 %25, i32 %26, i32 %21
%28 = select i1 %24, i32 %23, i32 %27
br i1 %5, label %29, label %43
29: ; preds = %20
%30 = zext i32 %1 to i64
br label %31
31: ; preds = %29, %31
%32 = phi i64 [ 0, %29 ], [ %33, %31 ]
%33 = add nuw nsw i64 %32, 1
%34 = trunc i64 %33 to i32
%35 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds double, double* %0, i64 %32
%37 = load double, double* %36
%38 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %32
%39 = load i8, i8* %38
%40 = tail call i32 @print_value(double %37, i32 %28, i8 signext %39, i32 0)
%41 = tail call i32 @putchar(i8 signext 59)
%42 = icmp eq i64 %33, %30
br i1 %42, label %43, label %31
43: ; preds = %31, %20
ret void
}