#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 */

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int,
                           unsigned char, unsigned char);
unsigned char *get_asn_db_info(unsigned char *, int, int *, char *, size_t,
                               char *, size_t);
unsigned char *get_asn_textseq_id(unsigned char *, char *, size_t, char *,
                                  size_t);
int /*<<< orphan*/ stderr;
unsigned char *get_asn_seqid(unsigned char *abp, int *gi_p, int *db, char *acc,
                             size_t acc_len, char *name, size_t name_len) {
  int db_type, itmp, seq_cnt = 0;
  *gi_p = 0;
  if (*abp != 0x30) {
    fprintf(stderr,
            "*** ERROR [%s:%d] - get_asn_seqid - missing SEQ 1: %2x %2x\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/ncbl2_mlib.c",
            2299, abp[0], abp[1]);
    return abp;
  } else {
    abp += 2;
    seq_cnt++;
  }
  while (*abp) {
    if (*abp == 0xa4) {
      abp = get_asn_textseq_id(abp + 2, name, name_len, acc, acc_len);
    } else if (*abp == 0xa5) {
      abp = get_asn_textseq_id(abp + 2, name, name_len, acc, acc_len);
    } else if ((db_type = (*abp & 31)) < 17) {
      abp =
          get_asn_db_info(abp + 2, db_type, gi_p, name, name_len, acc, acc_len);
      *db = db_type;
    } else {
      fprintf(
          stderr,
          "*** ERROR [%s:%d] -- get_asn_seqid not TEXTSEQ/not GI: %2x %2x\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/ncbl2_mlib.c",
          2317, abp[0], abp[1]);
      return abp;
    }
  }
  while (seq_cnt-- > 0) {
    abp += 4;
  }
  return abp;
}


x86 assembly (clang, -O0):
<get_asn_seqid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x30,%eax
je     11b7 <get_asn_seqid+0x87>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%r8b
mov    -0x10(%rbp),%rax
lea    0xe70(%rip),%rsi
lea    0xea5(%rip),%rdx
mov    $0x8fb,%ecx
movzbl %r8b,%r8d
movzbl 0x1(%rax),%r9d
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1321 <get_asn_seqid+0x1f1>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11d1 <get_asn_seqid+0xa1>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     12ef <get_asn_seqid+0x1bf>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xa4,%eax
jne    1216 <get_asn_seqid+0xe6>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
mov    -0x38(%rbp),%rsi
mov    0x10(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1050 <get_asn_textseq_id@plt>
mov    %rax,-0x10(%rbp)
jmp    12ea <get_asn_seqid+0x1ba>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xa5,%eax
jne    124e <get_asn_seqid+0x11e>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
mov    -0x38(%rbp),%rsi
mov    0x10(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1050 <get_asn_textseq_id@plt>
mov    %rax,-0x10(%rbp)
jmp    12e5 <get_asn_seqid+0x1b5>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
and    $0x1f,%eax
mov    %eax,-0x3c(%rbp)
cmp    $0x11,%eax
jge    129e <get_asn_seqid+0x16e>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
mov    -0x3c(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    0x10(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    -0x30(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <get_asn_db_info@plt>
mov    %rax,-0x10(%rbp)
mov    -0x3c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    12e0 <get_asn_seqid+0x1b0>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%r8b
mov    -0x10(%rbp),%rax
lea    0xe37(%rip),%rsi
lea    0xd7c(%rip),%rdx
mov    $0x90d,%ecx
movzbl %r8b,%r8d
movzbl 0x1(%rax),%r9d
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1321 <get_asn_seqid+0x1f1>
jmp    12e5 <get_asn_seqid+0x1b5>
jmp    12ea <get_asn_seqid+0x1ba>
jmp    11d1 <get_asn_seqid+0xa1>
jmp    12f4 <get_asn_seqid+0x1c4>
mov    -0x44(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x44(%rbp)
cmp    $0x0,%eax
jle    1319 <get_asn_seqid+0x1e9>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    12f4 <get_asn_seqid+0x1c4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_asn_seqid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %rdi,%rbx
mov    %rsi,0x8(%rsp)
movl   $0x0,(%rsi)
mov    (%rdi),%al
cmp    $0x30,%al
jne    11db <get_asn_seqid+0xab>
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
mov    0x50(%rsp),%r13
add    $0x2,%rbx
jmp    118b <get_asn_seqid+0x5b>
nop
add    $0x2,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %r15,%r8
call   1050 <get_asn_textseq_id@plt>
mov    %rax,%rbx
movzbl (%rbx),%r8d
cmp    $0xa4,%r8d
je     1170 <get_asn_seqid+0x40>
cmp    $0xa5,%r8b
je     1170 <get_asn_seqid+0x40>
test   %r8b,%r8b
je     1202 <get_asn_seqid+0xd2>
mov    %r8d,%ebp
and    $0x1f,%ebp
cmp    $0x10,%bpl
ja     1208 <get_asn_seqid+0xd8>
add    $0x2,%rbx
mov    %r15,(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    0x8(%rsp),%rdx
mov    %r14,%rcx
mov    %r13,%r8
mov    %r12,%r9
call   1040 <get_asn_db_info@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rax
mov    %ebp,(%rax)
jmp    118b <get_asn_seqid+0x5b>
mov    0x2dfe(%rip),%rcx
mov    (%rcx),%edi
movzbl 0x1(%rbx),%r9d
movzbl %al,%r8d
lea    0xe0c(%rip),%rsi
lea    0xe41(%rip),%rdx
mov    $0x8fb,%ecx
jmp    1229 <get_asn_seqid+0xf9>
add    $0x4,%rbx
jmp    122e <get_asn_seqid+0xfe>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
movzbl 0x1(%rbx),%r9d
lea    0xed3(%rip),%rsi
lea    0xe18(%rip),%rdx
mov    $0x90d,%ecx
call   1030 <fprintf@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [60 x i8] c"*** ERROR [%s:%d] - get_asn_seqid - missing SEQ 1: %2x %2x\0A\00"
@.str.1 = [180 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/ncbl2_mlib.c\00"
@.str.2 = [64 x i8] c"*** ERROR [%s:%d] -- get_asn_seqid not TEXTSEQ/not GI: %2x %2x\0A\00"
define i8* @get_asn_seqid(i8* %0, i32* %1, i32* %2, i8* %3, i64 %4, i8* %5, i64 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %9
store i32* %1, i32** %10
store i32* %2, i32** %11
store i8* %3, i8** %12
store i64 %4, i64* %13
store i8* %5, i8** %14
store i64 %6, i64* %15
store i32 0, i32* %18
%19 = load i32*, i32** %10
store i32 0, i32* %19
%20 = load i8*, i8** %9
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = icmp ne i32 %22, 48
br i1 %23, label %24, label %34
24: ; preds = %7
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %9
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = load i8*, i8** %9
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8, i8* %30
%32 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str.1, i64 0, i64 0), i32 2299, i8 zeroext %28, i8 zeroext %31)
%33 = load i8*, i8** %9
store i8* %33, i8** %8
br label %111
34: ; preds = %7
%35 = load i8*, i8** %9
%36 = getelementptr inbounds i8, i8* %35, i64 2
store i8* %36, i8** %9
%37 = load i32, i32* %18
%38 = add nsw i32 %37, 1
store i32 %38, i32* %18
br label %39
39: ; preds = %34
br label %40
40: ; preds = %100, %39
%41 = load i8*, i8** %9
%42 = load i8, i8* %41
%43 = icmp ne i8 %42, 0
br i1 %43, label %44, label %101
44: ; preds = %40
%45 = load i8*, i8** %9
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = icmp eq i32 %47, 164
br i1 %48, label %49, label %57
49: ; preds = %44
%50 = load i8*, i8** %9
%51 = getelementptr inbounds i8, i8* %50, i64 2
%52 = load i8*, i8** %14
%53 = load i64, i64* %15
%54 = load i8*, i8** %12
%55 = load i64, i64* %13
%56 = call i8* @get_asn_textseq_id(i8* %51, i8* %52, i64 %53, i8* %54, i64 %55)
store i8* %56, i8** %9
br label %100
57: ; preds = %44
%58 = load i8*, i8** %9
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = icmp eq i32 %60, 165
br i1 %61, label %62, label %70
62: ; preds = %57
%63 = load i8*, i8** %9
%64 = getelementptr inbounds i8, i8* %63, i64 2
%65 = load i8*, i8** %14
%66 = load i64, i64* %15
%67 = load i8*, i8** %12
%68 = load i64, i64* %13
%69 = call i8* @get_asn_textseq_id(i8* %64, i8* %65, i64 %66, i8* %67, i64 %68)
store i8* %69, i8** %9
br label %99
70: ; preds = %57
%71 = load i8*, i8** %9
%72 = load i8, i8* %71
%73 = zext i8 %72 to i32
%74 = and i32 %73, 31
store i32 %74, i32* %16
%75 = icmp slt i32 %74, 17
br i1 %75, label %76, label %88
76: ; preds = %70
%77 = load i8*, i8** %9
%78 = getelementptr inbounds i8, i8* %77, i64 2
%79 = load i32, i32* %16
%80 = load i32*, i32** %10
%81 = load i8*, i8** %14
%82 = load i64, i64* %15
%83 = load i8*, i8** %12
%84 = load i64, i64* %13
%85 = call i8* @get_asn_db_info(i8* %78, i32 %79, i32* %80, i8* %81, i64 %82, i8* %83, i64 %84)
store i8* %85, i8** %9
%86 = load i32, i32* %16
%87 = load i32*, i32** %11
store i32 %86, i32* %87
br label %98
88: ; preds = %70
%89 = load i32, i32* @stderr
%90 = load i8*, i8** %9
%91 = getelementptr inbounds i8, i8* %90, i64 0
%92 = load i8, i8* %91
%93 = load i8*, i8** %9
%94 = getelementptr inbounds i8, i8* %93, i64 1
%95 = load i8, i8* %94
%96 = call i32 @fprintf(i32 %89, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str.1, i64 0, i64 0), i32 2317, i8 zeroext %92, i8 zeroext %95)
%97 = load i8*, i8** %9
store i8* %97, i8** %8
br label %111
98: ; preds = %76
br label %99
99: ; preds = %98, %62
br label %100
100: ; preds = %99, %49
br label %40
101: ; preds = %40
br label %102
102: ; preds = %106, %101
%103 = load i32, i32* %18
%104 = add nsw i32 %103, -1
store i32 %104, i32* %18
%105 = icmp sgt i32 %103, 0
br i1 %105, label %106, label %109
106: ; preds = %102
%107 = load i8*, i8** %9
%108 = getelementptr inbounds i8, i8* %107, i64 4
store i8* %108, i8** %9
br label %102
109: ; preds = %102
%110 = load i8*, i8** %9
store i8* %110, i8** %8
br label %111
111: ; preds = %109, %88, %24
%112 = load i8*, i8** %8
ret i8* %112
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [60 x i8] c"*** ERROR [%s:%d] - get_asn_seqid - missing SEQ 1: %2x %2x\0A\00"
@.str.1 = [180 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/ncbl2_mlib.c\00"
@.str.2 = [64 x i8] c"*** ERROR [%s:%d] -- get_asn_seqid not TEXTSEQ/not GI: %2x %2x\0A\00"
define i8* @get_asn_seqid(i8* %0, i32* %1, i32* nocapture writeonly %2, i8* %3, i64 %4, i8* %5, i64 %6) {
store i32 0, i32* %1
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 48
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = load i8, i8* %12
%14 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str.1, i64 0, i64 0), i32 2299, i8 zeroext %8, i8 zeroext %13)
br label %42
15: ; preds = %7
%16 = getelementptr inbounds i8, i8* %0, i64 2
br label %17
17: ; preds = %28, %15
%18 = phi i8* [ %16, %15 ], [ %29, %28 ]
%19 = load i8, i8* %18
switch i8 %19, label %30 [
i8 0, label %20
i8 -92, label %22
i8 -91, label %25
]
20: ; preds = %17
%21 = getelementptr i8, i8* %18, i64 4
br label %42
22: ; preds = %17
%23 = getelementptr inbounds i8, i8* %18, i64 2
%24 = tail call i8* @get_asn_textseq_id(i8* %23, i8* %5, i64 %6, i8* %3, i64 %4)
br label %28
25: ; preds = %17
%26 = getelementptr inbounds i8, i8* %18, i64 2
%27 = tail call i8* @get_asn_textseq_id(i8* %26, i8* %5, i64 %6, i8* %3, i64 %4)
br label %28
28: ; preds = %25, %34, %22
%29 = phi i8* [ %24, %22 ], [ %27, %25 ], [ %36, %34 ]
br label %17
30: ; preds = %17
%31 = and i8 %19, 31
%32 = zext i8 %31 to i32
%33 = icmp ult i8 %31, 17
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = getelementptr inbounds i8, i8* %18, i64 2
%36 = tail call i8* @get_asn_db_info(i8* %35, i32 %32, i32* %1, i8* %5, i64 %6, i8* %3, i64 %4)
store i32 %32, i32* %2
br label %28
37: ; preds = %30
%38 = load i32, i32* @stderr
%39 = getelementptr inbounds i8, i8* %18, i64 1
%40 = load i8, i8* %39
%41 = tail call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str.1, i64 0, i64 0), i32 2317, i8 zeroext %19, i8 zeroext %40)
br label %42
42: ; preds = %20, %37, %10
%43 = phi i8* [ %0, %10 ], [ %18, %37 ], [ %21, %20 ]
ret i8* %43
}