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

/* Variables and functions */
char *calloc(size_t, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
char *strchr(char *, char);
size_t strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void lib_choice(char *lname, int nl, char *flstr, int ldnaseq) {
  FILE *fch;
  char line[512], *bp;
  char *chstr[40], *chfile[40];
  char *chtmp, *charr;
  int i, j, k, chlen;
  charr = NULL;
  if (strlen(flstr) > (size_t)0) {
    chlen = 40 * 120;
    if ((chtmp = charr = calloc((size_t)chlen, sizeof(char))) == NULL) {
      fprintf(stderr, "*** ERROR [%s:%d] cannot allocate choice file array\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/uwbmrb/BMRB-API/refs/heads/master/"
              "server/wsgi/bmrbapi/submodules/fasta36/src/lib_sel.c",
              112);
      goto l1;
    }
    chlen--;
    if ((fch = fopen(flstr, "r")) == NULL) {
      fprintf(stderr, "*** ERROR [%s:%d] cannot open choice file: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/uwbmrb/BMRB-API/refs/heads/master/"
              "server/wsgi/bmrbapi/submodules/fasta36/src/lib_sel.c",
              117, flstr);
      goto l1;
    }
    fprintf(stderr, "\n Choose sequence library:\n\n");
    for (i = j = 0; j < 40; i++) {
      if (fgets(line, sizeof(line), fch) == NULL)
        break;
      if (line[0] == ';')
        continue;
      if ((bp = strchr(line, '\n')) != NULL)
        *bp = '\0';
      if ((bp = strchr(line, '$')) == NULL)
        continue;
      *bp++ = '\0';
      if ((*bp++ - '0') != ldnaseq)
        continue;
      if ((k = strlen(line)) > chlen)
        break;
      strncpy(chstr[j] = chtmp, line, chlen);
      chtmp += k + 1;
      chlen -= k + 1;
      if ((k = strlen(bp)) > chlen)
        break;
      strncpy(chfile[j] = chtmp, bp, chlen);
      chtmp += k + 1;
      chlen -= k + 1;
      fprintf(stderr, "    %c: %s\n", *chfile[j++], line);
    }
  l2:
    fprintf(stderr, "\n Enter library filename (e.g. %s), letter (e.g. P)\n",
            (ldnaseq == 0) ? "prot.lib" : "dna.lib");
    fprintf(stderr, " or a %% followed by a list of letters (e.g. %%PN): ");
    fflush(stderr);
    if (fgets(line, sizeof(line), stdin) == NULL)
      exit(0);
    if ((bp = strchr(line, '\n')) != NULL)
      *bp = '\0';
    if (strlen(line) == 0)
      goto l2;
    strncpy(lname, line, nl);
  } else {
  l1:
    fprintf(stderr, " library file name: ");
    fflush(stderr);
    if (fgets(line, sizeof(line), stdin) == NULL)
      exit(0);
    if ((bp = strchr(line, '\n')) != NULL)
      *bp = '\0';
    if (strlen(line) > (size_t)0)
      strncpy(lname, line, nl);
    else
      goto l1;
  }
  if (charr != NULL) {
    fclose(fch);
    free(charr);
  }
}


x86 assembly (clang, -O0):
<lib_choice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movq   $0x0,-0x4d0(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
jbe    15d2 <lib_choice+0x422>
movl   $0x12c0,-0x4e0(%rbp)
movslq -0x4e0(%rbp),%rdi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x4d0(%rbp)
mov    %rax,-0x4c8(%rbp)
cmp    $0x0,%rax
jne    1242 <lib_choice+0x92>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
lea    0xdd6(%rip),%rsi
lea    0xe04(%rip),%rdx
mov    $0x70,%ecx
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15d7 <lib_choice+0x427>
mov    -0x4e0(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4e0(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    129b <lib_choice+0xeb>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%r8
lea    0xe65(%rip),%rsi
lea    0xdab(%rip),%rdx
mov    $0x75,%ecx
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15d7 <lib_choice+0x427>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4d8(%rbp)
movl   $0x0,-0x4d4(%rbp)
cmpl   $0x28,-0x4d8(%rbp)
jge    14ee <lib_choice+0x33e>
lea    -0x230(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x200,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    12f7 <lib_choice+0x147>
jmp    14ee <lib_choice+0x33e>
movsbl -0x230(%rbp),%eax
cmp    $0x3b,%eax
jne    130c <lib_choice+0x15c>
jmp    14da <lib_choice+0x32a>
lea    -0x230(%rbp),%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
mov    %rax,-0x238(%rbp)
cmp    $0x0,%rax
je     1338 <lib_choice+0x188>
mov    -0x238(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x230(%rbp),%rdi
mov    $0x24,%esi
call   1070 <strchr@plt>
mov    %rax,-0x238(%rbp)
cmp    $0x0,%rax
jne    135f <lib_choice+0x1af>
jmp    14da <lib_choice+0x32a>
mov    -0x238(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x238(%rbp)
movb   $0x0,(%rax)
mov    -0x238(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x238(%rbp)
movsbl (%rax),%eax
sub    $0x30,%eax
cmp    -0x1c(%rbp),%eax
je     13a0 <lib_choice+0x1f0>
jmp    14da <lib_choice+0x32a>
lea    -0x230(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x4dc(%rbp)
cmp    -0x4e0(%rbp),%eax
jle    13c3 <lib_choice+0x213>
jmp    14ee <lib_choice+0x33e>
mov    -0x4c8(%rbp),%rdi
movslq -0x4d8(%rbp),%rax
mov    %rdi,-0x380(%rbp,%rax,8)
ff
lea    -0x230(%rbp),%rsi
mov    -0x4e0(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x4dc(%rbp),%ecx
add    $0x1,%ecx
mov    -0x4c8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x4c8(%rbp)
mov    -0x4dc(%rbp),%ecx
add    $0x1,%ecx
mov    -0x4e0(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4e0(%rbp)
mov    -0x238(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x4dc(%rbp)
cmp    -0x4e0(%rbp),%eax
jle    1442 <lib_choice+0x292>
jmp    14ee <lib_choice+0x33e>
mov    -0x4c8(%rbp),%rdi
movslq -0x4d8(%rbp),%rax
mov    %rdi,-0x4c0(%rbp,%rax,8)
ff
mov    -0x238(%rbp),%rsi
mov    -0x4e0(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x4dc(%rbp),%ecx
add    $0x1,%ecx
mov    -0x4c8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x4c8(%rbp)
mov    -0x4dc(%rbp),%ecx
add    $0x1,%ecx
mov    -0x4e0(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4e0(%rbp)
mov    0x2b33(%rip),%rax
mov    (%rax),%edi
mov    -0x4d8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x4d8(%rbp)
cltq
mov    -0x4c0(%rbp,%rax,8),%rax
ff
movsbl (%rax),%edx
lea    -0x230(%rbp),%rcx
lea    0xc61(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x4d4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4d4(%rbp)
jmp    12c6 <lib_choice+0x116>
jmp    14f3 <lib_choice+0x343>
mov    0x2ade(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%ecx
lea    0xc78(%rip),%rdx
lea    0xc68(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rdx
lea    0xc25(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2aaf(%rip),%rax
mov    (%rax),%edi
lea    0xc54(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2a98(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
lea    -0x230(%rbp),%rdi
mov    0x2a93(%rip),%rax
mov    (%rax),%rdx
mov    $0x200,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    1573 <lib_choice+0x3c3>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    -0x230(%rbp),%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
mov    %rax,-0x238(%rbp)
cmp    $0x0,%rax
je     159f <lib_choice+0x3ef>
mov    -0x238(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x230(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
jne    15ba <lib_choice+0x40a>
jmp    14f3 <lib_choice+0x343>
mov    -0x8(%rbp),%rdi
lea    -0x230(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <strncpy@plt>
jmp    168c <lib_choice+0x4dc>
jmp    15d7 <lib_choice+0x427>
mov    0x29fa(%rip),%rax
mov    (%rax),%edi
lea    0xbd4(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x29e3(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
lea    -0x230(%rbp),%rdi
mov    0x29de(%rip),%rax
mov    (%rax),%rdx
mov    $0x200,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    1628 <lib_choice+0x478>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    -0x230(%rbp),%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
mov    %rax,-0x238(%rbp)
cmp    $0x0,%rax
je     1654 <lib_choice+0x4a4>
mov    -0x238(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x230(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
jbe    1682 <lib_choice+0x4d2>
mov    -0x8(%rbp),%rdi
lea    -0x230(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <strncpy@plt>
jmp    1687 <lib_choice+0x4d7>
jmp    15d7 <lib_choice+0x427>
jmp    168c <lib_choice+0x4dc>
cmpq   $0x0,-0x4d0(%rbp)
je     16af <lib_choice+0x4ff>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x4d0(%rbp),%rdi
call   1030 <free@plt>
add    $0x4e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lib_choice>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    %ecx,(%rsp)
mov    %esi,%r12d
mov    %rdi,%r13
cmpb   $0x0,(%rdx)
je     136b <lib_choice+0x1bb>
mov    %rdx,%rbx
mov    $0x12c0,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
test   %rax,%rax
je     1455 <lib_choice+0x2a5>
mov    %rax,%rbp
lea    0xeee(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
mov    0x2dd1(%rip),%r15
mov    (%r15),%edi
mov    %rax,%rcx
mov    %rax,0x8(%rsp)
test   %rax,%rax
mov    %rbp,0x18(%rsp)
je     1481 <lib_choice+0x2d1>
mov    %r13,0x28(%rsp)
mov    %r12d,0x24(%rsp)
lea    0xee6(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x12bf,%r14d
movl   $0x0,0x4(%rsp)
mov    %rbp,0x10(%rsp)
mov    0x8(%rsp),%rbp
jmp    126b <lib_choice+0xbb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpl   $0x28,0x4(%rsp)
jge    1377 <lib_choice+0x1c7>
lea    0x30(%rsp),%rdi
mov    $0x200,%esi
mov    %rbp,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1377 <lib_choice+0x1c7>
cmpb   $0x3b,0x30(%rsp)
je     1260 <lib_choice+0xb0>
lea    0x30(%rsp),%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     12a4 <lib_choice+0xf4>
movb   $0x0,(%rax)
lea    0x30(%rsp),%rdi
mov    $0x24,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1260 <lib_choice+0xb0>
mov    %rax,%rbx
movb   $0x0,(%rax)
movsbl 0x1(%rax),%eax
add    $0xffffffd0,%eax
cmp    (%rsp),%eax
jne    1260 <lib_choice+0xb0>
lea    0x30(%rsp),%rdi
call   1060 <strlen@plt>
mov    %rax,%r13
cmp    %r13d,%r14d
jl     1377 <lib_choice+0x1c7>
add    $0x2,%rbx
mov    0x10(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    %r14d,%edx
call   1040 <strncpy@plt>
mov    %r13d,%r12d
not    %r12d
add    %r14d,%r12d
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rax,%r14
cmp    %r14d,%r12d
jl     1377 <lib_choice+0x1c7>
movslq %r13d,%rax
mov    0x10(%rsp),%rcx
lea    (%rax,%rcx,1),%rbp
add    $0x1,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1040 <strncpy@plt>
movslq %r14d,%rax
add    %rbp,%rax
add    $0x1,%rax
mov    %rax,0x10(%rsp)
not    %r14d
add    %r12d,%r14d
mov    (%r15),%edi
addl   $0x1,0x4(%rsp)
movsbl 0x0(%rbp),%edx
mov    0x8(%rsp),%rbp
lea    0xdda(%rip),%rsi
lea    0x30(%rsp),%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1260 <lib_choice+0xb0>
xor    %eax,%eax
mov    %rax,0x18(%rsp)
jmp    149e <lib_choice+0x2ee>
cmpl   $0x0,(%rsp)
lea    0xdf3(%rip),%rax
lea    0xdf5(%rip),%rbp
cmove  %rax,%rbp
lea    0xdac(%rip),%r14
lea    0xdeb(%rip),%r12
mov    0x2c46(%rip),%r13
lea    0x30(%rsp),%rbx
jmp    13b7 <lib_choice+0x207>
nopl   0x0(%rax)
cmpb   $0x0,0x30(%rsp)
jne    140d <lib_choice+0x25d>
mov    (%r15),%edi
mov    %r14,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%r15),%edi
mov    %r12,%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%r15),%edi
call   10b0 <fflush@plt>
mov    0x0(%r13),%rdx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     151a <lib_choice+0x36a>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     13b0 <lib_choice+0x200>
movb   $0x0,(%rax)
jmp    13b0 <lib_choice+0x200>
mov    0x24(%rsp),%r12d
mov    0x28(%rsp),%r13
lea    0x30(%rsp),%rsi
mov    %r13,%rdi
mov    %r12d,%edx
call   1040 <strncpy@plt>
mov    0x18(%rsp),%rbx
test   %rbx,%rbx
mov    0x8(%rsp),%rdi
je     1443 <lib_choice+0x293>
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b7c(%rip),%rax
mov    (%rax),%edi
lea    0xb9b(%rip),%rsi
lea    0xbc9(%rip),%rdx
xor    %eax,%eax
mov    %rax,0x18(%rsp)
mov    $0x70,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    149e <lib_choice+0x2ee>
lea    0xc60(%rip),%rsi
lea    0xba6(%rip),%rdx
mov    $0x75,%ecx
mov    %rbx,%r8
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2b33(%rip),%rbx
lea    0xd0f(%rip),%r14
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    0x2b2e(%rip),%r15
lea    0x30(%rsp),%rbp
jmp    14db <lib_choice+0x32b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,0x30(%rsp)
jne    1417 <lib_choice+0x267>
mov    (%rbx),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
call   10b0 <fflush@plt>
mov    (%r15),%rdx
mov    %rbp,%rdi
mov    $0x200,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     151a <lib_choice+0x36a>
mov    %rbp,%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     14d0 <lib_choice+0x320>
movb   $0x0,(%rax)
jmp    14d0 <lib_choice+0x320>
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [53 x i8] c"*** ERROR [%s:%d] cannot allocate choice file array\0A\00"
@.str.1 = [177 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/uwbmrb/BMRB-API/refs/heads/master/server/wsgi/bmrbapi/submodules/fasta36/src/lib_sel.c\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [47 x i8] c"*** ERROR [%s:%d] cannot open choice file: %s\0A\00"
@.str.4 = [29 x i8] c"\0A Choose sequence library:\0A\0A\00"
@.str.5 = [12 x i8] c" %c: %s\0A\00"
@.str.6 = [53 x i8] c"\0A Enter library filename (e.g. %s), letter (e.g. P)\0A\00"
@.str.7 = [9 x i8] c"prot.lib\00"
@.str.8 = [8 x i8] c"dna.lib\00"
@.str.9 = [53 x i8] c" or a %% followed by a list of letters (e.g. %%PN): \00"
@stdin = global i32* null
@.str.10 = [21 x i8] c" library file name: \00"
define void @lib_choice(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca [512 x i8]
%11 = alloca i8*
%12 = alloca [40 x i8*]
%13 = alloca [40 x i8*]
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
store i8* null, i8** %15
%20 = load i8*, i8** %7
%21 = call i64 @strlen(i8* %20)
%22 = icmp ugt i64 %21, 0
br i1 %22, label %23, label %175
23: ; preds = %4
store i32 4800, i32* %19
%24 = load i32, i32* %19
%25 = sext i32 %24 to i64
%26 = call i8* @calloc(i64 %25, i32 1)
store i8* %26, i8** %15
store i8* %26, i8** %14
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str.1, i64 0, i64 0), i32 112)
br label %176
31: ; preds = %23
%32 = load i32, i32* %19
%33 = add nsw i32 %32, -1
store i32 %33, i32* %19
%34 = load i8*, i8** %7
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %35, i32** %9
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %41
37: ; preds = %31
%38 = load i32, i32* @stderr
%39 = load i8*, i8** %7
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str.1, i64 0, i64 0), i32 117, i8* %39)
br label %176
41: ; preds = %31
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %17
store i32 0, i32* %16
br label %44
44: ; preds = %138, %41
%45 = load i32, i32* %17
%46 = icmp slt i32 %45, 40
br i1 %46, label %47, label %141
47: ; preds = %44
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%49 = load i32*, i32** %9
%50 = call i32* @fgets(i8* %48, i32 512, i32* %49)
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %53
52: ; preds = %47
br label %141
53: ; preds = %47
%54 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 59
br i1 %57, label %58, label %59
58: ; preds = %53
br label %138
59: ; preds = %53
%60 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%61 = call i8* @strchr(i8* %60, i8 signext 10)
store i8* %61, i8** %11
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %65
63: ; preds = %59
%64 = load i8*, i8** %11
store i8 0, i8* %64
br label %65
65: ; preds = %63, %59
%66 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%67 = call i8* @strchr(i8* %66, i8 signext 36)
store i8* %67, i8** %11
%68 = icmp eq i8* %67, null
br i1 %68, label %69, label %70
69: ; preds = %65
br label %138
70: ; preds = %65
%71 = load i8*, i8** %11
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %11
store i8 0, i8* %71
%73 = load i8*, i8** %11
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %11
%75 = load i8, i8* %73
%76 = sext i8 %75 to i32
%77 = sub nsw i32 %76, 48
%78 = load i32, i32* %8
%79 = icmp ne i32 %77, %78
br i1 %79, label %80, label %81
80: ; preds = %70
br label %138
81: ; preds = %70
%82 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%83 = call i64 @strlen(i8* %82)
%84 = trunc i64 %83 to i32
store i32 %84, i32* %18
%85 = load i32, i32* %19
%86 = icmp sgt i32 %84, %85
br i1 %86, label %87, label %88
87: ; preds = %81
br label %141
88: ; preds = %81
%89 = load i8*, i8** %14
%90 = load i32, i32* %17
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [40 x i8*], [40 x i8*]* %12, i64 0, i64 %91
store i8* %89, i8** %92
%93 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%94 = load i32, i32* %19
%95 = call i32 @strncpy(i8* %89, i8* %93, i32 %94)
%96 = load i32, i32* %18
%97 = add nsw i32 %96, 1
%98 = load i8*, i8** %14
%99 = sext i32 %97 to i64
%100 = getelementptr inbounds i8, i8* %98, i64 %99
store i8* %100, i8** %14
%101 = load i32, i32* %18
%102 = add nsw i32 %101, 1
%103 = load i32, i32* %19
%104 = sub nsw i32 %103, %102
store i32 %104, i32* %19
%105 = load i8*, i8** %11
%106 = call i64 @strlen(i8* %105)
%107 = trunc i64 %106 to i32
store i32 %107, i32* %18
%108 = load i32, i32* %19
%109 = icmp sgt i32 %107, %108
br i1 %109, label %110, label %111
110: ; preds = %88
br label %141
111: ; preds = %88
%112 = load i8*, i8** %14
%113 = load i32, i32* %17
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [40 x i8*], [40 x i8*]* %13, i64 0, i64 %114
store i8* %112, i8** %115
%116 = load i8*, i8** %11
%117 = load i32, i32* %19
%118 = call i32 @strncpy(i8* %112, i8* %116, i32 %117)
%119 = load i32, i32* %18
%120 = add nsw i32 %119, 1
%121 = load i8*, i8** %14
%122 = sext i32 %120 to i64
%123 = getelementptr inbounds i8, i8* %121, i64 %122
store i8* %123, i8** %14
%124 = load i32, i32* %18
%125 = add nsw i32 %124, 1
%126 = load i32, i32* %19
%127 = sub nsw i32 %126, %125
store i32 %127, i32* %19
%128 = load i32, i32* @stderr
%129 = load i32, i32* %17
%130 = add nsw i32 %129, 1
store i32 %130, i32* %17
%131 = sext i32 %129 to i64
%132 = getelementptr inbounds [40 x i8*], [40 x i8*]* %13, i64 0, i64 %131
%133 = load i8*, i8** %132
%134 = load i8, i8* %133
%135 = sext i8 %134 to i32
%136 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%137 = call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %135, i8* %136)
br label %138
138: ; preds = %111, %80, %69, %58
%139 = load i32, i32* %16
%140 = add nsw i32 %139, 1
store i32 %140, i32* %16
br label %44
141: ; preds = %110, %87, %52, %44
br label %142
142: ; preds = %169, %141
%143 = load i32, i32* @stderr
%144 = load i32, i32* %8
%145 = icmp eq i32 %144, 0
%146 = zext i1 %145 to i64
%147 = select i1 %145, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0)
%148 = call i32 (i32, i8*, ...) @fprintf(i32 %143, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i8* %147)
%149 = load i32, i32* @stderr
%150 = call i32 (i32, i8*, ...) @fprintf(i32 %149, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0))
%151 = load i32, i32* @stderr
%152 = call i32 @fflush(i32 %151)
%153 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%154 = load i32*, i32** @stdin
%155 = call i32* @fgets(i8* %153, i32 512, i32* %154)
%156 = icmp eq i32* %155, null
br i1 %156, label %157, label %159
157: ; preds = %142
%158 = call i32 @exit(i32 0)
unreachable
159: ; preds = %142
%160 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%161 = call i8* @strchr(i8* %160, i8 signext 10)
store i8* %161, i8** %11
%162 = icmp ne i8* %161, null
br i1 %162, label %163, label %165
163: ; preds = %159
%164 = load i8*, i8** %11
store i8 0, i8* %164
br label %165
165: ; preds = %163, %159
%166 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%167 = call i64 @strlen(i8* %166)
%168 = icmp eq i64 %167, 0
br i1 %168, label %169, label %170
169: ; preds = %165
br label %142
170: ; preds = %165
%171 = load i8*, i8** %5
%172 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%173 = load i32, i32* %6
%174 = call i32 @strncpy(i8* %171, i8* %172, i32 %173)
br label %204
175: ; preds = %4
br label %176
176: ; preds = %202, %175, %37, %28
%177 = load i32, i32* @stderr
%178 = call i32 (i32, i8*, ...) @fprintf(i32 %177, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%179 = load i32, i32* @stderr
%180 = call i32 @fflush(i32 %179)
%181 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%182 = load i32*, i32** @stdin
%183 = call i32* @fgets(i8* %181, i32 512, i32* %182)
%184 = icmp eq i32* %183, null
br i1 %184, label %185, label %187
185: ; preds = %176
%186 = call i32 @exit(i32 0)
unreachable
187: ; preds = %176
%188 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%189 = call i8* @strchr(i8* %188, i8 signext 10)
store i8* %189, i8** %11
%190 = icmp ne i8* %189, null
br i1 %190, label %191, label %193
191: ; preds = %187
%192 = load i8*, i8** %11
store i8 0, i8* %192
br label %193
193: ; preds = %191, %187
%194 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%195 = call i64 @strlen(i8* %194)
%196 = icmp ugt i64 %195, 0
br i1 %196, label %197, label %202
197: ; preds = %193
%198 = load i8*, i8** %5
%199 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%200 = load i32, i32* %6
%201 = call i32 @strncpy(i8* %198, i8* %199, i32 %200)
br label %203
202: ; preds = %193
br label %176
203: ; preds = %197
br label %204
204: ; preds = %203, %170
%205 = load i8*, i8** %15
%206 = icmp ne i8* %205, null
br i1 %206, label %207, label %212
207: ; preds = %204
%208 = load i32*, i32** %9
%209 = call i32 @fclose(i32* %208)
%210 = load i8*, i8** %15
%211 = call i32 @free(i8* %210)
br label %212
212: ; preds = %207, %204
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [53 x i8] c"*** ERROR [%s:%d] cannot allocate choice file array\0A\00"
@.str.1 = [177 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/uwbmrb/BMRB-API/refs/heads/master/server/wsgi/bmrbapi/submodules/fasta36/src/lib_sel.c\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [47 x i8] c"*** ERROR [%s:%d] cannot open choice file: %s\0A\00"
@.str.4 = [29 x i8] c"\0A Choose sequence library:\0A\0A\00"
@.str.5 = [12 x i8] c" %c: %s\0A\00"
@.str.6 = [53 x i8] c"\0A Enter library filename (e.g. %s), letter (e.g. P)\0A\00"
@.str.7 = [9 x i8] c"prot.lib\00"
@.str.8 = [8 x i8] c"dna.lib\00"
@.str.9 = [53 x i8] c" or a %% followed by a list of letters (e.g. %%PN): \00"
@stdin = global i32* null
@.str.10 = [21 x i8] c" library file name: \00"
define void @lib_choice(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca [512 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %14, %21, %4
%10 = phi i8* [ null, %4 ], [ %12, %21 ], [ null, %14 ]
br label %99
11: ; preds = %4
%12 = tail call i8* @calloc(i64 4800, i32 1)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str.1, i64 0, i64 0), i32 112)
br label %9
17: ; preds = %11
%18 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32* %18, null
%20 = load i32, i32* @stderr
br i1 %19, label %21, label %23
21: ; preds = %17
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str.1, i64 0, i64 0), i32 117, i8* %2)
br label %9
23: ; preds = %17
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %23, %72
%26 = phi i32 [ 4799, %23 ], [ %75, %72 ]
%27 = phi i32 [ 0, %23 ], [ %74, %72 ]
%28 = phi i8* [ %12, %23 ], [ %73, %72 ]
%29 = call i32* @fgets(i8* %6, i32 512, i32* %18)
%30 = icmp eq i32* %29, null
br i1 %30, label %77, label %31
31: ; preds = %25
%32 = load i8, i8* %6
%33 = icmp eq i8 %32, 59
br i1 %33, label %72, label %34
34: ; preds = %31
%35 = call i8* @strchr(i8* %6, i8 signext 10)
%36 = icmp eq i8* %35, null
br i1 %36, label %38, label %37
37: ; preds = %34
store i8 0, i8* %35
br label %38
38: ; preds = %37, %34
%39 = call i8* @strchr(i8* %6, i8 signext 36)
%40 = icmp eq i8* %39, null
br i1 %40, label %72, label %41
41: ; preds = %38
%42 = getelementptr inbounds i8, i8* %39, i64 1
store i8 0, i8* %39
%43 = getelementptr inbounds i8, i8* %39, i64 2
%44 = load i8, i8* %42
%45 = sext i8 %44 to i32
%46 = add nsw i32 %45, -48
%47 = icmp eq i32 %46, %3
br i1 %47, label %48, label %72
48: ; preds = %41
%49 = call i64 @strlen(i8* %6)
%50 = trunc i64 %49 to i32
%51 = icmp slt i32 %26, %50
br i1 %51, label %77, label %52
52: ; preds = %48
%53 = call i32 @strncpy(i8* %28, i8* %6, i32 %26)
%54 = add nsw i32 %50, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %28, i64 %55
%57 = sub nsw i32 %26, %54
%58 = call i64 @strlen(i8* %43)
%59 = trunc i64 %58 to i32
%60 = icmp slt i32 %57, %59
br i1 %60, label %77, label %61
61: ; preds = %52
%62 = call i32 @strncpy(i8* %56, i8* %43, i32 %57)
%63 = add nsw i32 %59, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %56, i64 %64
%66 = sub nsw i32 %57, %63
%67 = load i32, i32* @stderr
%68 = add nsw i32 %27, 1
%69 = load i8, i8* %56
%70 = sext i8 %69 to i32
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %70, i8* %6)
br label %72
72: ; preds = %41, %38, %31, %61
%73 = phi i8* [ %28, %31 ], [ %28, %38 ], [ %28, %41 ], [ %65, %61 ]
%74 = phi i32 [ %27, %31 ], [ %27, %38 ], [ %27, %41 ], [ %68, %61 ]
%75 = phi i32 [ %26, %31 ], [ %26, %38 ], [ %26, %41 ], [ %66, %61 ]
%76 = icmp slt i32 %74, 40
br i1 %76, label %25, label %77
77: ; preds = %52, %48, %25, %72
%78 = icmp eq i32 %3, 0
%79 = select i1 %78, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0)
br label %80
80: ; preds = %96, %77
%81 = load i32, i32* @stderr
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), i8* %79)
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0))
%85 = load i32, i32* @stderr
%86 = call i32 @fflush(i32 %85)
%87 = load i32*, i32** @stdin
%88 = call i32* @fgets(i8* %6, i32 512, i32* %87)
%89 = icmp eq i32* %88, null
br i1 %89, label %90, label %92
90: ; preds = %80
%91 = call i32 @exit(i32 0)
unreachable
92: ; preds = %80
%93 = call i8* @strchr(i8* %6, i8 signext 10)
%94 = icmp eq i8* %93, null
br i1 %94, label %96, label %95
95: ; preds = %92
store i8 0, i8* %93
br label %96
96: ; preds = %95, %92
%97 = load i8, i8* %6
%98 = icmp eq i8 %97, 0
br i1 %98, label %80, label %116
99: ; preds = %9, %113
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%102 = load i32, i32* @stderr
%103 = call i32 @fflush(i32 %102)
%104 = load i32*, i32** @stdin
%105 = call i32* @fgets(i8* %6, i32 512, i32* %104)
%106 = icmp eq i32* %105, null
br i1 %106, label %107, label %109
107: ; preds = %99
%108 = call i32 @exit(i32 0)
unreachable
109: ; preds = %99
%110 = call i8* @strchr(i8* %6, i8 signext 10)
%111 = icmp eq i8* %110, null
br i1 %111, label %113, label %112
112: ; preds = %109
store i8 0, i8* %110
br label %113
113: ; preds = %112, %109
%114 = load i8, i8* %6
%115 = icmp eq i8 %114, 0
br i1 %115, label %99, label %116
116: ; preds = %96, %113
%117 = phi i32* [ null, %113 ], [ %18, %96 ]
%118 = phi i8* [ %10, %113 ], [ %12, %96 ]
%119 = call i32 @strncpy(i8* %0, i8* %6, i32 %1)
%120 = icmp eq i8* %118, null
br i1 %120, label %124, label %121
121: ; preds = %116
%122 = call i32 @fclose(i32* %117)
%123 = call i32 @free(i8* %118)
br label %124
124: ; preds = %121, %116
ret void
}