#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 dbllist2str(int, double *, char *);
int itemcount(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ str2dbllist(int, char *, double *);
void test_dbllist2str(void) {
  int i, n, nbc;
  char s[80];
  printf("give the number of doubles : ");
  scanf("%d", &n);
  {
    double data[n];
    for (i = 0; i < n; i++) {
      printf("-> give element %d : ", i);
      scanf("%lf", &data[i]);
    }
    printf("The %d numbers : ", n);
    for (i = 0; i < n; i++)
      printf(" %.16le", data[i]);
    printf("\n");
    nbc = dbllist2str(n, data, s);
  }
  printf("The string : %s\n", s);
  {
    int ict = itemcount(s);
    double nbr[ict];
    int i;
    printf("number of items : %d\n", ict);
    str2dbllist(n, s, nbr);
    printf("the %d numbers :", ict);
    for (i = 0; i < ict; i++)
      printf(" %.16le", nbr[i]);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<test_dbllist2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x99(%rbp)
call   1030 <printf@plt>
mov    -0x99(%rbp),%al
lea    0xea2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x68(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1201 <test_dbllist2str+0xb1>
mov    -0x4(%rbp),%esi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x98(%rbp),%rsi
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11b6 <test_dbllist2str+0x66>
mov    -0x8(%rbp),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1251 <test_dbllist2str+0x101>
mov    -0x98(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe11(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1219 <test_dbllist2str+0xc9>
lea    0xe22(%rip),%rdi
xor    %eax,%eax
mov    %al,-0xb1(%rbp)
call   1030 <printf@plt>
mov    -0x98(%rbp),%rsi
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rdx
mov    %rdx,-0xb0(%rbp)
call   1070 <dbllist2str@plt>
mov    -0xb0(%rbp),%rsi
mov    %eax,%ecx
mov    -0xb1(%rbp),%al
mov    %ecx,-0xc(%rbp)
mov    -0x68(%rbp),%rcx
mov    %rcx,%rsp
lea    0xdb6(%rip),%rdi
call   1030 <printf@plt>
mov    -0xb0(%rbp),%rdi
call   1040 <itemcount@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x80(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x88(%rbp)
mov    -0x74(%rbp),%esi
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xa8(%rbp),%rdx
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rsi
call   1050 <str2dbllist@plt>
mov    -0x74(%rbp),%esi
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    1363 <test_dbllist2str+0x213>
mov    -0xa8(%rbp),%rax
movslq -0x8c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xd05(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    131f <test_dbllist2str+0x1cf>
lea    0xd10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x80(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_dbllist2str>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe98(%rip),%rdi
lea    -0x2c(%rbp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %rsp,%r15
mov    -0x2c(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x2c(%rbp),%esi
test   %esi,%esi
jle    11fe <test_dbllist2str+0x9e>
mov    %r15,-0x38(%rbp)
lea    0xe63(%rip),%r14
lea    0xe72(%rip),%r15
mov    %r12,%r13
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rsi
add    $0x8,%r13
cmp    %rsi,%rbx
jl     11d0 <test_dbllist2str+0x70>
mov    -0x38(%rbp),%r15
lea    0xe36(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    123d <test_dbllist2str+0xdd>
xor    %ebx,%ebx
lea    0xe32(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsd  (%r12,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     1220 <test_dbllist2str+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x2c(%rbp),%edi
lea    -0x90(%rbp),%r14
mov    %r12,%rsi
mov    %r14,%rdx
call   1080 <dbllist2str@plt>
mov    %r15,%rsp
lea    0xdef(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1050 <itemcount@plt>
mov    %eax,%r15d
mov    %rsp,-0x38(%rbp)
mov    %eax,%r13d
mov    %rsp,%r12
lea    0xf(,%r13,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
lea    0xdc8(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   1060 <str2dbllist@plt>
lea    0xdbf(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r15d,%r15d
jle    12f9 <test_dbllist2str+0x199>
xor    %ebx,%ebx
lea    0xd78(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r12,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    12e0 <test_dbllist2str+0x180>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x38(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"give the number of doubles : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"-> give element %d : \00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [18 x i8] c"The %d numbers : \00"
@.str.5 = [8 x i8] c" %.16le\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [17 x i8] c"The string : %s\0A\00"
@.str.8 = [22 x i8] c"number of items : %d\0A\00"
@.str.9 = [17 x i8] c"the %d numbers :\00"
define void @test_dbllist2str() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [80 x i8]
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %5
%16 = alloca double, i64 %14
store i64 %14, i64* %6
store i32 0, i32* %1
br label %17
17: ; preds = %28, %0
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i32, i32* %1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %16, i64 %25
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %26)
br label %28
28: ; preds = %21
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 1
store i32 %30, i32* %1
br label %17
31: ; preds = %17
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %32)
store i32 0, i32* %1
br label %34
34: ; preds = %44, %31
%35 = load i32, i32* %1
%36 = load i32, i32* %2
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %47
38: ; preds = %34
%39 = load i32, i32* %1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %16, i64 %40
%42 = load double, double* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %42)
br label %44
44: ; preds = %38
%45 = load i32, i32* %1
%46 = add nsw i32 %45, 1
store i32 %46, i32* %1
br label %34
47: ; preds = %34
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%49 = load i32, i32* %2
%50 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%51 = call i32 @dbllist2str(i32 %49, double* %16, i8* %50)
store i32 %51, i32* %3
%52 = load i8*, i8** %5
%53 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %53)
%55 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%56 = call i32 @itemcount(i8* %55)
store i32 %56, i32* %7
%57 = load i32, i32* %7
%58 = zext i32 %57 to i64
%59 = call i8* @llvm.stacksave()
store i8* %59, i8** %8
%60 = alloca double, i64 %58
store i64 %58, i64* %9
%61 = load i32, i32* %7
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %2
%64 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%65 = call i32 @str2dbllist(i32 %63, i8* %64, double* %60)
%66 = load i32, i32* %7
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %66)
store i32 0, i32* %10
br label %68
68: ; preds = %78, %47
%69 = load i32, i32* %10
%70 = load i32, i32* %7
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %81
72: ; preds = %68
%73 = load i32, i32* %10
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %60, i64 %74
%76 = load double, double* %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %76)
br label %78
78: ; preds = %72
%79 = load i32, i32* %10
%80 = add nsw i32 %79, 1
store i32 %80, i32* %10
br label %68
81: ; preds = %68
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%83 = load i8*, i8** %8
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"give the number of doubles : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"-> give element %d : \00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [18 x i8] c"The %d numbers : \00"
@.str.5 = [8 x i8] c" %.16le\00"
@.str.7 = [17 x i8] c"The string : %s\0A\00"
@.str.8 = [22 x i8] c"number of items : %d\0A\00"
@.str.9 = [17 x i8] c"the %d numbers :\00"
define void @test_dbllist2str() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = alloca double, i64 %8
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %0, %13
%14 = phi i64 [ %19, %13 ], [ 0, %0 ]
%15 = trunc i64 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds double, double* %10, i64 %14
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %17)
%19 = add nuw nsw i64 %14, 1
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %13, label %23
23: ; preds = %13, %0
%24 = phi i32 [ %11, %0 ], [ %20, %13 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %1
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %23, %28
%29 = phi i64 [ %33, %28 ], [ 0, %23 ]
%30 = getelementptr inbounds double, double* %10, i64 %29
%31 = load double, double* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %31)
%33 = add nuw nsw i64 %29, 1
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %28, label %37
37: ; preds = %28, %23
%38 = call i32 @putchar(i32 10)
%39 = load i32, i32* %1
%40 = call i32 @dbllist2str(i32 %39, double* %10, i8* %4)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %4)
%42 = call i32 @itemcount(i8* %4)
%43 = zext i32 %42 to i64
%44 = call i8* @llvm.stacksave()
%45 = alloca double, i64 %43
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %42)
%47 = load i32, i32* %1
%48 = call i32 @str2dbllist(i32 %47, i8* %4, double* %45)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %42)
%50 = icmp sgt i32 %42, 0
br i1 %50, label %51, label %58
51: ; preds = %37, %51
%52 = phi i64 [ %56, %51 ], [ 0, %37 ]
%53 = getelementptr inbounds double, double* %45, i64 %52
%54 = load double, double* %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %54)
%56 = add nuw nsw i64 %52, 1
%57 = icmp eq i64 %56, %43
br i1 %57, label %58, label %51
58: ; preds = %51, %37
%59 = call i32 @putchar(i32 10)
ret void
}