#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 */
char *createDnaString(double, double, double, double, int);
int /*<<< orphan*/ free(char *);
char *huffmanComplex(char *);
char *huffmanSimple(char *);
int /*<<< orphan*/ printf(char *, double, ...);
scalar_t__ strlen(char *);
void testN() {
  double a = 0.50;
  double t = 0.30;
  double c = 0.10;
  double g = 0.10;
  int n = 200;
  int start = 10;
  double rcSimple[n - start];
  double rcComplex[n - start];
  int len[n - start];
  char *seq = NULL;
  char *binSimple = NULL;
  char *binComplex = NULL;
  int size = -1;
  double averageSimpleRC = 0;
  double averageComplexRC = 0;
  for (int i = start; i < n; i++) {
    size = i * 8;
    seq = createDnaString(a, g, c, t, i);
    binSimple = huffmanSimple(seq);
    binComplex = huffmanComplex(seq);
    len[i - start] = i;
    rcSimple[i - start] = (double)size / (double)(strlen(binSimple));
    rcComplex[i - start] = (double)size / (double)(strlen(binComplex));
    printf("%d\t%.3f\t%.3f\n\n", len[i - start], rcSimple[i - start],
           rcComplex[i - start]);
    averageSimpleRC += rcSimple[i - start];
    averageComplexRC += rcComplex[i - start];
    free(binSimple);
    free(binComplex);
    free(seq);
  }
  averageSimpleRC = averageSimpleRC / (n - start);
  averageComplexRC = averageComplexRC / (n - start);
  printf("Ratio medio algoritmo simple: %.3f\n", averageSimpleRC);
  printf("Ratio medio algoritmo complejo: %.3f\n", averageComplexRC);
}


x86 assembly (clang, -O0):
<testN>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movabs $0x3fe0000000000000,%rax
mov    %rax,-0x8(%rbp)
movabs $0x3fd3333333333333,%rax
33 d3 3f
mov    %rax,-0x10(%rbp)
movabs $0x3fb999999999999a,%rax
99 b9 3f
mov    %rax,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
movl   $0xc8,-0x24(%rbp)
movl   $0xa,-0x28(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    %ecx,%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    %ecx,%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    %ecx,%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movl   $0xffffffff,-0x64(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    13ee <testN+0x28e>
mov    -0x7c(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x64(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm3
mov    -0x7c(%rbp),%edi
call   1040 <createDnaString@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
call   1080 <huffmanSimple@plt>
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rdi
call   1070 <huffmanComplex@plt>
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
mov    %rcx,-0x60(%rbp)
mov    -0x7c(%rbp),%edx
mov    -0x7c(%rbp),%ecx
sub    -0x28(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
cvtsi2sdl -0x64(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x58(%rbp),%rdi
call   1050 <strlen@plt>
movsd  -0xa8(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
cvtsi2sd %rcx,%xmm1
divsd  %xmm1,%xmm0
mov    -0x7c(%rbp),%ecx
sub    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x64(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0x60(%rbp),%rdi
call   1050 <strlen@plt>
movsd  -0xa0(%rbp),%xmm0
ff
mov    -0x88(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    %rax,%rsi
mov    -0x90(%rbp),%rax
cvtsi2sd %rsi,%xmm1
divsd  %xmm1,%xmm0
mov    -0x7c(%rbp),%esi
sub    -0x28(%rbp),%esi
movslq %esi,%rsi
movsd  %xmm0,(%rax,%rsi,8)
mov    -0x7c(%rbp),%esi
sub    -0x28(%rbp),%esi
movslq %esi,%rsi
cvtsi2sdl (%rdx,%rsi,4),%xmm0
mov    -0x7c(%rbp),%edx
sub    -0x28(%rbp),%edx
movslq %edx,%rdx
movsd  (%rcx,%rdx,8),%xmm1
mov    -0x7c(%rbp),%ecx
sub    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
lea    0xc80(%rip),%rdi
mov    $0x3,%al
call   1060 <printf@plt>
mov    -0x98(%rbp),%rcx
mov    -0x90(%rbp),%rax
mov    -0x7c(%rbp),%edx
sub    -0x28(%rbp),%edx
movslq %edx,%rdx
movsd  (%rcx,%rdx,8),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x7c(%rbp),%ecx
sub    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    125b <testN+0xfb>
movsd  -0x70(%rbp),%xmm0
mov    -0x24(%rbp),%eax
sub    -0x28(%rbp),%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x78(%rbp),%xmm0
mov    -0x24(%rbp),%eax
sub    -0x28(%rbp),%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
lea    0xbe5(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x78(%rbp),%xmm0
lea    0xbf6(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testN>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
mov    $0xa,%ebx
movsd  0xe7d(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x50,%r14d
nop
movsd  0xe70(%rip),%xmm0
movsd  0xe70(%rip),%xmm1
movaps %xmm1,%xmm2
movsd  0xe6d(%rip),%xmm3
mov    %ebx,%edi
call   1040 <createDnaString@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1080 <huffmanSimple@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1070 <huffmanComplex@plt>
mov    %rax,%r13
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movapd %xmm0,0x20(%rsp)
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   1050 <strlen@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rbp,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
unpcklpd %xmm0,%xmm1
movapd 0x20(%rsp),%xmm0
unpcklpd %xmm0,%xmm0
divpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
movapd %xmm0,%xmm2
movapd %xmm0,0x20(%rsp)
unpckhpd %xmm0,%xmm1
lea    0xe09(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x3,%al
call   1060 <printf@plt>
movapd 0x10(%rsp),%xmm0
addpd  0x20(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xdb4(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0x1,%ebx
add    $0x8,%r14d
cmp    $0x640,%r14d
jne    1190 <testN+0x30>
movapd 0x10(%rsp),%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
movsd  0xd8c(%rip),%xmm1
divsd  %xmm1,%xmm0
divsd  %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
lea    0xd8e(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xda4(%rip),%rdi
movaps 0x10(%rsp),%xmm0
mov    $0x1,%al
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <printf@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"%d\09%.3f\09%.3f\0A\0A\00"
@.str.1 = [36 x i8] c"Ratio medio algoritmo simple: %.3f\0A\00"
@.str.2 = [38 x i8] c"Ratio medio algoritmo complejo: %.3f\0A\00"
define void @testN() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca double
%16 = alloca double
%17 = alloca i32
store double 5.000000e-01, double* %1
store double 3.000000e-01, double* %2
store double 1.000000e-01, double* %3
store double 1.000000e-01, double* %4
store i32 200, i32* %5
store i32 10, i32* %6
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = sub nsw i32 %18, %19
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %7
%23 = alloca double, i64 %21
store i64 %21, i64* %8
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = sub nsw i32 %24, %25
%27 = zext i32 %26 to i64
%28 = alloca double, i64 %27
store i64 %27, i64* %9
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = sub nsw i32 %29, %30
%32 = zext i32 %31 to i64
%33 = alloca i32, i64 %32
store i64 %32, i64* %10
store i8* null, i8** %11
store i8* null, i8** %12
store i8* null, i8** %13
store i32 -1, i32* %14
store double 0.000000e+00, double* %15
store double 0.000000e+00, double* %16
%34 = load i32, i32* %6
store i32 %34, i32* %17
br label %35
35: ; preds = %122, %0
%36 = load i32, i32* %17
%37 = load i32, i32* %5
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %125
39: ; preds = %35
%40 = load i32, i32* %17
%41 = mul nsw i32 %40, 8
store i32 %41, i32* %14
%42 = load double, double* %1
%43 = load double, double* %4
%44 = load double, double* %3
%45 = load double, double* %2
%46 = load i32, i32* %17
%47 = call i8* @createDnaString(double %42, double %43, double %44, double %45, i32 %46)
store i8* %47, i8** %11
%48 = load i8*, i8** %11
%49 = call i8* @huffmanSimple(i8* %48)
store i8* %49, i8** %12
%50 = load i8*, i8** %11
%51 = call i8* @huffmanComplex(i8* %50)
store i8* %51, i8** %13
%52 = load i32, i32* %17
%53 = load i32, i32* %17
%54 = load i32, i32* %6
%55 = sub nsw i32 %53, %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %33, i64 %56
store i32 %52, i32* %57
%58 = load i32, i32* %14
%59 = sitofp i32 %58 to double
%60 = load i8*, i8** %12
%61 = call i64 @strlen(i8* %60)
%62 = sitofp i64 %61 to double
%63 = fdiv double %59, %62
%64 = load i32, i32* %17
%65 = load i32, i32* %6
%66 = sub nsw i32 %64, %65
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %23, i64 %67
store double %63, double* %68
%69 = load i32, i32* %14
%70 = sitofp i32 %69 to double
%71 = load i8*, i8** %13
%72 = call i64 @strlen(i8* %71)
%73 = sitofp i64 %72 to double
%74 = fdiv double %70, %73
%75 = load i32, i32* %17
%76 = load i32, i32* %6
%77 = sub nsw i32 %75, %76
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %28, i64 %78
store double %74, double* %79
%80 = load i32, i32* %17
%81 = load i32, i32* %6
%82 = sub nsw i32 %80, %81
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %33, i64 %83
%85 = load i32, i32* %84
%86 = sitofp i32 %85 to double
%87 = load i32, i32* %17
%88 = load i32, i32* %6
%89 = sub nsw i32 %87, %88
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %23, i64 %90
%92 = load double, double* %91
%93 = load i32, i32* %17
%94 = load i32, i32* %6
%95 = sub nsw i32 %93, %94
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %28, i64 %96
%98 = load double, double* %97
%99 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double %86, double %92, double %98)
%100 = load i32, i32* %17
%101 = load i32, i32* %6
%102 = sub nsw i32 %100, %101
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %23, i64 %103
%105 = load double, double* %104
%106 = load double, double* %15
%107 = fadd double %106, %105
store double %107, double* %15
%108 = load i32, i32* %17
%109 = load i32, i32* %6
%110 = sub nsw i32 %108, %109
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double, double* %28, i64 %111
%113 = load double, double* %112
%114 = load double, double* %16
%115 = fadd double %114, %113
store double %115, double* %16
%116 = load i8*, i8** %12
%117 = call i32 @free(i8* %116)
%118 = load i8*, i8** %13
%119 = call i32 @free(i8* %118)
%120 = load i8*, i8** %11
%121 = call i32 @free(i8* %120)
br label %122
122: ; preds = %39
%123 = load i32, i32* %17
%124 = add nsw i32 %123, 1
store i32 %124, i32* %17
br label %35
125: ; preds = %35
%126 = load double, double* %15
%127 = load i32, i32* %5
%128 = load i32, i32* %6
%129 = sub nsw i32 %127, %128
%130 = sitofp i32 %129 to double
%131 = fdiv double %126, %130
store double %131, double* %15
%132 = load double, double* %16
%133 = load i32, i32* %5
%134 = load i32, i32* %6
%135 = sub nsw i32 %133, %134
%136 = sitofp i32 %135 to double
%137 = fdiv double %132, %136
store double %137, double* %16
%138 = load double, double* %15
%139 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), double %138)
%140 = load double, double* %16
%141 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), double %140)
%142 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"%d\09%.3f\09%.3f\0A\0A\00"
@.str.1 = [36 x i8] c"Ratio medio algoritmo simple: %.3f\0A\00"
@.str.2 = [38 x i8] c"Ratio medio algoritmo complejo: %.3f\0A\00"
define void @testN() {
br label %8
1: ; preds = %8
%2 = extractelement <2 x double> %28, i64 1
%3 = fdiv double %2, 1.900000e+02
%4 = extractelement <2 x double> %28, i64 0
%5 = fdiv double %4, 1.900000e+02
%6 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), double %3)
%7 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), double %5)
ret void
8: ; preds = %0, %8
%9 = phi i32 [ 10, %0 ], [ %32, %8 ]
%10 = phi <2 x double> [ zeroinitializer, %0 ], [ %28, %8 ]
%11 = shl nuw nsw i32 %9, 3
%12 = tail call i8* @createDnaString(double 5.000000e-01, double 1.000000e-01, double 1.000000e-01, double 3.000000e-01, i32 %9)
%13 = tail call i8* @huffmanSimple(i8* %12)
%14 = tail call i8* @huffmanComplex(i8* %12)
%15 = sitofp i32 %11 to double
%16 = tail call i64 @strlen(i8* dereferenceable(1) %13)
%17 = tail call i64 @strlen(i8* dereferenceable(1) %14)
%18 = insertelement <2 x i64> poison, i64 %17, i64 0
%19 = insertelement <2 x i64> %18, i64 %16, i64 1
%20 = sitofp <2 x i64> %19 to <2 x double>
%21 = insertelement <2 x double> poison, double %15, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = fdiv <2 x double> %22, %20
%24 = sitofp i32 %9 to double
%25 = extractelement <2 x double> %23, i64 0
%26 = extractelement <2 x double> %23, i64 1
%27 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double %24, double %26, double %25)
%28 = fadd <2 x double> %10, %23
%29 = tail call i32 @free(i8* %13)
%30 = tail call i32 @free(i8* %14)
%31 = tail call i32 @free(i8* %12)
%32 = add nuw nsw i32 %9, 1
%33 = icmp eq i32 %32, 200
br i1 %33, label %1, label %8
}