#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_R_DATA_TOO_LARGE;
int /*<<< orphan*/ RSAerror(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) {
    RSAerror(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    1170 <RSA_padding_check_none+0x40>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
call   1050 <RSAerror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11aa <RSA_padding_check_none+0x7a>
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    1155 <RSA_padding_check_none+0x25>
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
call   1050 <RSAerror@plt>
mov    $0xffffffff,%ebx
jmp    1179 <RSA_padding_check_none+0x49>
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_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 %18
15: ; preds = %5
%16 = load i32, i32* @RSA_R_DATA_TOO_LARGE
%17 = call i32 @RSAerror(i32 %16)
store i32 -1, i32* %6
br label %36
18: ; preds = %5
%19 = load i8*, i8** %7
%20 = load i32, i32* %8
%21 = load i32, i32* %10
%22 = sub nsw i32 %20, %21
%23 = call i32 @memset(i8* %19, i32 0, i32 %22)
%24 = load i8*, i8** %7
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = sub i64 0, %29
%31 = getelementptr inbounds i8, i8* %27, i64 %30
%32 = load i8*, i8** %9
%33 = load i32, i32* %10
%34 = call i32 @memcpy(i8* %31, i8* %32, i32 %33)
%35 = load i32, i32* %8
store i32 %35, i32* %6
br label %36
36: ; preds = %18, %15
%37 = load i32, i32* %6
ret i32 %37
}

LLVM IR (-O2):
@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 %10
7: ; preds = %5
%8 = load i32, i32* @RSA_R_DATA_TOO_LARGE
%9 = tail call i32 @RSAerror(i32 %8)
br label %19
10: ; preds = %5
%11 = sub nsw i32 %1, %3
%12 = tail call i32 @memset(i8* %0, i32 0, i32 %11)
%13 = sext i32 %1 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = sext i32 %3 to i64
%16 = sub nsw i64 0, %15
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = tail call i32 @memcpy(i8* %17, i8* %2, i32 %3)
br label %19
19: ; preds = %10, %7
%20 = phi i32 [ -1, %7 ], [ %1, %10 ]
ret i32 %20
}