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

/* Variables and functions */
unsigned char *get_asn_date(unsigned char *, char *, int);
unsigned char *get_asn_int(unsigned char *, int *);
unsigned char *get_asn_text(unsigned char *, char *, int);
unsigned char *get_asn_pdb_id(unsigned char *abp, char *acc, size_t acc_len,
                              char *chain, size_t chain_len) {
  int ichain, seq_cnt = 0;
  char dummy[40];
  if (*abp == 0x30) {
    abp += 2;
    seq_cnt++;
  }
  while (*abp) {
    switch (*abp) {
    case 0:
      abp += 2;
      break;
    case 0xa0:
      abp = get_asn_text(abp + 2, acc, 20);
      break;
    case 0xa1:
      abp = get_asn_int(abp + 2, &ichain);
      chain[0] = ichain;
      chain[1] = '\0';
      break;
    case 0xa2:
      abp = get_asn_date(abp + 2, dummy, sizeof(dummy));
      break;
    default:
      abp += 2;
    }
  }
  while (seq_cnt-- > 0) {
    abp += 4;
  }
  return abp;
}


x86 assembly (clang, -O0):
<get_asn_pdb_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x30,%eax
jne    1178 <get_asn_pdb_id+0x48>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    117d <get_asn_pdb_id+0x4d>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1267 <get_asn_pdb_id+0x137>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x64(%rbp)
test   %eax,%eax
je     11da <get_asn_pdb_id+0xaa>
jmp    11a1 <get_asn_pdb_id+0x71>
mov    -0x64(%rbp),%eax
sub    $0xa0,%eax
je     11eb <get_asn_pdb_id+0xbb>
jmp    11b4 <get_asn_pdb_id+0x84>
mov    -0x64(%rbp),%eax
sub    $0xa1,%eax
je     120a <get_asn_pdb_id+0xda>
jmp    11c7 <get_asn_pdb_id+0x97>
mov    -0x64(%rbp),%eax
sub    $0xa2,%eax
je     1237 <get_asn_pdb_id+0x107>
jmp    1256 <get_asn_pdb_id+0x126>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    1262 <get_asn_pdb_id+0x132>
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x14,%edx
call   1040 <get_asn_text@plt>
mov    %rax,-0x8(%rbp)
jmp    1262 <get_asn_pdb_id+0x132>
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
lea    -0x2c(%rbp),%rsi
call   1030 <get_asn_int@plt>
mov    %rax,-0x8(%rbp)
mov    -0x2c(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,0x1(%rax)
jmp    1262 <get_asn_pdb_id+0x132>
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
lea    -0x60(%rbp),%rsi
mov    $0x28,%edx
call   1050 <get_asn_date@plt>
mov    %rax,-0x8(%rbp)
jmp    1262 <get_asn_pdb_id+0x132>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    117d <get_asn_pdb_id+0x4d>
jmp    126c <get_asn_pdb_id+0x13c>
mov    -0x30(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x30(%rbp)
cmp    $0x0,%eax
jle    1291 <get_asn_pdb_id+0x161>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    126c <get_asn_pdb_id+0x13c>
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_asn_pdb_id>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rcx,%rbx
mov    %rsi,%r14
mov    (%rdi),%bpl
xor    %eax,%eax
cmp    $0x30,%bpl
sete   %al
lea    (%rdi,%rax,2),%rax
lea    0xc(%rsp),%r15
lea    0x10(%rsp),%r12
jmp    1174 <get_asn_pdb_id+0x44>
xchg   %ax,%ax
add    $0x2,%rax
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x14,%edx
call   1040 <get_asn_text@plt>
movzbl (%rax),%ecx
cmp    $0xa1,%cl
jg     11b0 <get_asn_pdb_id+0x80>
cmp    $0xa0,%cl
je     1160 <get_asn_pdb_id+0x30>
cmp    $0xa1,%cl
jne    11cf <get_asn_pdb_id+0x9f>
add    $0x2,%rax
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <get_asn_int@plt>
movzbl 0xc(%rsp),%ecx
mov    %cl,(%rbx)
movb   $0x0,0x1(%rbx)
jmp    1174 <get_asn_pdb_id+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0xa2,%cl
jne    11cb <get_asn_pdb_id+0x9b>
add    $0x2,%rax
mov    %rax,%rdi
mov    %r12,%rsi
mov    $0x28,%edx
call   1050 <get_asn_date@plt>
jmp    1174 <get_asn_pdb_id+0x44>
test   %cl,%cl
je     11d5 <get_asn_pdb_id+0xa5>
add    $0x2,%rax
jmp    1174 <get_asn_pdb_id+0x44>
xor    %ecx,%ecx
cmp    $0x30,%bpl
sete   %cl
lea    (%rax,%rcx,4),%rax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @get_asn_pdb_id(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca [40 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i64 %4, i64* %10
store i32 0, i32* %12
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = icmp eq i32 %16, 48
br i1 %17, label %18, label %23
18: ; preds = %5
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i64 2
store i8* %20, i8** %6
%21 = load i32, i32* %12
%22 = add nsw i32 %21, 1
store i32 %22, i32* %12
br label %23
23: ; preds = %18, %5
br label %24
24: ; preds = %58, %23
%25 = load i8*, i8** %6
%26 = load i8, i8* %25
%27 = icmp ne i8 %26, 0
br i1 %27, label %28, label %59
28: ; preds = %24
%29 = load i8*, i8** %6
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
switch i32 %31, label %55 [
i32 0, label %32
i32 160, label %35
i32 161, label %40
i32 162, label %50
]
32: ; preds = %28
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 2
store i8* %34, i8** %6
br label %58
35: ; preds = %28
%36 = load i8*, i8** %6
%37 = getelementptr inbounds i8, i8* %36, i64 2
%38 = load i8*, i8** %7
%39 = call i8* @get_asn_text(i8* %37, i8* %38, i32 20)
store i8* %39, i8** %6
br label %58
40: ; preds = %28
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i64 2
%43 = call i8* @get_asn_int(i8* %42, i32* %11)
store i8* %43, i8** %6
%44 = load i32, i32* %11
%45 = trunc i32 %44 to i8
%46 = load i8*, i8** %9
%47 = getelementptr inbounds i8, i8* %46, i64 0
store i8 %45, i8* %47
%48 = load i8*, i8** %9
%49 = getelementptr inbounds i8, i8* %48, i64 1
store i8 0, i8* %49
br label %58
50: ; preds = %28
%51 = load i8*, i8** %6
%52 = getelementptr inbounds i8, i8* %51, i64 2
%53 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%54 = call i8* @get_asn_date(i8* %52, i8* %53, i32 40)
store i8* %54, i8** %6
br label %58
55: ; preds = %28
%56 = load i8*, i8** %6
%57 = getelementptr inbounds i8, i8* %56, i64 2
store i8* %57, i8** %6
br label %58
58: ; preds = %55, %50, %40, %35, %32
br label %24
59: ; preds = %24
br label %60
60: ; preds = %64, %59
%61 = load i32, i32* %12
%62 = add nsw i32 %61, -1
store i32 %62, i32* %12
%63 = icmp sgt i32 %61, 0
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = load i8*, i8** %6
%66 = getelementptr inbounds i8, i8* %65, i64 4
store i8* %66, i8** %6
br label %60
67: ; preds = %60
%68 = load i8*, i8** %6
ret i8* %68
}

LLVM IR (-O2):
define i8* @get_asn_pdb_id(i8* %0, i8* %1, i64 %2, i8* nocapture writeonly %3, i64 %4) {
%6 = alloca i32
%7 = alloca [40 x i8]
%8 = bitcast i32* %6 to i8*
%9 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%10 = load i8, i8* %0
%11 = icmp eq i8 %10, 48
%12 = select i1 %11, i64 2, i64 0
%13 = getelementptr i8, i8* %0, i64 %12
%14 = getelementptr inbounds i8, i8* %3, i64 1
br label %15
15: ; preds = %34, %5
%16 = phi i8* [ %13, %5 ], [ %35, %34 ]
%17 = load i8, i8* %16
switch i8 %17, label %32 [
i8 0, label %18
i8 -94, label %29
i8 -96, label %21
i8 -95, label %24
]
18: ; preds = %15
%19 = select i1 %11, i64 4, i64 0
%20 = getelementptr i8, i8* %16, i64 %19
ret i8* %20
21: ; preds = %15
%22 = getelementptr inbounds i8, i8* %16, i64 2
%23 = call i8* @get_asn_text(i8* %22, i8* %1, i32 20)
br label %34
24: ; preds = %15
%25 = getelementptr inbounds i8, i8* %16, i64 2
%26 = call i8* @get_asn_int(i8* %25, i32* %6)
%27 = load i32, i32* %6
%28 = trunc i32 %27 to i8
store i8 %28, i8* %3
store i8 0, i8* %14
br label %34
29: ; preds = %15
%30 = getelementptr inbounds i8, i8* %16, i64 2
%31 = call i8* @get_asn_date(i8* %30, i8* %9, i32 40)
br label %34
32: ; preds = %15
%33 = getelementptr inbounds i8, i8* %16, i64 2
br label %34
34: ; preds = %32, %29, %24, %21
%35 = phi i8* [ %33, %32 ], [ %31, %29 ], [ %26, %24 ], [ %23, %21 ]
br label %15
}