#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 */
struct NetFrame {
  int dummy;
};

/* Variables and functions */
unsigned int asn1_length(struct NetFrame *, unsigned char const *, unsigned int,
                         unsigned int *);
int /*<<< orphan*/ asn1_tag(unsigned char const *, unsigned int,
                            unsigned int *);
void asn1_string(struct NetFrame *frame, const unsigned char *px,
                 unsigned length, unsigned *r_offset,
                 const unsigned char **r_str, unsigned *r_str_length) {
  unsigned len;
  if (*r_offset >= length)
    return;
  asn1_tag(px, length, r_offset);
  len = asn1_length(frame, px, length, r_offset);
  *r_str = px + *r_offset;
  *r_str_length = len;
  *r_offset += len;
}


x86 assembly (clang, -O0):
<asn1_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cmp    -0x14(%rbp),%eax
jb     1153 <asn1_string+0x33>
jmp    11a2 <asn1_string+0x82>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <asn1_tag@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1030 <asn1_length@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
add    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x34(%rbp),%ecx
mov    -0x20(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asn1_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    %edx,(%rcx)
jae    116a <asn1_string+0x4a>
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %rsi,%r12
mov    %rdi,%r13
mov    %rsi,%rdi
mov    %edx,%esi
mov    %rcx,%rdx
call   1040 <asn1_tag@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1030 <asn1_length@plt>
mov    (%rbx),%ecx
add    %r12,%rcx
mov    %rcx,(%r15)
mov    %eax,(%r14)
add    %eax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.NetFrame = type { i32 }
define void @asn1_string(%struct.NetFrame* %0, i8* %1, i32 %2, i32* %3, i8** %4, i32* %5) {
%7 = alloca %struct.NetFrame*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i8**
%12 = alloca i32*
%13 = alloca i32
store %struct.NetFrame* %0, %struct.NetFrame** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32* %3, i32** %10
store i8** %4, i8*** %11
store i32* %5, i32** %12
%14 = load i32*, i32** %10
%15 = load i32, i32* %14
%16 = load i32, i32* %9
%17 = icmp uge i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %6
br label %41
19: ; preds = %6
%20 = load i8*, i8** %8
%21 = load i32, i32* %9
%22 = load i32*, i32** %10
%23 = call i32 @asn1_tag(i8* %20, i32 %21, i32* %22)
%24 = load %struct.NetFrame*, %struct.NetFrame** %7
%25 = load i8*, i8** %8
%26 = load i32, i32* %9
%27 = load i32*, i32** %10
%28 = call i32 @asn1_length(%struct.NetFrame* %24, i8* %25, i32 %26, i32* %27)
store i32 %28, i32* %13
%29 = load i8*, i8** %8
%30 = load i32*, i32** %10
%31 = load i32, i32* %30
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
%34 = load i8**, i8*** %11
store i8* %33, i8** %34
%35 = load i32, i32* %13
%36 = load i32*, i32** %12
store i32 %35, i32* %36
%37 = load i32, i32* %13
%38 = load i32*, i32** %10
%39 = load i32, i32* %38
%40 = add i32 %39, %37
store i32 %40, i32* %38
br label %41
41: ; preds = %19, %18
ret void
}

LLVM IR (-O2):
%struct.NetFrame = type { i32 }
define void @asn1_string(%struct.NetFrame* %0, i8* %1, i32 %2, i32* %3, i8** nocapture writeonly %4, i32* nocapture writeonly %5) {
%7 = load i32, i32* %3
%8 = icmp ult i32 %7, %2
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = tail call i32 @asn1_tag(i8* %1, i32 %2, i32* %3)
%11 = tail call i32 @asn1_length(%struct.NetFrame* %0, i8* %1, i32 %2, i32* %3)
%12 = load i32, i32* %3
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %1, i64 %13
store i8* %14, i8** %4
store i32 %11, i32* %5
%15 = load i32, i32* %3
%16 = add i32 %15, %11
store i32 %16, i32* %3
br label %17
17: ; preds = %6, %9
ret void
}