#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*/ Haar_wavelet(float *, float *, int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(float *);
float *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  float *S_in = NULL;
  float *S_out = NULL;
  int size = 8;
  int i;
  S_in = malloc(size * sizeof(float));
  S_out = malloc(size * sizeof(float));
  if (S_in == NULL || S_out == NULL) {
    printf("Erreur : exit(-1)\n");
    exit(-1);
  }
  S_in[0] = -48.0;
  S_in[1] = -16.0;
  S_in[2] = 48.0;
  S_in[3] = 16.0;
  S_in[4] = -16.0;
  S_in[5] = -48.0;
  S_in[6] = -32.0;
  S_in[7] = -16.0;
  printf("Valeur contenues dans S_in = [ ");
  for (i = 0; i < size; ++i) {
    printf("%f, ", S_in[i]);
  }
  printf("] \n");
  Haar_wavelet(S_in, S_out, size, 8);
  printf("Valeur contenues dans S_out = [ ");
  for (i = 0; i < size; ++i) {
    printf("%f, ", S_out[i]);
  }
  printf("] \n");
  free(S_in);
  printf("free(S_in)\n");
  free(S_out);
  printf("free(S)\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x8,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11ab <main+0x5b>
cmpq   $0x0,-0x10(%rbp)
jne    11c3 <main+0x73>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rax
movss  0xe39(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0xe21(%rip),%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  0xe20(%rip),%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movss  0xe0b(%rip),%xmm0
movss  %xmm0,0xc(%rax)
mov    -0x8(%rbp),%rax
movss  0xdee(%rip),%xmm0
movss  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movss  0xde5(%rip),%xmm0
movss  %xmm0,0x14(%rax)
mov    -0x8(%rbp),%rax
movss  0xdd0(%rip),%xmm0
movss  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
movss  0xdbb(%rip),%xmm0
movss  %xmm0,0x1c(%rax)
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1298 <main+0x148>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc4(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    125f <main+0x10f>
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x8,%ecx
call   1050 <Haar_wavelet@plt>
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1309 <main+0x1b9>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd53(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12d0 <main+0x180>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x20,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x20,%edi
call   1070 <malloc@plt>
test   %r14,%r14
je     1354 <main+0x1f4>
mov    %rax,%rbx
test   %rax,%rax
je     1354 <main+0x1f4>
movaps 0xe65(%rip),%xmm0
movups %xmm0,(%r14)
movaps 0xe6a(%rip),%xmm0
movups %xmm0,0x10(%r14)
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea8(%rip),%r15
movsd  0xe58(%rip),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xe4e(%rip),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xe44(%rip),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xe3a(%rip),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r15,%rdi
movsd  0xe15(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r15,%rdi
movsd  0xdfb(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xe0c(%rip),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r15,%rdi
movsd  0xddf(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe37(%rip),%r12
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
mov    $0x8,%ecx
call   1060 <Haar_wavelet@plt>
lea    0xdf2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movss  (%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x8(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0xc(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x10(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x14(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x18(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x1c(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xd61(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xd58(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <puts@plt>
lea    0xd49(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Erreur : exit(-1)\0A\00"
@.str.1 = [32 x i8] c"Valeur contenues dans S_in = [ \00"
@.str.2 = [5 x i8] c"%f, \00"
@.str.3 = [4 x i8] c"] \0A\00"
@.str.4 = [33 x i8] c"Valeur contenues dans S_out = [ \00"
@.str.5 = [12 x i8] c"free(S_in)\0A\00"
@.str.6 = [9 x i8] c"free(S)\0A\00"
define void @main() {
%1 = alloca float*
%2 = alloca float*
%3 = alloca i32
%4 = alloca i32
store float* null, float** %1
store float* null, float** %2
store i32 8, i32* %3
%5 = load i32, i32* %3
%6 = sext i32 %5 to i64
%7 = mul i64 %6, 4
%8 = trunc i64 %7 to i32
%9 = call float* @malloc(i32 %8)
store float* %9, float** %1
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call float* @malloc(i32 %13)
store float* %14, float** %2
%15 = load float*, float** %1
%16 = icmp eq float* %15, null
br i1 %16, label %20, label %17
17: ; preds = %0
%18 = load float*, float** %2
%19 = icmp eq float* %18, null
br i1 %19, label %20, label %23
20: ; preds = %17, %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %17
%24 = load float*, float** %1
%25 = getelementptr inbounds float, float* %24, i64 0
store float -4.800000e+01, float* %25
%26 = load float*, float** %1
%27 = getelementptr inbounds float, float* %26, i64 1
store float -1.600000e+01, float* %27
%28 = load float*, float** %1
%29 = getelementptr inbounds float, float* %28, i64 2
store float 4.800000e+01, float* %29
%30 = load float*, float** %1
%31 = getelementptr inbounds float, float* %30, i64 3
store float 1.600000e+01, float* %31
%32 = load float*, float** %1
%33 = getelementptr inbounds float, float* %32, i64 4
store float -1.600000e+01, float* %33
%34 = load float*, float** %1
%35 = getelementptr inbounds float, float* %34, i64 5
store float -4.800000e+01, float* %35
%36 = load float*, float** %1
%37 = getelementptr inbounds float, float* %36, i64 6
store float -3.200000e+01, float* %37
%38 = load float*, float** %1
%39 = getelementptr inbounds float, float* %38, i64 7
store float -1.600000e+01, float* %39
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %41
41: ; preds = %53, %23
%42 = load i32, i32* %4
%43 = load i32, i32* %3
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %56
45: ; preds = %41
%46 = load float*, float** %1
%47 = load i32, i32* %4
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds float, float* %46, i64 %48
%50 = load float, float* %49
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %51)
br label %53
53: ; preds = %45
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
br label %41
56: ; preds = %41
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%58 = load float*, float** %1
%59 = load float*, float** %2
%60 = load i32, i32* %3
%61 = call i32 @Haar_wavelet(float* %58, float* %59, i32 %60, i32 8)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %63
63: ; preds = %75, %56
%64 = load i32, i32* %4
%65 = load i32, i32* %3
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %78
67: ; preds = %63
%68 = load float*, float** %2
%69 = load i32, i32* %4
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds float, float* %68, i64 %70
%72 = load float, float* %71
%73 = fpext float %72 to double
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %73)
br label %75
75: ; preds = %67
%76 = load i32, i32* %4
%77 = add nsw i32 %76, 1
store i32 %77, i32* %4
br label %63
78: ; preds = %63
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%80 = load float*, float** %1
%81 = call i32 @free(float* %80)
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%83 = load float*, float** %2
%84 = call i32 @free(float* %83)
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [32 x i8] c"Valeur contenues dans S_in = [ \00"
@.str.2 = [5 x i8] c"%f, \00"
@.str.4 = [33 x i8] c"Valeur contenues dans S_out = [ \00"
@str.7 = [3 x i8] c"] \00"
@str.8 = [11 x i8] c"free(S_in)\00"
@str.9 = [8 x i8] c"free(S)\00"
@str.10 = [18 x i8] c"Erreur : exit(-1)\00"
define void @main() {
%1 = tail call float* @malloc(i32 32)
%2 = tail call float* @malloc(i32 32)
%3 = icmp eq float* %1, null
%4 = icmp eq float* %2, null
%5 = or i1 %3, %4
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %0
%10 = bitcast float* %1 to <4 x float>*
store <4 x float> <float -4.800000e+01, float -1.600000e+01, float 4.800000e+01, float 1.600000e+01>, <4 x float>* %10
%11 = getelementptr inbounds float, float* %1, i64 4
%12 = bitcast float* %11 to <4 x float>*
store <4 x float> <float -1.600000e+01, float -4.800000e+01, float -3.200000e+01, float -1.600000e+01>, <4 x float>* %12
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double -4.800000e+01)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double -1.600000e+01)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double 4.800000e+01)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double 1.600000e+01)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double -1.600000e+01)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double -4.800000e+01)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double -3.200000e+01)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double -1.600000e+01)
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.7, i64 0, i64 0))
%23 = tail call i32 @Haar_wavelet(float* %1, float* %2, i32 8, i32 8)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%25 = load float, float* %2
%26 = fpext float %25 to double
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %26)
%28 = getelementptr inbounds float, float* %2, i64 1
%29 = load float, float* %28
%30 = fpext float %29 to double
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %30)
%32 = getelementptr inbounds float, float* %2, i64 2
%33 = load float, float* %32
%34 = fpext float %33 to double
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %34)
%36 = getelementptr inbounds float, float* %2, i64 3
%37 = load float, float* %36
%38 = fpext float %37 to double
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %38)
%40 = getelementptr inbounds float, float* %2, i64 4
%41 = load float, float* %40
%42 = fpext float %41 to double
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %42)
%44 = getelementptr inbounds float, float* %2, i64 5
%45 = load float, float* %44
%46 = fpext float %45 to double
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %46)
%48 = getelementptr inbounds float, float* %2, i64 6
%49 = load float, float* %48
%50 = fpext float %49 to double
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %50)
%52 = getelementptr inbounds float, float* %2, i64 7
%53 = load float, float* %52
%54 = fpext float %53 to double
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %54)
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.7, i64 0, i64 0))
%57 = tail call i32 @free(float* %1)
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0))
%59 = tail call i32 @free(float* %2)
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.9, i64 0, i64 0))
ret void
}