#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 */
size_t CodonToAmino(int, int const);
scalar_t__ IsStop(int, int const);
int IsValidGencode(int const);
int /*<<< orphan*/ assert(int);
double *calloc(int, int);
int /*<<< orphan*/ warnx(char *, char *, int);
double *GetAminoFrequencies(const double *codons, const int gencode) {
  double *af;
  assert(NULL != codons);
  assert(IsValidGencode(gencode));
  af = calloc(20, sizeof(double));
  if (NULL == af) {
    warnx("Failed to allocate memory %s:%d\n. Returing null",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/timmassingham/SLR/refs/heads/master/src/"
          "gencode.c",
          332);
    return NULL;
  }
  for (int codon = 0; codon < 64; codon++) {
    if (IsStop(codon, gencode)) {
      continue;
    }
    af[CodonToAmino(codon, gencode)] += codons[codon];
  }
  return af;
}


x86 assembly (clang, -O0):
<GetAminoFrequencies>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x14(%rbp),%edi
call   1060 <IsValidGencode@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    $0x14,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    11d5 <GetAminoFrequencies+0x75>
lea    0xe49(%rip),%rdi
lea    0xe72(%rip),%rsi
mov    $0x14c,%edx
call   1030 <warnx@plt>
movq   $0x0,-0x8(%rbp)
jmp    1251 <GetAminoFrequencies+0xf1>
movl   $0x0,-0x24(%rbp)
cmpl   $0x40,-0x24(%rbp)
jge    1249 <GetAminoFrequencies+0xe9>
mov    -0x24(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1080 <IsStop@plt>
cmp    $0x0,%rax
je     1200 <GetAminoFrequencies+0xa0>
jmp    123b <GetAminoFrequencies+0xdb>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1070 <CodonToAmino@plt>
movsd  -0x38(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11dc <GetAminoFrequencies+0x7c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetAminoFrequencies>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1050 <assert@plt>
mov    %ebp,%edi
call   1060 <IsValidGencode@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    $0x14,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%r15
test   %rax,%rax
je     11ef <GetAminoFrequencies+0x8f>
xor    %ebx,%ebx
jmp    11ba <GetAminoFrequencies+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    $0x40,%rbx
je     1207 <GetAminoFrequencies+0xa7>
mov    %ebx,%edi
mov    %ebp,%esi
call   1080 <IsStop@plt>
test   %rax,%rax
jne    11b0 <GetAminoFrequencies+0x50>
movsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    %ebp,%esi
call   1070 <CodonToAmino@plt>
movsd  (%rsp),%xmm0
addsd  (%r15,%rax,8),%xmm0
movsd  %xmm0,(%r15,%rax,8)
jmp    11b0 <GetAminoFrequencies+0x50>
lea    0xe0a(%rip),%rdi
lea    0xe33(%rip),%rsi
mov    $0x14c,%edx
call   1030 <warnx@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Failed to allocate memory %s:%d\0A. Returing null\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/timmassingham/SLR/refs/heads/master/src/gencode.c\00"
define double* @GetAminoFrequencies(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
%8 = load double*, double** %4
%9 = icmp ne double* null, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i32, i32* %5
%13 = call i32 @IsValidGencode(i32 %12)
%14 = call i32 @assert(i32 %13)
%15 = call double* @calloc(i32 20, i32 8)
store double* %15, double** %6
%16 = load double*, double** %6
%17 = icmp eq double* null, %16
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @warnx(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 332)
store double* null, double** %3
br label %48
20: ; preds = %2
store i32 0, i32* %7
br label %21
21: ; preds = %43, %20
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 64
br i1 %23, label %24, label %46
24: ; preds = %21
%25 = load i32, i32* %7
%26 = load i32, i32* %5
%27 = call i64 @IsStop(i32 %25, i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %24
br label %43
30: ; preds = %24
%31 = load double*, double** %4
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = load double*, double** %6
%37 = load i32, i32* %7
%38 = load i32, i32* %5
%39 = call i64 @CodonToAmino(i32 %37, i32 %38)
%40 = getelementptr inbounds double, double* %36, i64 %39
%41 = load double, double* %40
%42 = fadd double %41, %35
store double %42, double* %40
br label %43
43: ; preds = %30, %29
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %21
46: ; preds = %21
%47 = load double*, double** %6
store double* %47, double** %3
br label %48
48: ; preds = %46, %18
%49 = load double*, double** %3
ret double* %49
}

LLVM IR (-O2):
@.str = [48 x i8] c"Failed to allocate memory %s:%d\0A. Returing null\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/timmassingham/SLR/refs/heads/master/src/gencode.c\00"
define noalias double* @GetAminoFrequencies(double* %0, i32 %1) {
%3 = icmp ne double* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i32 @IsValidGencode(i32 %1)
%7 = tail call i32 @assert(i32 %6)
%8 = tail call double* @calloc(i32 20, i32 8)
%9 = icmp eq double* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @warnx(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 332)
br label %27
12: ; preds = %2, %24
%13 = phi i64 [ %25, %24 ], [ 0, %2 ]
%14 = trunc i64 %13 to i32
%15 = tail call i64 @IsStop(i32 %14, i32 %1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = getelementptr inbounds double, double* %0, i64 %13
%19 = load double, double* %18
%20 = tail call i64 @CodonToAmino(i32 %14, i32 %1)
%21 = getelementptr inbounds double, double* %8, i64 %20
%22 = load double, double* %21
%23 = fadd double %19, %22
store double %23, double* %21
br label %24
24: ; preds = %12, %17
%25 = add nuw nsw i64 %13, 1
%26 = icmp eq i64 %25, 64
br i1 %26, label %27, label %12
27: ; preds = %24, %10
ret double* %8
}