#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 /*<<< orphan*/);
int ToNucleo(char);
int *calloc(size_t, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
char gchar(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int *ReadNucleo(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",
           1405);
    exit(EXIT_FAILURE);
  };
  bool has_ambig_nuc = false;
  for (i = 0; i < n_pts; i++) {
    c = gchar(fp);
    j = ToNucleo(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(0);
    }
    seq[i] = j;
  }
  if (has_ambig_nuc) {
    fputc('\n', stdout);
  }
  return seq;
}


x86 assembly (clang, -O0):
<ReadNucleo>:
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   1070 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c8 <ReadNucleo+0x58>
lea    0xe59(%rip),%rdi
lea    0xe68(%rip),%rsi
mov    $0x57d,%edx
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1267 <ReadNucleo+0xf7>
mov    -0x8(%rbp),%rdi
call   1030 <gchar@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%edi
call   1040 <ToNucleo@plt>
mov    %eax,-0x2c(%rbp)
mov    $0xffffffff,%eax
cmp    -0x2c(%rbp),%eax
jne    124b <ReadNucleo+0xdb>
xor    %eax,%eax
cmp    -0x30(%rbp),%eax
jne    122c <ReadNucleo+0xbc>
mov    -0x18(%rbp),%rsi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x30(%rbp)
movsbl -0x21(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <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    11d6 <ReadNucleo+0x66>
cmpl   $0x0,-0x30(%rbp)
je     1284 <ReadNucleo+0x114>
mov    0x2d60(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1060 <fputc@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadNucleo>:
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   1070 <calloc@plt>
test   %rax,%rax
je     1238 <ReadNucleo+0xc8>
mov    %rax,%rbx
test   %ebp,%ebp
jle    1226 <ReadNucleo+0xb6>
mov    %ebp,%r14d
xor    %ebp,%ebp
xor    %r13d,%r13d
jmp    11dc <ReadNucleo+0x6c>
nop
lea    0xf23(%rip),%rdi
mov    %r12d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <GapChar@plt>
mov    $0x1,%r13d
mov    %eax,(%rbx,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r14
je     120e <ReadNucleo+0x9e>
mov    %r15,%rdi
call   1030 <gchar@plt>
movsbl %al,%r12d
mov    %r12d,%edi
call   1040 <ToNucleo@plt>
cmp    $0xffffffff,%eax
jne    11d0 <ReadNucleo+0x60>
test   %r13d,%r13d
jne    11b0 <ReadNucleo+0x40>
lea    0xe9e(%rip),%rdi
mov    (%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b0 <ReadNucleo+0x40>
test   %r13d,%r13d
je     1226 <ReadNucleo+0xb6>
mov    0x2dbe(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1060 <fputc@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdc1(%rip),%rdi
lea    0xdd0(%rip),%rsi
mov    $0x57d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
call   1090 <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"
@stdout = global i32 0
define i32* @ReadNucleo(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 1405)
%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 @ToNucleo(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 0)
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* %11
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i32, i32* @stdout
%59 = call i32 @fputc(i8 signext 10, i32 %58)
br label %60
60: ; preds = %57, %54
%61 = load i32*, i32** %7
ret i32* %61
}

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"
@stdout = global i32 0
define i32* @ReadNucleo(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 %41
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 1405)
%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 @ToNucleo(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 0)
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
%37 = icmp eq i32 %32, 0
br i1 %37, label %41, label %38
38: ; preds = %36
%39 = load i32, i32* @stdout
%40 = tail call i32 @fputc(i8 signext 10, i32 %39)
br label %41
41: ; preds = %7, %38, %36
ret i32* %5
}