#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 *build_consensus(int **, int, int, double, int);
int /*<<< orphan*/ free_votes(int **, int);
int **get_votes_qual(char **, char **, int, int, char);
int **get_votes_simple(char **, int, int);
char *rm_gaps(char *, int);
char *get_consensus(char *align[], char *quals[], int n_seqs, int seq_len,
                    double cons_thres, int min_reads, char qual_thres,
                    int gapped) {
  if (cons_thres == -1.0) {
    cons_thres = 0.5;
  }
  int **votes;
  if (quals == 0) {
    votes = get_votes_simple(align, n_seqs, seq_len);
  } else {
    votes = get_votes_qual(align, quals, n_seqs, seq_len, qual_thres);
  }
  char *consensus_gapped =
      build_consensus(votes, n_seqs, seq_len, cons_thres, min_reads);
  char *consensus;
  if (gapped) {
    consensus = consensus_gapped;
  } else {
    consensus = rm_gaps(consensus_gapped, seq_len);
  }
  free_votes(votes, seq_len);
  return consensus;
}


x86 assembly (clang, -O0):
<get_consensus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %r9b,%al
mov    0x10(%rbp),%r9d
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %al,-0x25(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe7a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11a3 <get_consensus+0x53>
jp     11a3 <get_consensus+0x53>
movsd  0xe6a(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c6 <get_consensus+0x76>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1070 <get_votes_simple@plt>
mov    %rax,-0x30(%rbp)
jmp    11e2 <get_consensus+0x92>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
movsbl -0x25(%rbp),%r8d
call   1030 <get_votes_qual@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
movsd  -0x20(%rbp),%xmm0
mov    -0x24(%rbp),%ecx
call   1050 <build_consensus@plt>
mov    %rax,-0x38(%rbp)
cmpl   $0x0,0x10(%rbp)
je     1214 <get_consensus+0xc4>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    1224 <get_consensus+0xd4>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1060 <rm_gaps@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1040 <free_votes@plt>
mov    -0x40(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_consensus>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r14d
mov    %ecx,%r12d
mov    %edx,%r15d
mov    0x50(%rsp),%r13d
movsd  0xe8c(%rip),%xmm2
cmpeqsd %xmm0,%xmm2
movsd  0xe87(%rip),%xmm1
andpd  %xmm2,%xmm1
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
movapd %xmm2,(%rsp)
test   %rsi,%rsi
je     11a8 <get_consensus+0x58>
movsbl %r9b,%r8d
mov    %r15d,%edx
mov    %r12d,%ecx
call   1030 <get_votes_qual@plt>
jmp    11b3 <get_consensus+0x63>
mov    %r15d,%esi
mov    %r12d,%edx
call   1070 <get_votes_simple@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15d,%esi
mov    %r12d,%edx
movaps (%rsp),%xmm0
mov    %r14d,%ecx
call   1050 <build_consensus@plt>
mov    %rax,%rbx
test   %r13d,%r13d
jne    11e1 <get_consensus+0x91>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1060 <rm_gaps@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %r12d,%esi
call   1040 <free_votes@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @get_consensus(i8** %0, i8** %1, i32 %2, i32 %3, double %4, i32 %5, i8 signext %6, i32 %7) {
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca i32
%15 = alloca i8
%16 = alloca i32
%17 = alloca i32**
%18 = alloca i8*
%19 = alloca i8*
store i8** %0, i8*** %9
store i8** %1, i8*** %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store double %4, double* %13
store i32 %5, i32* %14
store i8 %6, i8* %15
store i32 %7, i32* %16
%20 = load double, double* %13
%21 = fcmp oeq double %20, -1.000000e+00
br i1 %21, label %22, label %23
22: ; preds = %8
store double 5.000000e-01, double* %13
br label %23
23: ; preds = %22, %8
%24 = load i8**, i8*** %10
%25 = icmp eq i8** %24, null
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i8**, i8*** %9
%28 = load i32, i32* %11
%29 = load i32, i32* %12
%30 = call i32** @get_votes_simple(i8** %27, i32 %28, i32 %29)
store i32** %30, i32*** %17
br label %38
31: ; preds = %23
%32 = load i8**, i8*** %9
%33 = load i8**, i8*** %10
%34 = load i32, i32* %11
%35 = load i32, i32* %12
%36 = load i8, i8* %15
%37 = call i32** @get_votes_qual(i8** %32, i8** %33, i32 %34, i32 %35, i8 signext %36)
store i32** %37, i32*** %17
br label %38
38: ; preds = %31, %26
%39 = load i32**, i32*** %17
%40 = load i32, i32* %11
%41 = load i32, i32* %12
%42 = load double, double* %13
%43 = load i32, i32* %14
%44 = call i8* @build_consensus(i32** %39, i32 %40, i32 %41, double %42, i32 %43)
store i8* %44, i8** %18
%45 = load i32, i32* %16
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %38
%48 = load i8*, i8** %18
store i8* %48, i8** %19
br label %53
49: ; preds = %38
%50 = load i8*, i8** %18
%51 = load i32, i32* %12
%52 = call i8* @rm_gaps(i8* %50, i32 %51)
store i8* %52, i8** %19
br label %53
53: ; preds = %49, %47
%54 = load i32**, i32*** %17
%55 = load i32, i32* %12
%56 = call i32 @free_votes(i32** %54, i32 %55)
%57 = load i8*, i8** %19
ret i8* %57
}

LLVM IR (-O2):
define i8* @get_consensus(i8** %0, i8** %1, i32 %2, i32 %3, double %4, i32 %5, i8 signext %6, i32 %7) {
%9 = fcmp oeq double %4, -1.000000e+00
%10 = select i1 %9, double 5.000000e-01, double %4
%11 = icmp eq i8** %1, null
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32** @get_votes_simple(i8** %0, i32 %2, i32 %3)
br label %16
14: ; preds = %8
%15 = tail call i32** @get_votes_qual(i8** %0, i8** %1, i32 %2, i32 %3, i8 signext %6)
br label %16
16: ; preds = %14, %12
%17 = phi i32** [ %13, %12 ], [ %15, %14 ]
%18 = tail call i8* @build_consensus(i32** %17, i32 %2, i32 %3, double %10, i32 %5)
%19 = icmp eq i32 %7, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = tail call i8* @rm_gaps(i8* %18, i32 %3)
br label %22
22: ; preds = %16, %20
%23 = phi i8* [ %21, %20 ], [ %18, %16 ]
%24 = tail call i32 @free_votes(i32** %17, i32 %3)
ret i8* %23
}