#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/compacc2.c",
            1552);
    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));
  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/compacc2.c",
            1598, 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/compacc2.c",
        1605, 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    $0x610,%ecx
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15d9 <build_lib_db+0x429>
lea    0xee6(%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    0xe88(%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    0xe59(%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    0xe49(%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>
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    0xd3b(%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     1434 <build_lib_db+0x284>
mov    -0x1068(%rbp),%rax
movb   $0x20,(%rax)
lea    -0x1050(%rbp),%rdi
call   1060 <system@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jne    1452 <build_lib_db+0x2a2>
jmp    15d9 <build_lib_db+0x429>
cmpl   $0x0,-0x18(%rbp)
jl     1466 <build_lib_db+0x2b6>
cmpl   $0x7f,-0x18(%rbp)
jne    1495 <build_lib_db+0x2e5>
mov    0x2b73(%rip),%rax
mov    (%rax),%edi
lea    -0x1050(%rbp),%r8
lea    0xc8f(%rip),%rsi
lea    0xbbb(%rip),%rdx
mov    $0x63e,%ecx
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15d9 <build_lib_db+0x429>
mov    -0x105c(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    14e9 <build_lib_db+0x339>
mov    0x2b23(%rip),%rax
mov    (%rax),%edi
mov    -0x105c(%rbp),%r8d
add    $0x1,%r8d
lea    0xc71(%rip),%rsi
lea    0xb67(%rip),%rdx
mov    $0x645,%ecx
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15d9 <build_lib_db+0x429>
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x40,%eax
jne    1531 <build_lib_db+0x381>
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    0xc59(%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    15cc <build_lib_db+0x41c>
lea    -0x40(%rbp),%rdi
mov    -0x1058(%rbp),%edx
lea    0xbfc(%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    15e1 <build_lib_db+0x431>
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     12a9 <build_lib_db+0xf9>
mov    %rax,%r13
lea    0xf0b(%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    0xede(%rip),%rsi
mov    %r13,%rdi
call   1080 <strncat@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    $0x1ff,%edx
sub    %eax,%edx
lea    0xec2(%rip),%rsi
mov    %r13,%rdi
call   1080 <strncat@plt>
mov    %r13,%rdi
call   10d0 <mktemp@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
xor    %ebx,%ebx
cmpb   $0x40,(%r14)
sete   %bl
lea    (%rbx,%rax,1),%r15d
add    $0x1,%r15d
add    %r14,%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,%r12
test   %rax,%rax
je     12d4 <build_lib_db+0x124>
movb   $0x0,(%r12)
lea    0x1(%r12),%rbp
lea    0xefd(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbp,%rdi
call   10b0 <sscanf@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
add    %eax,%r15d
add    $0x1,%r15d
jmp    12dc <build_lib_db+0x12c>
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
lea    0xd47(%rip),%rsi
lea    0xd7f(%rip),%rdx
xor    %r12d,%r12d
mov    $0x610,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1457 <build_lib_db+0x2a7>
movl   $0x0,0xc(%rsp)
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1040 <strncpy@plt>
movb   $0x0,0x102f(%rsp)
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    $0xfff,%ebx
mov    $0xfff,%edx
sub    %eax,%edx
lea    0xdf5(%rip),%rsi
mov    %rbp,%rdi
call   1080 <strncat@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
sub    %eax,%ebx
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1080 <strncat@plt>
test   %r12,%r12
je     133d <build_lib_db+0x18d>
movb   $0x20,(%r12)
lea    0x30(%rsp),%rdi
call   1060 <system@plt>
cmp    $0x4,%eax
jne    1354 <build_lib_db+0x1a4>
xor    %r12d,%r12d
jmp    1457 <build_lib_db+0x2a7>
test   %eax,%eax
js     1401 <build_lib_db+0x251>
cmp    $0x7f,%eax
je     1401 <build_lib_db+0x251>
add    $0x1,%r15d
mov    %r15d,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
test   %rax,%rax
je     142e <build_lib_db+0x27e>
mov    %rax,%r12
movb   $0x0,(%rax)
cmpb   $0x40,(%r14)
jne    13a9 <build_lib_db+0x1f9>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    $0x1ff,%edx
sub    %eax,%edx
lea    0xde4(%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    1457 <build_lib_db+0x2a7>
lea    0xdac(%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    1457 <build_lib_db+0x2a7>
mov    0x2bd8(%rip),%rax
mov    (%rax),%edi
lea    0xcfb(%rip),%rsi
lea    0xc27(%rip),%rdx
xor    %r12d,%r12d
lea    0x30(%rsp),%r8
mov    $0x63e,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1457 <build_lib_db+0x2a7>
mov    0x2bab(%rip),%rax
mov    (%rax),%edi
lea    0xd04(%rip),%rsi
lea    0xbfa(%rip),%rdx
xor    %r12d,%r12d
mov    $0x645,%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 = [178 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/compacc2.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 ([178 x i8], [178 x i8]* @.str.1, i64 0, i64 0), i32 1552)
br label %164
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 4095
store i8 0, i8* %79
%80 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%81 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%82 = call i32 @strlen(i8* %81)
%83 = sext i32 %82 to i64
%84 = sub i64 4096, %83
%85 = sub i64 %84, 1
%86 = trunc i64 %85 to i32
%87 = call i32 @strncat(i8* %80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %86)
%88 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%89 = load i8*, i8** %7
%90 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%91 = call i32 @strlen(i8* %90)
%92 = sext i32 %91 to i64
%93 = sub i64 4096, %92
%94 = sub i64 %93, 1
%95 = trunc i64 %94 to i32
%96 = call i32 @strncat(i8* %88, i8* %89, i32 %95)
%97 = load i8*, i8** %13
%98 = icmp ne i8* %97, null
br i1 %98, label %99, label %101
99: ; preds = %75
%100 = load i8*, i8** %13
store i8 32, i8* %100
br label %101
101: ; preds = %99, %75
%102 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%103 = call i32 @system(i8* %102)
store i32 %103, i32* %5
%104 = load i32, i32* %5
%105 = icmp eq i32 %104, 4
br i1 %105, label %106, label %107
106: ; preds = %101
br label %164
107: ; preds = %101
%108 = load i32, i32* %5
%109 = icmp slt i32 %108, 0
br i1 %109, label %113, label %110
110: ; preds = %107
%111 = load i32, i32* %5
%112 = icmp eq i32 %111, 127
br i1 %112, label %113, label %117
113: ; preds = %110, %107
%114 = load i32, i32* @stderr
%115 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%116 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.1, i64 0, i64 0), i32 1598, i8* %115)
br label %164
117: ; preds = %110
%118 = load i32, i32* %12
%119 = add nsw i32 %118, 1
%120 = call i8* @calloc(i32 %119, i32 1)
store i8* %120, i8** %8
%121 = icmp eq i8* %120, null
br i1 %121, label %122, label %127
122: ; preds = %117
%123 = load i32, i32* @stderr
%124 = load i32, i32* %12
%125 = add nsw i32 %124, 1
%126 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %123, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.1, i64 0, i64 0), i32 1605, i32 %125)
br label %164
127: ; preds = %117
%128 = load i8*, i8** %8
%129 = getelementptr inbounds i8, i8* %128, i64 0
store i8 0, i8* %129
%130 = load i8*, i8** %3
%131 = load i8, i8* %130
%132 = sext i8 %131 to i32
%133 = icmp eq i32 %132, 64
br i1 %133, label %134, label %141
134: ; preds = %127
%135 = load i8*, i8** %8
%136 = load i8*, i8** %8
%137 = call i32 @strlen(i8* %136)
%138 = sub nsw i32 512, %137
%139 = sub nsw i32 %138, 1
%140 = call i32 @strncat(i8* %135, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 %139)
br label %141
141: ; preds = %134, %127
%142 = load i8*, i8** %8
%143 = load i8*, i8** %7
%144 = load i8*, i8** %8
%145 = call i32 @strlen(i8* %144)
%146 = sub nsw i32 512, %145
%147 = sub nsw i32 %146, 1
%148 = call i32 @strncat(i8* %142, i8* %143, i32 %147)
%149 = load i32, i32* %11
%150 = icmp sgt i32 %149, 0
br i1 %150, label %151, label %162
151: ; preds = %141
%152 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%153 = load i32, i32* %11
%154 = call i32 @sprintf(i8* %152, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %153)
%155 = load i8*, i8** %8
%156 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%157 = load i8*, i8** %8
%158 = call i32 @strlen(i8* %157)
%159 = sub nsw i32 512, %158
%160 = sub nsw i32 %159, 1
%161 = call i32 @strncat(i8* %155, i8* %156, i32 %160)
br label %162
162: ; preds = %151, %141
%163 = load i8*, i8** %8
store i8* %163, i8** %2
br label %165
164: ; preds = %122, %113, %106, %17
store i8* null, i8** %2
br label %165
165: ; preds = %164, %162
%166 = load i8*, i8** %2
ret i8* %166
}

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 = [178 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/compacc2.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 ([178 x i8], [178 x i8]* @.str.1, i64 0, i64 0), i32 1552)
br label %89
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 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 4095
store i8 0, i8* %46
%47 = call i32 @strlen(i8* %6)
%48 = sub i32 4095, %47
%49 = call i32 @strncat(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %48)
%50 = call i32 @strlen(i8* %6)
%51 = sub i32 4095, %50
%52 = call i32 @strncat(i8* %6, i8* %8, i32 %51)
br i1 %35, label %54, label %53
53: ; preds = %43
store i8 32, i8* %34
br label %54
54: ; preds = %53, %43
%55 = call i32 @system(i8* %6)
%56 = icmp eq i32 %55, 4
br i1 %56, label %89, label %57
57: ; preds = %54
%58 = icmp slt i32 %55, 0
%59 = icmp eq i32 %55, 127
%60 = or i1 %58, %59
br i1 %60, label %61, label %64
61: ; preds = %57
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.1, i64 0, i64 0), i32 1598, i8* %6)
br label %89
64: ; preds = %57
%65 = add nsw i32 %44, 1
%66 = call i8* @calloc(i32 %65, i32 1)
%67 = icmp eq i8* %66, null
br i1 %67, label %68, label %71
68: ; preds = %64
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, i8*, i32, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.1, i64 0, i64 0), i32 1605, i32 %65)
br label %89
71: ; preds = %64
store i8 0, i8* %66
%72 = load i8, i8* %0
%73 = icmp eq i8 %72, 64
br i1 %73, label %74, label %78
74: ; preds = %71
%75 = call i32 @strlen(i8* %66)
%76 = sub i32 511, %75
%77 = call i32 @strncat(i8* %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %74, %71
%79 = call i32 @strlen(i8* %66)
%80 = sub i32 511, %79
%81 = call i32 @strncat(i8* %66, i8* %8, i32 %80)
%82 = load i32, i32* %4
%83 = icmp sgt i32 %82, 0
br i1 %83, label %84, label %89
84: ; preds = %78
%85 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %82)
%86 = call i32 @strlen(i8* %66)
%87 = sub i32 511, %86
%88 = call i32 @strncat(i8* %66, i8* %5, i32 %87)
br label %89
89: ; preds = %10, %61, %68, %54, %78, %84
%90 = phi i8* [ %66, %84 ], [ %66, %78 ], [ null, %54 ], [ null, %68 ], [ null, %61 ], [ null, %10 ]
ret i8* %90
}