#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__ calloc(int, int);
int /*<<< orphan*/ dd_to_string(double const *, char *, int, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/, int,
                                char, int *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
void dd_write(const double *a, int precision) {
  char *s = (char *)calloc(precision + 10, sizeof(char));
  int s_end;
  dd_to_string(a, s, precision, 0, 0, 0, 1, ' ', &s_end);
  printf("%s", s);
  free(s);
}


x86 assembly (clang, -O0):
<dd_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0xa,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
xor    %r9d,%r9d
lea    -0x1c(%rbp),%rax
mov    %r9d,%ecx
mov    %r9d,%r8d
movl   $0x1,(%rsp)
movl   $0x20,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1060 <dd_to_string@plt>
mov    -0x18(%rbp),%rsi
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dd_write>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r15d
mov    %rdi,%r14
lea    0xa(%r15),%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
sub    $0x8,%rsp
lea    0x14(%rsp),%rax
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   %rax
push   $0x20
push   $0x1
call   1060 <dd_to_string@plt>
add    $0x20,%rsp
lea    0xe71(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @dd_write(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = add nsw i32 %7, 10
%9 = call i64 @calloc(i32 %8, i32 1)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %5
%11 = load double*, double** %3
%12 = load i8*, i8** %5
%13 = load i32, i32* %4
%14 = call i32 @dd_to_string(double* %11, i8* %12, i32 %13, i32 0, i32 0, i32 0, i32 1, i8 signext 32, i32* %6)
%15 = load i8*, i8** %5
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %5
%18 = call i32 @free(i8* %17)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @dd_write(double* %0, i32 %1) {
%3 = alloca i32
%4 = add nsw i32 %1, 10
%5 = tail call i64 @calloc(i32 %4, i32 1)
%6 = inttoptr i64 %5 to i8*
%7 = bitcast i32* %3 to i8*
%8 = call i32 @dd_to_string(double* %0, i8* %6, i32 %1, i32 0, i32 0, i32 0, i32 1, i8 signext 32, i32* %3)
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%10 = call i32 @free(i8* %6)
ret void
}