#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_int(unsigned char *, int *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int /*<<< orphan*/ stderr;
unsigned char *get_asn_date_std(unsigned char *abp, char *date) {
  int seq_cnt = 0;
  int year, month, day;
  year = month = day = 0;
  while (*abp == 0x30) {
    abp += 2;
    seq_cnt++;
  }
  while (*abp) {
    switch (*abp) {
    case 0xa0:
      abp = get_asn_int(abp + 2, &year);
      break;
    case 0xa1:
      abp = get_asn_int(abp + 2, &month);
      break;
    case 0xa2:
      abp = get_asn_int(abp + 2, &day);
      break;
    default:
      fprintf(stderr,
              "*** ERROR [%s:%d] - incorrect date-std code: %0x1 %0x1\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",
              2125, abp[0], abp[1]);
    }
  }
  sprintf(date, "%02d-%02d-%02d", year, month, day);
  while (seq_cnt-- > 0) {
    abp += 4;
  }
  return abp + 2;
}


x86 assembly (clang, -O0):
<get_asn_date_std>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x30,%eax
jne    1186 <get_asn_date_std+0x56>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115c <get_asn_date_std+0x2c>
jmp    118b <get_asn_date_std+0x5b>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1260 <get_asn_date_std+0x130>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x24(%rbp)
sub    $0xa0,%eax
je     11d8 <get_asn_date_std+0xa8>
jmp    11b2 <get_asn_date_std+0x82>
mov    -0x24(%rbp),%eax
sub    $0xa1,%eax
je     11f2 <get_asn_date_std+0xc2>
jmp    11c5 <get_asn_date_std+0x95>
mov    -0x24(%rbp),%eax
sub    $0xa2,%eax
je     120c <get_asn_date_std+0xdc>
jmp    1226 <get_asn_date_std+0xf6>
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
lea    -0x18(%rbp),%rsi
call   1030 <get_asn_int@plt>
mov    %rax,-0x8(%rbp)
jmp    125b <get_asn_date_std+0x12b>
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
lea    -0x1c(%rbp),%rsi
call   1030 <get_asn_int@plt>
mov    %rax,-0x8(%rbp)
jmp    125b <get_asn_date_std+0x12b>
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
lea    -0x20(%rbp),%rsi
call   1030 <get_asn_int@plt>
mov    %rax,-0x8(%rbp)
jmp    125b <get_asn_date_std+0x12b>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%r8b
mov    -0x8(%rbp),%rax
lea    0xdbf(%rip),%rsi
lea    0xdf0(%rip),%rdx
mov    $0x84d,%ecx
movzbl %r8b,%r8d
movzbl 0x1(%rax),%r9d
call   1040 <fprintf@plt>
jmp    118b <get_asn_date_std+0x5b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xe77(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jle    129f <get_asn_date_std+0x16f>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    127a <get_asn_date_std+0x14a>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_asn_date_std>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %rdi,%rbx
movl   $0x0,0x4(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    (%rdi),%al
xor    %r15d,%r15d
cmp    $0x30,%al
jne    1180 <get_asn_date_std+0x50>
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15d
movzbl 0x2(%rbx),%eax
add    $0x2,%rbx
cmp    $0x30,%al
je     1170 <get_asn_date_std+0x40>
lea    0x8(%rsp),%r12
lea    0xe74(%rip),%r13
lea    0xea5(%rip),%rbp
lea    0x4(%rsp),%r14
cmp    $0xa1,%al
jle    11ba <get_asn_date_std+0x8a>
jmp    11d0 <get_asn_date_std+0xa0>
xchg   %ax,%ax
add    $0x2,%rbx
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
call   1030 <get_asn_int@plt>
mov    %rax,%rbx
mov    (%rax),%al
cmp    $0xa1,%al
jg     11d0 <get_asn_date_std+0xa0>
cmp    $0xa0,%al
je     11a0 <get_asn_date_std+0x70>
cmp    $0xa1,%al
jne    11e4 <get_asn_date_std+0xb4>
add    $0x2,%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
jmp    11ac <get_asn_date_std+0x7c>
xchg   %ax,%ax
cmp    $0xa2,%al
jne    11e0 <get_asn_date_std+0xb0>
add    $0x2,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
jmp    11ac <get_asn_date_std+0x7c>
test   %al,%al
je     120e <get_asn_date_std+0xde>
mov    0x2df5(%rip),%rcx
mov    (%rcx),%edi
movzbl 0x1(%rbx),%r9d
movzbl %al,%r8d
mov    %r13,%rsi
mov    %rbp,%rdx
mov    $0x84d,%ecx
call   1040 <fprintf@plt>
mov    (%rbx),%al
cmp    $0xa1,%al
jle    11ba <get_asn_date_std+0x8a>
jmp    11d0 <get_asn_date_std+0xa0>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0x4(%rsp),%r8d
lea    0xeca(%rip),%rsi
mov    0x10(%rsp),%rdi
call   1050 <sprintf@plt>
lea    -0x1(%r15),%eax
xor    %ecx,%ecx
test   %r15d,%r15d
lea    0x4(,%rax,4),%rax
cmovg  %rax,%rcx
lea    (%rbx,%rcx,1),%rax
add    $0x2,%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 = [56 x i8] c"*** ERROR [%s:%d] - incorrect date-std code: %0x1 %0x1\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 = [15 x i8] c"%02d-%02d-%02d\00"
define i8* @get_asn_date_std(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
store i32 0, i32* %8
store i32 0, i32* %7
store i32 0, i32* %6
br label %9
9: ; preds = %14, %2
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = icmp eq i32 %12, 48
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 2
store i8* %16, i8** %3
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %9
19: ; preds = %9
br label %20
20: ; preds = %49, %19
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %24, label %50
24: ; preds = %20
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
switch i32 %27, label %40 [
i32 160, label %28
i32 161, label %32
i32 162, label %36
]
28: ; preds = %24
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 2
%31 = call i8* @get_asn_int(i8* %30, i32* %6)
store i8* %31, i8** %3
br label %49
32: ; preds = %24
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i64 2
%35 = call i8* @get_asn_int(i8* %34, i32* %7)
store i8* %35, i8** %3
br label %49
36: ; preds = %24
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 2
%39 = call i8* @get_asn_int(i8* %38, i32* %8)
store i8* %39, i8** %3
br label %49
40: ; preds = %24
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i64 0
%44 = load i8, i8* %43
%45 = load i8*, i8** %3
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = load i8, i8* %46
%48 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str.1, i64 0, i64 0), i32 2125, i8 zeroext %44, i8 zeroext %47)
br label %49
49: ; preds = %40, %36, %32, %28
br label %20
50: ; preds = %20
%51 = load i8*, i8** %4
%52 = load i32, i32* %6
%53 = load i32, i32* %7
%54 = load i32, i32* %8
%55 = call i32 @sprintf(i8* %51, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %52, i32 %53, i32 %54)
br label %56
56: ; preds = %60, %50
%57 = load i32, i32* %5
%58 = add nsw i32 %57, -1
store i32 %58, i32* %5
%59 = icmp sgt i32 %57, 0
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = load i8*, i8** %3
%62 = getelementptr inbounds i8, i8* %61, i64 4
store i8* %62, i8** %3
br label %56
63: ; preds = %56
%64 = load i8*, i8** %3
%65 = getelementptr inbounds i8, i8* %64, i64 2
ret i8* %65
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [56 x i8] c"*** ERROR [%s:%d] - incorrect date-std code: %0x1 %0x1\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 = [15 x i8] c"%02d-%02d-%02d\00"
define i8* @get_asn_date_std(i8* %0, i8* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
store i32 0, i32* %4
store i32 0, i32* %3
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 48
br i1 %10, label %15, label %11
11: ; preds = %15, %2
%12 = phi i8* [ %0, %2 ], [ %18, %15 ]
%13 = phi i32 [ 0, %2 ], [ %19, %15 ]
%14 = phi i8 [ %9, %2 ], [ %20, %15 ]
br label %22
15: ; preds = %2, %15
%16 = phi i32 [ %19, %15 ], [ 0, %2 ]
%17 = phi i8* [ %18, %15 ], [ %0, %2 ]
%18 = getelementptr inbounds i8, i8* %17, i64 2
%19 = add nuw nsw i32 %16, 1
%20 = load i8, i8* %18
%21 = icmp eq i8 %20, 48
br i1 %21, label %15, label %11
22: ; preds = %11, %39
%23 = phi i8 [ %41, %39 ], [ %14, %11 ]
%24 = phi i8* [ %40, %39 ], [ %12, %11 ]
switch i8 %23, label %34 [
i8 0, label %42
i8 -96, label %25
i8 -95, label %28
i8 -94, label %31
]
25: ; preds = %22
%26 = getelementptr inbounds i8, i8* %24, i64 2
%27 = call i8* @get_asn_int(i8* %26, i32* %3)
br label %39
28: ; preds = %22
%29 = getelementptr inbounds i8, i8* %24, i64 2
%30 = call i8* @get_asn_int(i8* %29, i32* %4)
br label %39
31: ; preds = %22
%32 = getelementptr inbounds i8, i8* %24, i64 2
%33 = call i8* @get_asn_int(i8* %32, i32* %5)
br label %39
34: ; preds = %22
%35 = load i32, i32* @stderr
%36 = getelementptr inbounds i8, i8* %24, i64 1
%37 = load i8, i8* %36
%38 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str.1, i64 0, i64 0), i32 2125, i8 zeroext %23, i8 zeroext %37)
br label %39
39: ; preds = %34, %31, %28, %25
%40 = phi i8* [ %24, %34 ], [ %33, %31 ], [ %30, %28 ], [ %27, %25 ]
%41 = load i8, i8* %40
br label %22
42: ; preds = %22
%43 = load i32, i32* %3
%44 = load i32, i32* %4
%45 = load i32, i32* %5
%46 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %43, i32 %44, i32 %45)
%47 = icmp sgt i32 %13, 0
%48 = add nsw i32 %13, -1
%49 = zext i32 %48 to i64
%50 = shl nuw nsw i64 %49, 2
%51 = add nuw nsw i64 %50, 4
%52 = select i1 %47, i64 %51, i64 0
%53 = getelementptr i8, i8* %24, i64 %52
%54 = getelementptr inbounds i8, i8* %53, i64 2
ret i8* %54
}