#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*/ fill_genotype_model(char *, char *, int, int,
                                       int /*<<< orphan*/, int, int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
long multiset(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ printswitch(int);
void test_DNA(int ploidy, int verbose) {
  int i;
  int j;
  long combinations = multiset(4, ploidy);
  char *alleles = "ACGT";
  char *model;
  model = malloc((ploidy + 1) * sizeof(char));
  model[ploidy] = '\0';
  printf("\nCREATING ");
  printswitch(ploidy);
  printf(" GENOTYPE MODEL\n");
  printf("%lu POSSIBLE COMBINATIONS\n", combinations);
  printf("===============\n");
  for (i = 0; i < 4; i++) {
    fill_genotype_model(alleles, model, ploidy, 4, 0, i, verbose);
  }
  free(model);
  return;
}


x86 assembly (clang, -O0):
<test_DNA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x4,%edi
call   1040 <multiset@plt>
mov    %rax,-0x18(%rbp)
lea    0xe7a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x4(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4(%rbp),%edi
call   1050 <printswitch@plt>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    1232 <test_DNA+0xd2>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x4(%rbp),%edx
mov    -0xc(%rbp),%r9d
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
xor    %r8d,%r8d
mov    %eax,(%rsp)
call   1080 <fill_genotype_model@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11f8 <test_DNA+0x98>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_DNA>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0x4,%edi
mov    %ebp,%esi
call   1040 <multiset@plt>
mov    %rax,%r15
lea    0x1(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
movslq %ebp,%rbp
movb   $0x0,(%rax,%rbp,1)
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%edi
call   1050 <printswitch@plt>
lea    0xe72(%rip),%rdi
call   1060 <puts@plt>
lea    0xe4b(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe65(%rip),%rdi
call   1060 <puts@plt>
mov    %r14d,(%rsp)
lea    0xe1a(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    $0x4,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1090 <fill_genotype_model@plt>
mov    %r14d,(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    $0x4,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1090 <fill_genotype_model@plt>
mov    %r14d,(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    $0x4,%ecx
xor    %r8d,%r8d
mov    $0x2,%r9d
call   1090 <fill_genotype_model@plt>
mov    %r14d,(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    $0x4,%ecx
xor    %r8d,%r8d
mov    $0x3,%r9d
call   1090 <fill_genotype_model@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"ACGT\00"
@.str.1 = [11 x i8] c"\0ACREATING \00"
@.str.2 = [17 x i8] c" GENOTYPE MODEL\0A\00"
@.str.3 = [27 x i8] c"%lu POSSIBLE COMBINATIONS\0A\00"
@.str.4 = [17 x i8] c"===============\0A\00"
define void @test_DNA(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = load i32, i32* %3
%11 = call i64 @multiset(i32 4, i32 %10)
store i64 %11, i64* %7
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 1
%16 = trunc i64 %15 to i32
%17 = call i8* @malloc(i32 %16)
store i8* %17, i8** %9
%18 = load i8*, i8** %9
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
store i8 0, i8* %21
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* %3
%24 = call i32 @printswitch(i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%26 = load i64, i64* %7
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i64 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %5
br label %29
29: ; preds = %39, %2
%30 = load i32, i32* %5
%31 = icmp slt i32 %30, 4
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = load i8*, i8** %8
%34 = load i8*, i8** %9
%35 = load i32, i32* %3
%36 = load i32, i32* %5
%37 = load i32, i32* %4
%38 = call i32 @fill_genotype_model(i8* %33, i8* %34, i32 %35, i32 4, i32 0, i32 %36, i32 %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %29
42: ; preds = %29
%43 = load i8*, i8** %9
%44 = call i32 @free(i8* %43)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"ACGT\00"
@.str.1 = [11 x i8] c"\0ACREATING \00"
@.str.3 = [27 x i8] c"%lu POSSIBLE COMBINATIONS\0A\00"
@str = [16 x i8] c" GENOTYPE MODEL\00"
@str.5 = [16 x i8] c"===============\00"
define void @test_DNA(i32 %0, i32 %1) {
%3 = tail call i64 @multiset(i32 4, i32 %0)
%4 = add nsw i32 %0, 1
%5 = tail call i8* @malloc(i32 %4)
%6 = sext i32 %0 to i64
%7 = getelementptr inbounds i8, i8* %5, i64 %6
store i8 0, i8* %7
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @printswitch(i32 %0)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i64 %3)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.5, i64 0, i64 0))
%13 = tail call i32 @fill_genotype_model(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %0, i32 4, i32 0, i32 0, i32 %1)
%14 = tail call i32 @fill_genotype_model(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %0, i32 4, i32 0, i32 1, i32 %1)
%15 = tail call i32 @fill_genotype_model(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %0, i32 4, i32 0, i32 2, i32 %1)
%16 = tail call i32 @fill_genotype_model(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %0, i32 4, i32 0, i32 3, i32 %1)
%17 = tail call i32 @free(i8* %5)
ret void
}