#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 */
unsigned char *get_asn_text(unsigned char *, char *, size_t);
unsigned char *get_asn_local_id(unsigned char *abp, char *acc, size_t acc_len) {
  int seqcnt = 0;
  if (*abp == 0x30) {
    abp += 2;
    seqcnt++;
  }
  abp = get_asn_text(abp + 2, acc, acc_len);
  while (seqcnt-- > 0)
    abp += 4;
  acc[acc_len - 1] = '\0';
  return abp + 2;
}


x86 assembly (clang, -O0):
<get_asn_local_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x30,%eax
jne    1150 <get_asn_local_id+0x40>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x2,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <get_asn_text@plt>
mov    %rax,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
jle    118e <get_asn_local_id+0x7e>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    1169 <get_asn_local_id+0x59>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_asn_local_id>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
xor    %ebx,%ebx
cmpb   $0x30,(%rdi)
sete   %bl
lea    (%rdi,%rbx,2),%rdi
add    $0x2,%rdi
call   1030 <get_asn_text@plt>
movb   $0x0,-0x1(%r14,%r15,1)
lea    (%rax,%rbx,4),%rax
add    $0x2,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @get_asn_local_id(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
store i32 0, i32* %7
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = icmp eq i32 %10, 48
br i1 %11, label %12, label %17
12: ; preds = %3
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 2
store i8* %14, i8** %4
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 1
store i32 %16, i32* %7
br label %17
17: ; preds = %12, %3
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = load i8*, i8** %5
%21 = load i64, i64* %6
%22 = call i8* @get_asn_text(i8* %19, i8* %20, i64 %21)
store i8* %22, i8** %4
br label %23
23: ; preds = %27, %17
%24 = load i32, i32* %7
%25 = add nsw i32 %24, -1
store i32 %25, i32* %7
%26 = icmp sgt i32 %24, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 4
store i8* %29, i8** %4
br label %23
30: ; preds = %23
%31 = load i8*, i8** %5
%32 = load i64, i64* %6
%33 = sub i64 %32, 1
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 0, i8* %34
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i64 2
ret i8* %36
}

LLVM IR (-O2):
define i8* @get_asn_local_id(i8* %0, i8* %1, i64 %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 48
%6 = select i1 %5, i64 2, i64 0
%7 = getelementptr i8, i8* %0, i64 %6
%8 = getelementptr inbounds i8, i8* %7, i64 2
%9 = tail call i8* @get_asn_text(i8* %8, i8* %1, i64 %2)
%10 = select i1 %5, i64 4, i64 0
%11 = getelementptr i8, i8* %9, i64 %10
%12 = add i64 %2, -1
%13 = getelementptr inbounds i8, i8* %1, i64 %12
store i8 0, i8* %13
%14 = getelementptr inbounds i8, i8* %11, i64 2
ret i8* %14
}