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

/* Variables and functions */
unsigned char *get_asn_int(unsigned char *, int *);
unsigned char *get_asn_text(unsigned char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, scalar_t__);
unsigned char *get_asn_textseq_id(unsigned char *abp, char *name,
                                  size_t name_len, char *acc, size_t acc_len) {
  char release[20], ver_str[10];
  int version;
  int seqcnt = 0;
  ver_str[0] = '\0';
  if (*abp == 0x30) {
    abp += 2;
    seqcnt++;
  }
  while (*abp) {
    switch (*abp) {
    case 0xa0:
      abp = get_asn_text(abp + 2, name, name_len);
      break;
    case 0xa1:
      abp = get_asn_text(abp + 2, acc, acc_len);
      break;
    case 0xa2:
      abp = get_asn_text(abp + 2, release, sizeof(release));
      break;
    case 0xa3:
      abp = get_asn_int(abp + 2, &version);
      sprintf(ver_str, ".%d", version);
      break;
    default:
      abp += 2;
    }
  }
  while (seqcnt-- > 0)
    abp += 4;
  strncat(acc, ver_str, acc_len - strlen(acc));
  acc[19] = '\0';
  return abp;
}


x86 assembly (clang, -O0):
<get_asn_textseq_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x54(%rbp)
movb   $0x0,-0x4a(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x30,%eax
jne    119f <get_asn_textseq_id+0x4f>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11a4 <get_asn_textseq_id+0x54>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     127d <get_asn_textseq_id+0x12d>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
add    $0xffffff60,%eax
mov    %eax,%ecx
mov    %rcx,-0x60(%rbp)
sub    $0x3,%eax
ja     126c <get_asn_textseq_id+0x11c>
mov    -0x60(%rbp),%rax
lea    0xe29(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    %eax,%edx
call   1060 <get_asn_text@plt>
mov    %rax,-0x8(%rbp)
jmp    1278 <get_asn_textseq_id+0x128>
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    %eax,%edx
call   1060 <get_asn_text@plt>
mov    %rax,-0x8(%rbp)
jmp    1278 <get_asn_textseq_id+0x128>
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
lea    -0x40(%rbp),%rsi
mov    $0x14,%edx
call   1060 <get_asn_text@plt>
mov    %rax,-0x8(%rbp)
jmp    1278 <get_asn_textseq_id+0x128>
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
lea    -0x50(%rbp),%rsi
call   1030 <get_asn_int@plt>
mov    %rax,-0x8(%rbp)
lea    -0x4a(%rbp),%rdi
mov    -0x50(%rbp),%edx
lea    0xdae(%rip),%rsi
call   1070 <sprintf@plt>
jmp    1278 <get_asn_textseq_id+0x128>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    11a4 <get_asn_textseq_id+0x54>
jmp    1282 <get_asn_textseq_id+0x132>
mov    -0x54(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x54(%rbp)
cmp    $0x0,%eax
jle    12a7 <get_asn_textseq_id+0x157>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    1282 <get_asn_textseq_id+0x132>
mov    -0x20(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x4a(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x78(%rbp),%rdx
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rsi
sub    %rax,%rdx
call   1050 <strncat@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,0x13(%rax)
mov    -0x8(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_asn_textseq_id>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,%r15
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%rbx
movb   $0x0,0x16(%rsp)
mov    (%rdi),%cl
xor    %eax,%eax
mov    %cl,0xf(%rsp)
cmp    $0x30,%cl
sete   %al
lea    (%rdi,%rax,2),%r13
lea    0xe78(%rip),%rbp
jmp    119f <get_asn_textseq_id+0x4f>
add    $0x2,%r13
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1060 <get_asn_text@plt>
mov    %rax,%r13
movzbl 0x0(%r13),%eax
lea    0x60(%rax),%ecx
cmp    $0x3,%cl
ja     11d0 <get_asn_textseq_id+0x80>
movzbl %cl,%eax
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
add    $0x2,%r13
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
jmp    1197 <get_asn_textseq_id+0x47>
nopl   0x0(%rax,%rax,1)
test   %al,%al
je     1218 <get_asn_textseq_id+0xc8>
add    $0x2,%r13
jmp    119f <get_asn_textseq_id+0x4f>
add    $0x2,%r13
mov    %r13,%rdi
lea    0x20(%rsp),%rsi
mov    $0x14,%edx
jmp    1197 <get_asn_textseq_id+0x47>
add    $0x2,%r13
mov    %r13,%rdi
lea    0x10(%rsp),%rsi
call   1030 <get_asn_int@plt>
mov    %rax,%r13
mov    0x10(%rsp),%edx
lea    0x16(%rsp),%rdi
lea    0xdff(%rip),%rsi
call   1070 <sprintf@plt>
jmp    119f <get_asn_textseq_id+0x4f>
xor    %eax,%eax
cmpb   $0x30,0xf(%rsp)
sete   %al
lea    0x0(,%rax,4),%rbx
add    %r13,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
sub    %rax,%r15
lea    0x16(%rsp),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
call   1050 <strncat@plt>
movb   $0x0,0x13(%r14)
mov    %rbx,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c".%d\00"
define i8* @get_asn_textseq_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 [20 x i8]
%12 = alloca [10 x i8]
%13 = alloca i32
%14 = alloca i32
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* %14
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 0, i64 0
store i8 0, i8* %15
%16 = load i8*, i8** %6
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = icmp eq i32 %18, 48
br i1 %19, label %20, label %25
20: ; preds = %5
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i64 2
store i8* %22, i8** %6
%23 = load i32, i32* %14
%24 = add nsw i32 %23, 1
store i32 %24, i32* %14
br label %25
25: ; preds = %20, %5
br label %26
26: ; preds = %63, %25
%27 = load i8*, i8** %6
%28 = load i8, i8* %27
%29 = icmp ne i8 %28, 0
br i1 %29, label %30, label %64
30: ; preds = %26
%31 = load i8*, i8** %6
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
switch i32 %33, label %60 [
i32 160, label %34
i32 161, label %41
i32 162, label %48
i32 163, label %53
]
34: ; preds = %30
%35 = load i8*, i8** %6
%36 = getelementptr inbounds i8, i8* %35, i64 2
%37 = load i8*, i8** %7
%38 = load i64, i64* %8
%39 = trunc i64 %38 to i32
%40 = call i8* @get_asn_text(i8* %36, i8* %37, i32 %39)
store i8* %40, i8** %6
br label %63
41: ; preds = %30
%42 = load i8*, i8** %6
%43 = getelementptr inbounds i8, i8* %42, i64 2
%44 = load i8*, i8** %9
%45 = load i64, i64* %10
%46 = trunc i64 %45 to i32
%47 = call i8* @get_asn_text(i8* %43, i8* %44, i32 %46)
store i8* %47, i8** %6
br label %63
48: ; preds = %30
%49 = load i8*, i8** %6
%50 = getelementptr inbounds i8, i8* %49, i64 2
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%52 = call i8* @get_asn_text(i8* %50, i8* %51, i32 20)
store i8* %52, i8** %6
br label %63
53: ; preds = %30
%54 = load i8*, i8** %6
%55 = getelementptr inbounds i8, i8* %54, i64 2
%56 = call i8* @get_asn_int(i8* %55, i32* %13)
store i8* %56, i8** %6
%57 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 0, i64 0
%58 = load i32, i32* %13
%59 = call i32 @sprintf(i8* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %58)
br label %63
60: ; preds = %30
%61 = load i8*, i8** %6
%62 = getelementptr inbounds i8, i8* %61, i64 2
store i8* %62, i8** %6
br label %63
63: ; preds = %60, %53, %48, %41, %34
br label %26
64: ; preds = %26
br label %65
65: ; preds = %69, %64
%66 = load i32, i32* %14
%67 = add nsw i32 %66, -1
store i32 %67, i32* %14
%68 = icmp sgt i32 %66, 0
br i1 %68, label %69, label %72
69: ; preds = %65
%70 = load i8*, i8** %6
%71 = getelementptr inbounds i8, i8* %70, i64 4
store i8* %71, i8** %6
br label %65
72: ; preds = %65
%73 = load i8*, i8** %9
%74 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 0, i64 0
%75 = load i64, i64* %10
%76 = load i8*, i8** %9
%77 = call i64 @strlen(i8* %76)
%78 = sub i64 %75, %77
%79 = call i32 @strncat(i8* %73, i8* %74, i64 %78)
%80 = load i8*, i8** %9
%81 = getelementptr inbounds i8, i8* %80, i64 19
store i8 0, i8* %81
%82 = load i8*, i8** %6
ret i8* %82
}

LLVM IR (-O2):
@.str = [4 x i8] c".%d\00"
define i8* @get_asn_textseq_id(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4) {
%6 = alloca [20 x i8]
%7 = alloca [10 x i8]
%8 = alloca i32
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%11 = bitcast i32* %8 to i8*
store i8 0, i8* %10
%12 = load i8, i8* %0
%13 = icmp eq i8 %12, 48
%14 = select i1 %13, i64 2, i64 0
%15 = getelementptr i8, i8* %0, i64 %14
%16 = trunc i64 %4 to i32
%17 = trunc i64 %2 to i32
br label %18
18: ; preds = %44, %5
%19 = phi i8* [ %15, %5 ], [ %45, %44 ]
%20 = load i8, i8* %19
switch i8 %20, label %42 [
i8 0, label %21
i8 -96, label %28
i8 -95, label %31
i8 -94, label %34
i8 -93, label %37
]
21: ; preds = %18
%22 = select i1 %13, i64 4, i64 0
%23 = getelementptr i8, i8* %19, i64 %22
%24 = call i64 @strlen(i8* dereferenceable(1) %3)
%25 = sub i64 %4, %24
%26 = call i32 @strncat(i8* %3, i8* %10, i64 %25)
%27 = getelementptr inbounds i8, i8* %3, i64 19
store i8 0, i8* %27
ret i8* %23
28: ; preds = %18
%29 = getelementptr inbounds i8, i8* %19, i64 2
%30 = call i8* @get_asn_text(i8* %29, i8* %1, i32 %17)
br label %44
31: ; preds = %18
%32 = getelementptr inbounds i8, i8* %19, i64 2
%33 = call i8* @get_asn_text(i8* %32, i8* %3, i32 %16)
br label %44
34: ; preds = %18
%35 = getelementptr inbounds i8, i8* %19, i64 2
%36 = call i8* @get_asn_text(i8* %35, i8* %9, i32 20)
br label %44
37: ; preds = %18
%38 = getelementptr inbounds i8, i8* %19, i64 2
%39 = call i8* @get_asn_int(i8* %38, i32* %8)
%40 = load i32, i32* %8
%41 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %40)
br label %44
42: ; preds = %18
%43 = getelementptr inbounds i8, i8* %19, i64 2
br label %44
44: ; preds = %42, %37, %34, %31, %28
%45 = phi i8* [ %43, %42 ], [ %39, %37 ], [ %36, %34 ], [ %33, %31 ], [ %30, %28 ]
br label %18
}