#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int GapChar(int);
int ToAmino(char);
int *calloc(size_t, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char gchar(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int *ReadAmino(FILE *fp, int n_pts, const char *name) {
  int *seq;
  char c;
  int i, j;
  seq = calloc((size_t)n_pts, sizeof(int));
  if (seq == NULL) {
    printf("Out of Memory! %s:%d\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/timmassingham/SLR/refs/heads/master/src/"
           "data.c",
           1437);
    exit(EXIT_FAILURE);
  };
  bool has_ambig_nuc = false;
  for (i = 0; i < n_pts; i++) {
    c = gchar(fp);
    j = ToAmino(c);
    if (-1 == j) {
      if (false == has_ambig_nuc) {
        printf("#  Warning: Found unrecognised nucleotide in sequence %s: ",
               name);
        has_ambig_nuc = true;
      }
      printf("%c(%d) ", c, i);
      j = GapChar(1);
    }
    seq[i] = j;
  }
  return seq;
}


x86 assembly (clang, -O0):
<ReadAmino>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movslq -0xc(%rbp),%rdi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b8 <ReadAmino+0x58>
lea    0xe69(%rip),%rdi
lea    0xe78(%rip),%rsi
mov    $0x59d,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    125a <ReadAmino+0xfa>
mov    -0x8(%rbp),%rdi
call   1030 <gchar@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%edi
call   1080 <ToAmino@plt>
mov    %eax,-0x2c(%rbp)
mov    $0xffffffff,%eax
cmp    -0x2c(%rbp),%eax
jne    123e <ReadAmino+0xde>
xor    %eax,%eax
cmp    -0x30(%rbp),%eax
jne    121c <ReadAmino+0xbc>
mov    -0x18(%rbp),%rsi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x30(%rbp)
movsbl -0x21(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <GapChar@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c6 <ReadAmino+0x66>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadAmino>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,(%rsp)
mov    %esi,%ebp
mov    %rdi,%r15
movslq %esi,%rdi
mov    $0x4,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     1213 <ReadAmino+0xb3>
mov    %rax,%rbx
test   %ebp,%ebp
jle    1201 <ReadAmino+0xa1>
mov    %ebp,%r14d
xor    %ebp,%ebp
xor    %r13d,%r13d
jmp    11cf <ReadAmino+0x6f>
nopl   0x0(%rax,%rax,1)
lea    0xf33(%rip),%rdi
mov    %r12d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r13d
mov    $0x1,%edi
call   1060 <GapChar@plt>
mov    %eax,(%rbx,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r14
je     1201 <ReadAmino+0xa1>
mov    %r15,%rdi
call   1030 <gchar@plt>
movsbl %al,%r12d
mov    %r12d,%edi
call   1080 <ToAmino@plt>
cmp    $0xffffffff,%eax
jne    11c3 <ReadAmino+0x63>
test   %r13d,%r13d
jne    11a0 <ReadAmino+0x40>
lea    0xeab(%rip),%rdi
mov    (%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a0 <ReadAmino+0x40>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xde6(%rip),%rdi
lea    0xdf5(%rip),%rsi
mov    $0x59d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Out of Memory! %s:%d\0A\00"
@.str.1 = [137 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/data.c\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [59 x i8] c"# Warning: Found unrecognised nucleotide in sequence %s: \00"
@.str.3 = [8 x i8] c"%c(%d) \00"
define i32* @ReadAmino(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = call i32* @calloc(i64 %13, i32 4)
store i32* %14, i32** %7
%15 = load i32*, i32** %7
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 1437)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %3
store i32 0, i32* %11
store i32 0, i32* %9
br label %22
22: ; preds = %51, %21
%23 = load i32, i32* %9
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %54
26: ; preds = %22
%27 = load i32*, i32** %4
%28 = call signext i8 @gchar(i32* %27)
store i8 %28, i8* %8
%29 = load i8, i8* %8
%30 = call i32 @ToAmino(i8 signext %29)
store i32 %30, i32* %10
%31 = load i32, i32* %10
%32 = icmp eq i32 -1, %31
br i1 %32, label %33, label %45
33: ; preds = %26
%34 = load i32, i32* %11
%35 = icmp eq i32 0, %34
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i8*, i8** %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i8* %37)
store i32 1, i32* %11
br label %39
39: ; preds = %36, %33
%40 = load i8, i8* %8
%41 = sext i8 %40 to i32
%42 = load i32, i32* %9
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %42)
%44 = call i32 @GapChar(i32 1)
store i32 %44, i32* %10
br label %45
45: ; preds = %39, %26
%46 = load i32, i32* %10
%47 = load i32*, i32** %7
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %47, i64 %49
store i32 %46, i32* %50
br label %51
51: ; preds = %45
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %22
54: ; preds = %22
%55 = load i32*, i32** %7
ret i32* %55
}

LLVM IR (-O2):
@.str = [22 x i8] c"Out of Memory! %s:%d\0A\00"
@.str.1 = [137 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/data.c\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [59 x i8] c"# Warning: Found unrecognised nucleotide in sequence %s: \00"
@.str.3 = [8 x i8] c"%c(%d) \00"
define i32* @ReadAmino(i32* %0, i32 %1, i8* %2) {
%4 = sext i32 %1 to i64
%5 = tail call i32* @calloc(i64 %4, i32 4)
%6 = icmp eq i32* %5, null
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %36
9: ; preds = %7
%10 = zext i32 %1 to i64
br label %15
11: ; preds = %3
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 1437)
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %9, %30
%16 = phi i64 [ 0, %9 ], [ %34, %30 ]
%17 = phi i32 [ 0, %9 ], [ %32, %30 ]
%18 = tail call signext i8 @gchar(i32* %0)
%19 = tail call i32 @ToAmino(i8 signext %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %30
21: ; preds = %15
%22 = icmp eq i32 %17, 0
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %25
25: ; preds = %23, %21
%26 = sext i8 %18 to i32
%27 = trunc i64 %16 to i32
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 %27)
%29 = tail call i32 @GapChar(i32 1)
br label %30
30: ; preds = %25, %15
%31 = phi i32 [ %29, %25 ], [ %19, %15 ]
%32 = phi i32 [ 1, %25 ], [ %17, %15 ]
%33 = getelementptr inbounds i32, i32* %5, i64 %16
store i32 %31, i32* %33
%34 = add nuw nsw i64 %16, 1
%35 = icmp eq i64 %34, %10
br i1 %35, label %36, label %15
36: ; preds = %30, %7
ret i32* %5
}