#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 */
long ASNDerCalcElementLength(long, long *);
long ASNDerWriteToken(unsigned char *, unsigned char, unsigned char *, long);
int ASNDerWriteElement(unsigned char *pbData, unsigned char ucElementSequence,
                       unsigned char ucType, unsigned char *pbTokenValue,
                       long nLength) {
  long nInternalLength = 0L;
  long nElementLength = ASNDerCalcElementLength(nLength, &nInternalLength);
  long nTempLength = 0L;
  nTempLength =
      ASNDerWriteToken(pbData, ucElementSequence, NULL, nInternalLength);
  pbData += nTempLength;
  nTempLength = ASNDerWriteToken(pbData, ucType, pbTokenValue, nLength);
  return nElementLength;
}


x86 assembly (clang, -O0):
<ASNDerWriteElement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %rdi,-0x8(%rbp)
mov    %dl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <ASNDerCalcElementLength@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x9(%rbp),%al
mov    -0x28(%rbp),%rcx
xor    %edx,%edx
movzbl %al,%esi
call   1040 <ASNDerWriteToken@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xa(%rbp),%al
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
movzbl %al,%esi
call   1040 <ASNDerWriteToken@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASNDerWriteElement>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbx
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbp
movq   $0x0,(%rsp)
mov    %rsp,%rsi
mov    %r8,%rdi
call   1030 <ASNDerCalcElementLength@plt>
mov    %rax,%r13
mov    (%rsp),%rcx
mov    %rbp,%rdi
mov    %r12d,%esi
xor    %edx,%edx
call   1040 <ASNDerWriteToken@plt>
add    %rax,%rbp
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1040 <ASNDerWriteToken@plt>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ASNDerWriteElement(i8* %0, i8 zeroext %1, i8 zeroext %2, i8* %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
store i8* %0, i8** %6
store i8 %1, i8* %7
store i8 %2, i8* %8
store i8* %3, i8** %9
store i64 %4, i64* %10
store i64 0, i64* %11
%14 = load i64, i64* %10
%15 = call i64 @ASNDerCalcElementLength(i64 %14, i64* %11)
store i64 %15, i64* %12
store i64 0, i64* %13
%16 = load i8*, i8** %6
%17 = load i8, i8* %7
%18 = load i64, i64* %11
%19 = call i64 @ASNDerWriteToken(i8* %16, i8 zeroext %17, i8* null, i64 %18)
store i64 %19, i64* %13
%20 = load i64, i64* %13
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i64 %20
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = load i8, i8* %8
%25 = load i8*, i8** %9
%26 = load i64, i64* %10
%27 = call i64 @ASNDerWriteToken(i8* %23, i8 zeroext %24, i8* %25, i64 %26)
store i64 %27, i64* %13
%28 = load i64, i64* %12
%29 = trunc i64 %28 to i32
ret i32 %29
}

LLVM IR (-O2):
define i32 @ASNDerWriteElement(i8* %0, i8 zeroext %1, i8 zeroext %2, i8* %3, i64 %4) {
%6 = alloca i64
%7 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%8 = call i64 @ASNDerCalcElementLength(i64 %4, i64* %6)
%9 = load i64, i64* %6
%10 = call i64 @ASNDerWriteToken(i8* %0, i8 zeroext %1, i8* null, i64 %9)
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = call i64 @ASNDerWriteToken(i8* %11, i8 zeroext %2, i8* %3, i64 %4)
%13 = trunc i64 %8 to i32
ret i32 %13
}