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

/* Variables and functions */
char *calloc(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, ...);
char *getenv(char *);
int /*<<< orphan*/ mktemp(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int system(char *);
char *build_lib_db(char *script_file) {
  int i, status;
  char tmp_line[32];
  char *lib_db_file, *lib_db_str;
  char lib_db_script[4096];
  int lib_db_indirect;
  int lib_db_type;
  int lib_db_str_len;
  char *bp, *lib_bp;
  if ((lib_db_file = (char *)calloc(512, sizeof(char))) == NULL) {
    fprintf(stderr,
            "*** ERROR [%s:%d] - [build_lib_db] Cannot allocate lib_db_file",
            "/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/compacc2e.c",
            1571);
    goto no_lib;
  }
  if ((bp = getenv("TMP_DIR")) != NULL) {
    strncpy(lib_db_file, bp, 512);
    lib_db_file[sizeof(lib_db_file) - 1] = '\0';
    strncat(lib_db_file, "/", sizeof(lib_db_file) - strlen(lib_db_file) - 1);
  }
  strncat(lib_db_file, "lib_db_XXXXXX", 512 - strlen(lib_db_file) - 1);
  mktemp(lib_db_file);
  lib_db_str_len = strlen(lib_db_file) + 1;
  lib_bp = script_file;
  if (*lib_bp == '@') {
    lib_bp++;
    lib_db_str_len++;
  }
  if ((bp = strchr(lib_bp, ' ')) != NULL) {
    *bp = '\0';
    sscanf(bp + 1, "%d", &lib_db_type);
    lib_db_str_len += (strlen(bp + 1) + 1);
  } else {
    lib_db_type = 0;
  }
  strncpy(lib_db_script, lib_bp, sizeof(lib_db_script));
  bp = strchr(lib_db_script, '+');
  for (; bp; bp = strchr(bp + 1, '+')) {
    *bp = ' ';
  }
  lib_db_script[sizeof(lib_db_script) - 1] = '\0';
  strncat(lib_db_script, " >",
          sizeof(lib_db_script) - strlen(lib_db_script) - 1);
  strncat(lib_db_script, lib_db_file,
          sizeof(lib_db_script) - strlen(lib_db_script) - 1);
  if (bp != NULL)
    *bp = ' ';
  status = system(lib_db_script);
  if (status == 4) {
    goto no_lib;
  }
  if (status < 0 || status == 127) {
    fprintf(stderr, "*** ERROR [%s:%d] - [build_lib_db] script: %s failed\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/compacc2e.c",
            1622, lib_db_script);
    goto no_lib;
  }
  if ((lib_db_str = calloc(lib_db_str_len + 1, sizeof(char))) == NULL) {
    fprintf(
        stderr,
        "*** ERROR [%s:%d] - [build_lib_db] cannot allocate lib_db_str[%d]\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/compacc2e.c",
        1629, lib_db_str_len + 1);
    goto no_lib;
  }
  lib_db_str[0] = '\0';
  if (*script_file == '@') {
    strncat(lib_db_str, "@", 512 - strlen(lib_db_str) - 1);
  }
  strncat(lib_db_str, lib_db_file, 512 - strlen(lib_db_str) - 1);
  if (lib_db_type > 0) {
    sprintf(tmp_line, " %d", lib_db_type);
    strncat(lib_db_str, tmp_line, 512 - strlen(lib_db_str) - 1);
  }
  return lib_db_str;
no_lib:
  return NULL;
}


x86 assembly (clang, -O0):
<build_lib_db>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10c0,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x200,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1204 <build_lib_db+0x54>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
lea    0xe4c(%rip),%rdx
mov    $0x623,%ecx
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    162a <build_lib_db+0x47a>
lea    0xee7(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x1068(%rbp)
cmp    $0x0,%rax
je     1276 <build_lib_db+0xc6>
mov    -0x48(%rbp),%rdi
mov    -0x1068(%rbp),%rsi
mov    $0x200,%edx
call   1040 <strncpy@plt>
mov    -0x48(%rbp),%rax
movb   $0x0,0x7(%rax)
mov    -0x48(%rbp),%rax
mov    %rax,-0x1078(%rbp)
mov    -0x48(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x1078(%rbp),%rdi
movslq %eax,%rcx
mov    $0x8,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
lea    0xe89(%rip),%rsi
call   1080 <strncat@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x1080(%rbp)
mov    -0x48(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x1080(%rbp),%rdi
mov    $0x200,%edx
sub    %eax,%edx
sub    $0x1,%edx
lea    0xe5a(%rip),%rsi
call   1080 <strncat@plt>
mov    -0x48(%rbp),%rdi
call   10d0 <mktemp@plt>
mov    -0x48(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x105c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x1070(%rbp)
mov    -0x1070(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x40,%eax
jne    1301 <build_lib_db+0x151>
mov    -0x1070(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1070(%rbp)
mov    -0x105c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x105c(%rbp)
mov    -0x1070(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,-0x1068(%rbp)
cmp    $0x0,%rax
je     136f <build_lib_db+0x1bf>
mov    -0x1068(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x1068(%rbp),%rdi
add    $0x1,%rdi
lea    0xe4a(%rip),%rsi
lea    -0x1058(%rbp),%rdx
call   10b0 <sscanf@plt>
mov    -0x1068(%rbp),%rdi
add    $0x1,%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
add    -0x105c(%rbp),%eax
mov    %eax,-0x105c(%rbp)
jmp    1379 <build_lib_db+0x1c9>
movl   $0x0,-0x1058(%rbp)
lea    -0x1050(%rbp),%rdi
mov    -0x1070(%rbp),%rsi
mov    $0x1000,%edx
call   1040 <strncpy@plt>
lea    -0x1050(%rbp),%rdi
mov    $0x2b,%esi
call   1070 <strchr@plt>
mov    %rax,-0x1068(%rbp)
cmpq   $0x0,-0x1068(%rbp)
je     13e2 <build_lib_db+0x232>
mov    -0x1068(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x1068(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2b,%esi
call   1070 <strchr@plt>
mov    %rax,-0x1068(%rbp)
jmp    13a9 <build_lib_db+0x1f9>
movb   $0x0,-0x51(%rbp)
lea    -0x1050(%rbp),%rax
mov    %rax,-0x1098(%rbp)
lea    -0x1050(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x1098(%rbp),%rdi
movslq %eax,%rcx
mov    $0x1000,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
lea    0xceb(%rip),%rsi
call   1080 <strncat@plt>
lea    -0x1050(%rbp),%rax
mov    %rax,-0x1090(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x1088(%rbp)
lea    -0x1050(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x1090(%rbp),%rdi
mov    -0x1088(%rbp),%rsi
movslq %eax,%rcx
mov    $0x1000,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
call   1080 <strncat@plt>
cmpq   $0x0,-0x1068(%rbp)
je     1485 <build_lib_db+0x2d5>
mov    -0x1068(%rbp),%rax
movb   $0x20,(%rax)
lea    -0x1050(%rbp),%rdi
call   1060 <system@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jne    14a3 <build_lib_db+0x2f3>
jmp    162a <build_lib_db+0x47a>
cmpl   $0x0,-0x18(%rbp)
jl     14b7 <build_lib_db+0x307>
cmpl   $0x7f,-0x18(%rbp)
jne    14e6 <build_lib_db+0x336>
mov    0x2b22(%rip),%rax
mov    (%rax),%edi
lea    -0x1050(%rbp),%r8
lea    0xc3f(%rip),%rsi
lea    0xb6a(%rip),%rdx
mov    $0x656,%ecx
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    162a <build_lib_db+0x47a>
mov    -0x105c(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    153a <build_lib_db+0x38a>
mov    0x2ad2(%rip),%rax
mov    (%rax),%edi
mov    -0x105c(%rbp),%r8d
add    $0x1,%r8d
lea    0xc21(%rip),%rsi
lea    0xb16(%rip),%rdx
mov    $0x65d,%ecx
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    162a <build_lib_db+0x47a>
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x40,%eax
jne    1582 <build_lib_db+0x3d2>
mov    -0x50(%rbp),%rax
mov    %rax,-0x10a0(%rbp)
mov    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x10a0(%rbp),%rdi
mov    $0x200,%edx
sub    %eax,%edx
sub    $0x1,%edx
lea    0xc09(%rip),%rsi
call   1080 <strncat@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x10b0(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x10a8(%rbp)
mov    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x10b0(%rbp),%rdi
mov    -0x10a8(%rbp),%rsi
mov    $0x200,%edx
sub    %eax,%edx
sub    $0x1,%edx
call   1080 <strncat@plt>
cmpl   $0x0,-0x1058(%rbp)
jle    161d <build_lib_db+0x46d>
lea    -0x40(%rbp),%rdi
mov    -0x1058(%rbp),%edx
lea    0xbac(%rip),%rsi
call   10c0 <sprintf@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x10c0(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x10b8(%rbp)
mov    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x10c0(%rbp),%rdi
mov    -0x10b8(%rbp),%rsi
mov    $0x200,%edx
sub    %eax,%edx
sub    $0x1,%edx
call   1080 <strncat@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1632 <build_lib_db+0x482>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_lib_db>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1038,%rsp
mov    %rdi,%r14
mov    $0x200,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
test   %rax,%rax
je     12a8 <build_lib_db+0xf8>
mov    %rax,%r13
lea    0xf0c(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1223 <build_lib_db+0x73>
mov    %r13,%rdi
mov    %rax,%rsi
mov    $0x200,%edx
call   1040 <strncpy@plt>
movb   $0x0,0x7(%r13)
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    $0x7,%edx
sub    %eax,%edx
lea    0xedf(%rip),%rsi
mov    %r13,%rdi
call   1080 <strncat@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    $0x1ff,%edx
sub    %eax,%edx
lea    0xec3(%rip),%rsi
mov    %r13,%rdi
call   1080 <strncat@plt>
mov    %r13,%rdi
call   10d0 <mktemp@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
xor    %r12d,%r12d
cmpb   $0x40,(%r14)
sete   %r12b
lea    (%r12,%rax,1),%r15d
add    $0x1,%r15d
add    %r14,%r12
mov    %r12,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     12d3 <build_lib_db+0x123>
mov    %rax,%rbx
movb   $0x0,(%rax)
add    $0x1,%rbx
lea    0xeff(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   10b0 <sscanf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
add    %eax,%r15d
add    $0x1,%r15d
jmp    12db <build_lib_db+0x12b>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
lea    0xd48(%rip),%rsi
lea    0xd80(%rip),%rdx
xor    %r12d,%r12d
mov    $0x623,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    147a <build_lib_db+0x2ca>
movl   $0x0,0xc(%rsp)
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1000,%edx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2b,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     131b <build_lib_db+0x16b>
movb   $0x20,(%rax)
add    $0x1,%rax
mov    %rax,%rdi
jmp    1300 <build_lib_db+0x150>
movb   $0x0,0x102f(%rsp)
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    $0xfff,%ebp
mov    $0xfff,%edx
sub    %eax,%edx
lea    0xdc7(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strncat@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
sub    %eax,%ebp
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1080 <strncat@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
cmp    $0x4,%eax
jne    1377 <build_lib_db+0x1c7>
xor    %r12d,%r12d
jmp    147a <build_lib_db+0x2ca>
test   %eax,%eax
js     1424 <build_lib_db+0x274>
cmp    $0x7f,%eax
je     1424 <build_lib_db+0x274>
add    $0x1,%r15d
mov    %r15d,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
test   %rax,%rax
je     1451 <build_lib_db+0x2a1>
mov    %rax,%r12
movb   $0x0,(%rax)
cmpb   $0x40,(%r14)
jne    13cc <build_lib_db+0x21c>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    $0x1ff,%edx
sub    %eax,%edx
lea    0xdc2(%rip),%rsi
mov    %r12,%rdi
call   1080 <strncat@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    $0x1ff,%ebx
mov    $0x1ff,%edx
sub    %eax,%edx
mov    %r12,%rdi
mov    %r13,%rsi
call   1080 <strncat@plt>
mov    0xc(%rsp),%edx
test   %edx,%edx
jle    147a <build_lib_db+0x2ca>
lea    0xd8a(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   10c0 <sprintf@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
sub    %eax,%ebx
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1080 <strncat@plt>
jmp    147a <build_lib_db+0x2ca>
mov    0x2bb5(%rip),%rax
mov    (%rax),%edi
lea    0xcd9(%rip),%rsi
lea    0xc04(%rip),%rdx
xor    %r12d,%r12d
lea    0x30(%rsp),%r8
mov    $0x656,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    147a <build_lib_db+0x2ca>
mov    0x2b88(%rip),%rax
mov    (%rax),%edi
lea    0xce2(%rip),%rsi
lea    0xbd7(%rip),%rdx
xor    %r12d,%r12d
mov    $0x65d,%ecx
mov    %r15d,%r8d
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r12,%rax
add    $0x1038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [63 x i8] c"*** ERROR [%s:%d] - [build_lib_db] Cannot allocate lib_db_file\00"
@.str.1 = [179 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/compacc2e.c\00"
@.str.2 = [8 x i8] c"TMP_DIR\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [14 x i8] c"lib_db_XXXXXX\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [3 x i8] c" >\00"
@.str.7 = [54 x i8] c"*** ERROR [%s:%d] - [build_lib_db] script: %s failed\0A\00"
@.str.8 = [67 x i8] c"*** ERROR [%s:%d] - [build_lib_db] cannot allocate lib_db_str[%d]\0A\00"
@.str.9 = [2 x i8] c"@\00"
@.str.10 = [4 x i8] c" %d\00"
define i8* @build_lib_db(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [32 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [4096 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
store i8* %0, i8** %3
%15 = call i8* @calloc(i32 512, i32 1)
store i8* %15, i8** %7
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([179 x i8], [179 x i8]* @.str.1, i64 0, i64 0), i32 1571)
br label %176
20: ; preds = %1
%21 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i8* %21, i8** %13
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %37
23: ; preds = %20
%24 = load i8*, i8** %7
%25 = load i8*, i8** %13
%26 = call i32 @strncpy(i8* %24, i8* %25, i32 512)
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 7
store i8 0, i8* %28
%29 = load i8*, i8** %7
%30 = load i8*, i8** %7
%31 = call i32 @strlen(i8* %30)
%32 = sext i32 %31 to i64
%33 = sub i64 8, %32
%34 = sub i64 %33, 1
%35 = trunc i64 %34 to i32
%36 = call i32 @strncat(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %23, %20
%38 = load i8*, i8** %7
%39 = load i8*, i8** %7
%40 = call i32 @strlen(i8* %39)
%41 = sub nsw i32 512, %40
%42 = sub nsw i32 %41, 1
%43 = call i32 @strncat(i8* %38, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = load i8*, i8** %7
%45 = call i32 @mktemp(i8* %44)
%46 = load i8*, i8** %7
%47 = call i32 @strlen(i8* %46)
%48 = add nsw i32 %47, 1
store i32 %48, i32* %12
%49 = load i8*, i8** %3
store i8* %49, i8** %14
%50 = load i8*, i8** %14
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 64
br i1 %53, label %54, label %59
54: ; preds = %37
%55 = load i8*, i8** %14
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %14
%57 = load i32, i32* %12
%58 = add nsw i32 %57, 1
store i32 %58, i32* %12
br label %59
59: ; preds = %54, %37
%60 = load i8*, i8** %14
%61 = call i8* @strchr(i8* %60, i8 signext 32)
store i8* %61, i8** %13
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %74
63: ; preds = %59
%64 = load i8*, i8** %13
store i8 0, i8* %64
%65 = load i8*, i8** %13
%66 = getelementptr inbounds i8, i8* %65, i64 1
%67 = call i32 @sscanf(i8* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %11)
%68 = load i8*, i8** %13
%69 = getelementptr inbounds i8, i8* %68, i64 1
%70 = call i32 @strlen(i8* %69)
%71 = add nsw i32 %70, 1
%72 = load i32, i32* %12
%73 = add nsw i32 %72, %71
store i32 %73, i32* %12
br label %75
74: ; preds = %59
store i32 0, i32* %11
br label %75
75: ; preds = %74, %63
%76 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%77 = load i8*, i8** %14
%78 = call i32 @strncpy(i8* %76, i8* %77, i32 4096)
%79 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%80 = call i8* @strchr(i8* %79, i8 signext 43)
store i8* %80, i8** %13
br label %81
81: ; preds = %86, %75
%82 = load i8*, i8** %13
%83 = icmp ne i8* %82, null
br i1 %83, label %84, label %90
84: ; preds = %81
%85 = load i8*, i8** %13
store i8 32, i8* %85
br label %86
86: ; preds = %84
%87 = load i8*, i8** %13
%88 = getelementptr inbounds i8, i8* %87, i64 1
%89 = call i8* @strchr(i8* %88, i8 signext 43)
store i8* %89, i8** %13
br label %81
90: ; preds = %81
%91 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 4095
store i8 0, i8* %91
%92 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%93 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%94 = call i32 @strlen(i8* %93)
%95 = sext i32 %94 to i64
%96 = sub i64 4096, %95
%97 = sub i64 %96, 1
%98 = trunc i64 %97 to i32
%99 = call i32 @strncat(i8* %92, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %98)
%100 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%101 = load i8*, i8** %7
%102 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%103 = call i32 @strlen(i8* %102)
%104 = sext i32 %103 to i64
%105 = sub i64 4096, %104
%106 = sub i64 %105, 1
%107 = trunc i64 %106 to i32
%108 = call i32 @strncat(i8* %100, i8* %101, i32 %107)
%109 = load i8*, i8** %13
%110 = icmp ne i8* %109, null
br i1 %110, label %111, label %113
111: ; preds = %90
%112 = load i8*, i8** %13
store i8 32, i8* %112
br label %113
113: ; preds = %111, %90
%114 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%115 = call i32 @system(i8* %114)
store i32 %115, i32* %5
%116 = load i32, i32* %5
%117 = icmp eq i32 %116, 4
br i1 %117, label %118, label %119
118: ; preds = %113
br label %176
119: ; preds = %113
%120 = load i32, i32* %5
%121 = icmp slt i32 %120, 0
br i1 %121, label %125, label %122
122: ; preds = %119
%123 = load i32, i32* %5
%124 = icmp eq i32 %123, 127
br i1 %124, label %125, label %129
125: ; preds = %122, %119
%126 = load i32, i32* @stderr
%127 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%128 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([179 x i8], [179 x i8]* @.str.1, i64 0, i64 0), i32 1622, i8* %127)
br label %176
129: ; preds = %122
%130 = load i32, i32* %12
%131 = add nsw i32 %130, 1
%132 = call i8* @calloc(i32 %131, i32 1)
store i8* %132, i8** %8
%133 = icmp eq i8* %132, null
br i1 %133, label %134, label %139
134: ; preds = %129
%135 = load i32, i32* @stderr
%136 = load i32, i32* %12
%137 = add nsw i32 %136, 1
%138 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([179 x i8], [179 x i8]* @.str.1, i64 0, i64 0), i32 1629, i32 %137)
br label %176
139: ; preds = %129
%140 = load i8*, i8** %8
%141 = getelementptr inbounds i8, i8* %140, i64 0
store i8 0, i8* %141
%142 = load i8*, i8** %3
%143 = load i8, i8* %142
%144 = sext i8 %143 to i32
%145 = icmp eq i32 %144, 64
br i1 %145, label %146, label %153
146: ; preds = %139
%147 = load i8*, i8** %8
%148 = load i8*, i8** %8
%149 = call i32 @strlen(i8* %148)
%150 = sub nsw i32 512, %149
%151 = sub nsw i32 %150, 1
%152 = call i32 @strncat(i8* %147, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 %151)
br label %153
153: ; preds = %146, %139
%154 = load i8*, i8** %8
%155 = load i8*, i8** %7
%156 = load i8*, i8** %8
%157 = call i32 @strlen(i8* %156)
%158 = sub nsw i32 512, %157
%159 = sub nsw i32 %158, 1
%160 = call i32 @strncat(i8* %154, i8* %155, i32 %159)
%161 = load i32, i32* %11
%162 = icmp sgt i32 %161, 0
br i1 %162, label %163, label %174
163: ; preds = %153
%164 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%165 = load i32, i32* %11
%166 = call i32 @sprintf(i8* %164, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %165)
%167 = load i8*, i8** %8
%168 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%169 = load i8*, i8** %8
%170 = call i32 @strlen(i8* %169)
%171 = sub nsw i32 512, %170
%172 = sub nsw i32 %171, 1
%173 = call i32 @strncat(i8* %167, i8* %168, i32 %172)
br label %174
174: ; preds = %163, %153
%175 = load i8*, i8** %8
store i8* %175, i8** %2
br label %177
176: ; preds = %134, %125, %118, %17
store i8* null, i8** %2
br label %177
177: ; preds = %176, %174
%178 = load i8*, i8** %2
ret i8* %178
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [63 x i8] c"*** ERROR [%s:%d] - [build_lib_db] Cannot allocate lib_db_file\00"
@.str.1 = [179 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/compacc2e.c\00"
@.str.2 = [8 x i8] c"TMP_DIR\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [14 x i8] c"lib_db_XXXXXX\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [3 x i8] c" >\00"
@.str.7 = [54 x i8] c"*** ERROR [%s:%d] - [build_lib_db] script: %s failed\0A\00"
@.str.8 = [67 x i8] c"*** ERROR [%s:%d] - [build_lib_db] cannot allocate lib_db_str[%d]\0A\00"
@.str.9 = [2 x i8] c"@\00"
@.str.10 = [4 x i8] c" %d\00"
define i8* @build_lib_db(i8* %0) {
%2 = alloca [32 x i8]
%3 = alloca [4096 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = tail call dereferenceable_or_null(512) i8* @calloc(i32 512, i32 1)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([179 x i8], [179 x i8]* @.str.1, i64 0, i64 0), i32 1571)
br label %95
13: ; preds = %1
%14 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = tail call i32 @strncpy(i8* %8, i8* %14, i32 512)
%18 = getelementptr inbounds i8, i8* %8, i64 7
store i8 0, i8* %18
%19 = tail call i32 @strlen(i8* %8)
%20 = sub i32 7, %19
%21 = tail call i32 @strncat(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %16, %13
%23 = tail call i32 @strlen(i8* %8)
%24 = sub i32 511, %23
%25 = tail call i32 @strncat(i8* %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = tail call i32 @mktemp(i8* %8)
%27 = tail call i32 @strlen(i8* %8)
%28 = load i8, i8* %0
%29 = icmp eq i8 %28, 64
%30 = select i1 %29, i32 2, i32 1
%31 = add nsw i32 %30, %27
%32 = zext i1 %29 to i64
%33 = getelementptr i8, i8* %0, i64 %32
%34 = tail call i8* @strchr(i8* %33, i8 signext 32)
%35 = icmp eq i8* %34, null
br i1 %35, label %42, label %36
36: ; preds = %22
store i8 0, i8* %34
%37 = getelementptr inbounds i8, i8* %34, i64 1
%38 = call i32 @sscanf(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%39 = call i32 @strlen(i8* %37)
%40 = add i32 %31, 1
%41 = add i32 %40, %39
br label %43
42: ; preds = %22
store i32 0, i32* %4
br label %43
43: ; preds = %42, %36
%44 = phi i32 [ %41, %36 ], [ %31, %42 ]
%45 = call i32 @strncpy(i8* %6, i8* %33, i32 4096)
%46 = call i8* @strchr(i8* %6, i8 signext 43)
%47 = icmp eq i8* %46, null
br i1 %47, label %53, label %48
48: ; preds = %43, %48
%49 = phi i8* [ %51, %48 ], [ %46, %43 ]
store i8 32, i8* %49
%50 = getelementptr inbounds i8, i8* %49, i64 1
%51 = call i8* @strchr(i8* %50, i8 signext 43)
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %48
53: ; preds = %48, %43
%54 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 4095
store i8 0, i8* %54
%55 = call i32 @strlen(i8* %6)
%56 = sub i32 4095, %55
%57 = call i32 @strncat(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %56)
%58 = call i32 @strlen(i8* %6)
%59 = sub i32 4095, %58
%60 = call i32 @strncat(i8* %6, i8* %8, i32 %59)
%61 = call i32 @system(i8* %6)
%62 = icmp eq i32 %61, 4
br i1 %62, label %95, label %63
63: ; preds = %53
%64 = icmp slt i32 %61, 0
%65 = icmp eq i32 %61, 127
%66 = or i1 %64, %65
br i1 %66, label %67, label %70
67: ; preds = %63
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([179 x i8], [179 x i8]* @.str.1, i64 0, i64 0), i32 1622, i8* %6)
br label %95
70: ; preds = %63
%71 = add nsw i32 %44, 1
%72 = call i8* @calloc(i32 %71, i32 1)
%73 = icmp eq i8* %72, null
br i1 %73, label %74, label %77
74: ; preds = %70
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([179 x i8], [179 x i8]* @.str.1, i64 0, i64 0), i32 1629, i32 %71)
br label %95
77: ; preds = %70
store i8 0, i8* %72
%78 = load i8, i8* %0
%79 = icmp eq i8 %78, 64
br i1 %79, label %80, label %84
80: ; preds = %77
%81 = call i32 @strlen(i8* %72)
%82 = sub i32 511, %81
%83 = call i32 @strncat(i8* %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %80, %77
%85 = call i32 @strlen(i8* %72)
%86 = sub i32 511, %85
%87 = call i32 @strncat(i8* %72, i8* %8, i32 %86)
%88 = load i32, i32* %4
%89 = icmp sgt i32 %88, 0
br i1 %89, label %90, label %95
90: ; preds = %84
%91 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %88)
%92 = call i32 @strlen(i8* %72)
%93 = sub i32 511, %92
%94 = call i32 @strncat(i8* %72, i8* %5, i32 %93)
br label %95
95: ; preds = %10, %67, %74, %53, %84, %90
%96 = phi i8* [ %72, %90 ], [ %72, %84 ], [ null, %53 ], [ null, %74 ], [ null, %67 ], [ null, %10 ]
ret i8* %96
}