#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*/ PRNT(char *, char *);
int sprintf(char *, char *, ...);
void printVec(const double *A, const int n, const char *nm) {
  int i, nc, ns = 255 - 20;
  char s[256], *ps;
  ps = &s[0];
  nc = sprintf(ps, "%s= [%g", nm, A[0]);
  ns -= nc;
  ps += nc;
  for (i = 1; i < n && ns > 0; i++) {
    nc = sprintf(ps, ", %g", A[i]);
    ns -= nc;
    ps += nc;
  }
  if (ns > 0)
    sprintf(ps, "]");
  PRNT("%s\n", s);
}


x86 assembly (clang, -O0):
<printVec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0xeb,-0x24(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x138(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xe9b(%rip),%rsi
mov    $0x1,%al
call   1040 <sprintf@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x138(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x138(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x139(%rbp)
jge    11b9 <printVec+0x99>
cmpl   $0x0,-0x24(%rbp)
setg   %al
mov    %al,-0x139(%rbp)
mov    -0x139(%rbp),%al
test   $0x1,%al
jne    11cc <printVec+0xac>
jmp    1221 <printVec+0x101>
mov    -0x138(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe21(%rip),%rsi
mov    $0x1,%al
call   1040 <sprintf@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x138(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x138(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1198 <printVec+0x78>
cmpl   $0x0,-0x24(%rbp)
jle    1240 <printVec+0x120>
mov    -0x138(%rbp),%rdi
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x130(%rbp),%rsi
lea    0xdc1(%rip),%rdi
call   1030 <PRNT@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printVec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %esi,%r15d
mov    %rdi,%r14
movsd  (%rdi),%xmm0
lea    0xebe(%rip),%rsi
mov    %rsp,%rdi
mov    $0x1,%al
call   1040 <sprintf@plt>
movslq %eax,%rcx
lea    (%rsp,%rcx,1),%r13
cmp    $0xeb,%ecx
setl   %cl
cmp    $0x2,%r15d
jl     11ab <printVec+0x8b>
cmp    $0xea,%eax
jg     11ab <printVec+0x8b>
mov    $0xeb,%ebp
sub    %eax,%ebp
mov    %r15d,%r12d
mov    $0x2,%ebx
lea    0xe89(%rip),%r15
nop
movsd  -0x8(%r14,%rbx,8),%xmm0
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1040 <sprintf@plt>
cltq
add    %rax,%r13
sub    %eax,%ebp
setg   %cl
cmp    %r12,%rbx
jae    11ab <printVec+0x8b>
add    $0x1,%rbx
test   %ebp,%ebp
jg     1180 <printVec+0x60>
test   %cl,%cl
je     11b6 <printVec+0x96>
movw   $0x5d,0x0(%r13)
lea    0xe50(%rip),%rdi
mov    %rsp,%rsi
call   1030 <PRNT@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%s= [%g\00"
@.str.1 = [5 x i8] c", %g\00"
@.str.2 = [2 x i8] c"]\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define void @printVec(double* %0, i32 %1, i8* %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [256 x i8]
%11 = alloca i8*
store double* %0, double** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 235, i32* %9
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
store i8* %12, i8** %11
%13 = load i8*, i8** %11
%14 = load i8*, i8** %6
%15 = load double*, double** %4
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %14, double %17)
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = load i32, i32* %9
%21 = sub nsw i32 %20, %19
store i32 %21, i32* %9
%22 = load i32, i32* %8
%23 = load i8*, i8** %11
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8* %25, i8** %11
store i32 1, i32* %7
br label %26
26: ; preds = %50, %3
%27 = load i32, i32* %7
%28 = load i32, i32* %5
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %9
%32 = icmp sgt i32 %31, 0
br label %33
33: ; preds = %30, %26
%34 = phi i1 [ false, %26 ], [ %32, %30 ]
br i1 %34, label %35, label %53
35: ; preds = %33
%36 = load i8*, i8** %11
%37 = load double*, double** %4
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = call i32 (i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %41)
store i32 %42, i32* %8
%43 = load i32, i32* %8
%44 = load i32, i32* %9
%45 = sub nsw i32 %44, %43
store i32 %45, i32* %9
%46 = load i32, i32* %8
%47 = load i8*, i8** %11
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds i8, i8* %47, i64 %48
store i8* %49, i8** %11
br label %50
50: ; preds = %35
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %26
53: ; preds = %33
%54 = load i32, i32* %9
%55 = icmp sgt i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = load i8*, i8** %11
%58 = call i32 (i8*, i8*, ...) @sprintf(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %59
59: ; preds = %56, %53
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%61 = call i32 @PRNT(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %60)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%s= [%g\00"
@.str.1 = [5 x i8] c", %g\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define void @printVec(double* nocapture %0, i32 %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = load double, double* %0
%7 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %2, double %6)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %8
%10 = icmp sgt i32 %1, 1
%11 = icmp slt i32 %7, 235
%12 = and i1 %10, %11
br i1 %12, label %13, label %30
13: ; preds = %3
%14 = sub nsw i32 235, %7
%15 = zext i32 %1 to i64
br label %16
16: ; preds = %13, %16
%17 = phi i64 [ 1, %13 ], [ %26, %16 ]
%18 = phi i8* [ %9, %13 ], [ %25, %16 ]
%19 = phi i32 [ %14, %13 ], [ %23, %16 ]
%20 = getelementptr inbounds double, double* %0, i64 %17
%21 = load double, double* %20
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %18, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %21)
%23 = sub nsw i32 %19, %22
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %18, i64 %24
%26 = add nuw nsw i64 %17, 1
%27 = icmp ult i64 %26, %15
%28 = icmp sgt i32 %23, 0
%29 = select i1 %27, i1 %28, i1 false
br i1 %29, label %16, label %30
30: ; preds = %16, %3
%31 = phi i8* [ %9, %3 ], [ %25, %16 ]
%32 = phi i1 [ %11, %3 ], [ %28, %16 ]
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = bitcast i8* %31 to i16*
store i16 93, i16* %34
br label %35
35: ; preds = %33, %30
%36 = call i32 @PRNT(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %5)
ret void
}