#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 createNucleotide(double, double, double, double);
char *malloc(int);
char *createDnaString(double adeninePercentage, double guaninePercentage,
                      double cytosinePercentage, double thyminePercentage,
                      int dnaLength) {
  char *dnaString = malloc((dnaLength + 1) * sizeof(char));
  for (int i = 0; i < dnaLength; i++) {
    dnaString[i] = createNucleotide(adeninePercentage, guaninePercentage,
                                    cytosinePercentage, thyminePercentage);
  }
  dnaString[dnaLength] = '\0';
  return dnaString;
}


x86 assembly (clang, -O0):
<createDnaString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    119d <createDnaString+0x7d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
call   1030 <createNucleotide@plt>
mov    %al,%dl
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115d <createDnaString+0x3d>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createDnaString>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edi,%r14d
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
lea    0x1(%r14),%edi
call   1040 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    118a <createDnaString+0x6a>
mov    %r14d,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
call   1030 <createNucleotide@plt>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <createDnaString+0x40>
movslq %r14d,%rax
movb   $0x0,(%r15,%rax,1)
mov    %r15,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @createDnaString(double %0, double %1, double %2, double %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store i32 %4, i32* %10
%13 = load i32, i32* %10
%14 = add nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 1
%17 = trunc i64 %16 to i32
%18 = call i8* @malloc(i32 %17)
store i8* %18, i8** %11
store i32 0, i32* %12
br label %19
19: ; preds = %33, %5
%20 = load i32, i32* %12
%21 = load i32, i32* %10
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %36
23: ; preds = %19
%24 = load double, double* %6
%25 = load double, double* %7
%26 = load double, double* %8
%27 = load double, double* %9
%28 = call signext i8 @createNucleotide(double %24, double %25, double %26, double %27)
%29 = load i8*, i8** %11
%30 = load i32, i32* %12
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 %28, i8* %32
br label %33
33: ; preds = %23
%34 = load i32, i32* %12
%35 = add nsw i32 %34, 1
store i32 %35, i32* %12
br label %19
36: ; preds = %19
%37 = load i8*, i8** %11
%38 = load i32, i32* %10
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
store i8 0, i8* %40
%41 = load i8*, i8** %11
ret i8* %41
}

LLVM IR (-O2):
define noalias i8* @createDnaString(double %0, double %1, double %2, double %3, i32 %4) {
%6 = add nsw i32 %4, 1
%7 = tail call i8* @malloc(i32 %6)
%8 = icmp sgt i32 %4, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = zext i32 %4 to i64
br label %14
11: ; preds = %14, %5
%12 = sext i32 %4 to i64
%13 = getelementptr inbounds i8, i8* %7, i64 %12
store i8 0, i8* %13
ret i8* %7
14: ; preds = %9, %14
%15 = phi i64 [ 0, %9 ], [ %18, %14 ]
%16 = tail call signext i8 @createNucleotide(double %0, double %1, double %2, double %3)
%17 = getelementptr inbounds i8, i8* %7, i64 %15
store i8 %16, i8* %17
%18 = add nuw nsw i64 %15, 1
%19 = icmp eq i64 %18, %10
br i1 %19, label %11, label %14
}