#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 */
int /*<<< orphan*/ RSA_F_RSA_PADDING_CHECK_NONE;
int /*<<< orphan*/ RSA_R_DATA_TOO_LARGE;
int /*<<< orphan*/ RSAerr(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int RSA_padding_check_none(unsigned char *to, int tlen,
                           const unsigned char *from, int flen, int num) {
  if (flen > tlen) {
    RSAerr(RSA_F_RSA_PADDING_CHECK_NONE, RSA_R_DATA_TOO_LARGE);
    return -1;
  }
  memset(to, 0, tlen - flen);
  memcpy(to + tlen - flen, from, flen);
  return tlen;
}


x86 assembly (clang, -O0):
<RSA_padding_check_none>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1179 <RSA_padding_check_none+0x49>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
call   1050 <RSAerr@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b3 <RSA_padding_check_none+0x83>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    -0x24(%rbp),%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
movslq -0x24(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RSA_padding_check_none>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%edx
sub    %ecx,%edx
jge    115e <RSA_padding_check_none+0x2e>
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
call   1050 <RSAerr@plt>
mov    $0xffffffff,%ebx
jmp    1182 <RSA_padding_check_none+0x52>
mov    %ecx,%ebp
mov    %esi,%ebx
mov    %rdi,%r15
xor    %esi,%esi
call   1030 <memset@plt>
movslq %ebx,%rdi
add    %r15,%rdi
movslq %ebp,%rax
sub    %rax,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <memcpy@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@RSA_F_RSA_PADDING_CHECK_NONE = global i32 0
@RSA_R_DATA_TOO_LARGE = global i32 0
define i32 @RSA_padding_check_none(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %1, %3
br i1 %6, label %7, label %11
7: ; preds = %5
%8 = load i32, i32* @RSA_F_RSA_PADDING_CHECK_NONE
%9 = load i32, i32* @RSA_R_DATA_TOO_LARGE
%10 = tail call i32 @RSAerr(i32 %8, i32 %9)
br label %20
11: ; preds = %5
%12 = sub nsw i32 %1, %3
%13 = tail call i32 @memset(i8* %0, i32 0, i32 %12)
%14 = sext i32 %1 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = sext i32 %3 to i64
%17 = sub nsw i64 0, %16
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = tail call i32 @memcpy(i8* %18, i8* %2, i32 %3)
br label %20
20: ; preds = %11, %7
%21 = phi i32 [ -1, %7 ], [ %1, %11 ]
ret i32 %21
}