#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int length;
  int /*<<< orphan*/ data;
};
typedef TYPE_1__ ASN1_STRING;

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned char *, int /*<<< orphan*/, int);
int GetAsn1StringBytes(ASN1_STRING *asn1, unsigned char *pBuf, int cBuf) {
  if (!asn1) {
    return 0;
  }
  if (!pBuf || cBuf < asn1->length) {
    return -asn1->length;
  }
  memcpy(pBuf, asn1->data, asn1->length);
  return 1;
}


x86 assembly (clang, -O0):
<GetAsn1StringBytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113a <GetAsn1StringBytes+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    1181 <GetAsn1StringBytes+0x71>
cmpq   $0x0,-0x18(%rbp)
je     1154 <GetAsn1StringBytes+0x44>
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    1164 <GetAsn1StringBytes+0x54>
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1181 <GetAsn1StringBytes+0x71>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
call   1030 <memcpy@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetAsn1StringBytes>:
push   %rax
test   %rdi,%rdi
je     1137 <GetAsn1StringBytes+0x27>
mov    (%rdi),%eax
test   %rsi,%rsi
je     113b <GetAsn1StringBytes+0x2b>
cmp    %edx,%eax
jg     113b <GetAsn1StringBytes+0x2b>
mov    0x4(%rdi),%ecx
mov    %rsi,%rdi
mov    %ecx,%esi
mov    %eax,%edx
call   1030 <memcpy@plt>
mov    $0x1,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret
neg    %eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
define i32 @GetAsn1StringBytes(%struct.TYPE_3__* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.TYPE_3__*
%6 = alloca i8*
%7 = alloca i32
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%9 = icmp ne %struct.TYPE_3__* %8, null
br i1 %9, label %11, label %10
10: ; preds = %3
store i32 0, i32* %4
br label %34
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32, i32* %7
%16 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = icmp slt i32 %15, %18
br i1 %19, label %20, label %25
20: ; preds = %14, %11
%21 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = sub nsw i32 0, %23
store i32 %24, i32* %4
br label %34
25: ; preds = %14
%26 = load i8*, i8** %6
%27 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%28 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %27, i32 0, i32 1
%29 = load i32, i32* %28
%30 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %30, i32 0, i32 0
%32 = load i32, i32* %31
%33 = call i32 @memcpy(i8* %26, i32 %29, i32 %32)
store i32 1, i32* %4
br label %34
34: ; preds = %25, %20, %10
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
define i32 @GetAsn1StringBytes(%struct.TYPE_3__* %0, i8* %1, i32 %2) {
%4 = icmp eq %struct.TYPE_3__* %0, null
br i1 %4, label %17, label %5
5: ; preds = %3
%6 = icmp eq i8* %1, null
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%8 = load i32, i32* %7
%9 = icmp sgt i32 %8, %2
%10 = select i1 %6, i1 true, i1 %9
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = sub nsw i32 0, %8
br label %17
13: ; preds = %5
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%15 = load i32, i32* %14
%16 = tail call i32 @memcpy(i8* %1, i32 %15, i32 %8)
br label %17
17: ; preds = %3, %13, %11
%18 = phi i32 [ %12, %11 ], [ 1, %13 ], [ 0, %3 ]
ret i32 %18
}