#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 */
scalar_t__ mCalloc(int, int);
scalar_t__ matrixCharMatches(char **, int, int, char const, int *);
double *calcStationaryProbsGlobal(char **s, int numSeqs, int length,
                                  int *filter, int numSelected,
                                  int alphabetSize, const char *alphabet) {
  int i;
  double *p;
  p = (double *)mCalloc(alphabetSize, sizeof(double));
  for (i = 0; i < alphabetSize; i++) {
    p[i] =
        (double)(matrixCharMatches(s, numSeqs, length, alphabet[i], filter)) /
        (numSeqs * numSelected);
  }
  return (p);
}


x86 assembly (clang, -O0):
<calcStationaryProbsGlobal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    $0x8,%esi
call   1040 <mCalloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11b6 <calcStationaryProbsGlobal+0x96>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%r8
movsbl %al,%ecx
call   1030 <matrixCharMatches@plt>
cvtsi2sd %rax,%xmm0
mov    -0xc(%rbp),%eax
imul   -0x1c(%rbp),%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115a <calcStationaryProbsGlobal+0x3a>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcStationaryProbsGlobal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r14d
mov    %r8d,%r13d
mov    %rcx,0x10(%rsp)
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%r12
mov    %r9d,%edi
mov    $0x8,%esi
call   1040 <mCalloc@plt>
mov    %rax,%rbp
test   %r14d,%r14d
jle    11aa <calcStationaryProbsGlobal+0x8a>
imul   %ebx,%r13d
cvtsi2sd %r13d,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r14d,%r13d
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
mov    0x50(%rsp),%rax
movsbl (%rax,%r14,1),%ecx
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    0x10(%rsp),%r8
call   1030 <matrixCharMatches@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x0(%rbp,%r14,8)
add    $0x1,%r14
cmp    %r14,%r13
jne    1170 <calcStationaryProbsGlobal+0x50>
mov    %rbp,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double* @calcStationaryProbsGlobal(i8** %0, i32 %1, i32 %2, i32* %3, i32 %4, i32 %5, i8* nocapture %6) {
%8 = tail call i64 @mCalloc(i32 %5, i32 8)
%9 = inttoptr i64 %8 to double*
%10 = icmp sgt i32 %5, 0
br i1 %10, label %11, label %25
11: ; preds = %7
%12 = mul nsw i32 %4, %1
%13 = sitofp i32 %12 to double
%14 = zext i32 %5 to i64
br label %15
15: ; preds = %11, %15
%16 = phi i64 [ 0, %11 ], [ %23, %15 ]
%17 = getelementptr inbounds i8, i8* %6, i64 %16
%18 = load i8, i8* %17
%19 = tail call i64 @matrixCharMatches(i8** %0, i32 %1, i32 %2, i8 signext %18, i32* %3)
%20 = sitofp i64 %19 to double
%21 = fdiv double %20, %13
%22 = getelementptr inbounds double, double* %9, i64 %16
store double %21, double* %22
%23 = add nuw nsw i64 %16, 1
%24 = icmp eq i64 %23, %14
br i1 %24, label %25, label %15
25: ; preds = %15, %7
ret double* %9
}