#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ const *,
                          size_t);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int, size_t);
int /*<<< orphan*/ printf(char *);
int rsa_padding_check_none(uint8_t *to, int tlen, const uint8_t *from, int flen,
                           int num) {
  (void)&(num);
  if (flen > tlen) {
    printf("from length larger than to length\n");
    return -1;
  }
  (void)memset(to, 0x0, (size_t)(tlen - flen));
  (void)memcpy(to + tlen - flen, from, (size_t)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    116e <rsa_padding_check_none+0x3e>
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <rsa_padding_check_none+0x84>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
sub    -0x24(%rbp),%eax
movslq %eax,%rdx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
movslq -0x24(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
movslq -0x24(%rbp),%rdx
call   1050 <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    %esi,%eax
sub    %ecx,%eax
jge    1150 <rsa_padding_check_none+0x20>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
jmp    1181 <rsa_padding_check_none+0x51>
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %esi,%ebx
mov    %rdi,%r15
movslq %eax,%rdx
xor    %esi,%esi
call   1040 <memset@plt>
movslq %ebx,%rax
lea    (%r15,%rax,4),%rdi
movslq %ebp,%rdx
lea    0x0(,%rdx,4),%rax
sub    %rax,%rdi
mov    %r14,%rsi
call   1050 <memcpy@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"from length larger than to length\0A\00"
define i32 @rsa_padding_check_none(i32* %0, i32 %1, i32* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %7
store i32 %1, i32* %8
store i32* %2, i32** %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 %17
15: ; preds = %5
%16 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %6
br label %37
17: ; preds = %5
%18 = load i32*, i32** %7
%19 = load i32, i32* %8
%20 = load i32, i32* %10
%21 = sub nsw i32 %19, %20
%22 = sext i32 %21 to i64
%23 = call i32 @memset(i32* %18, i32 0, i64 %22)
%24 = load i32*, i32** %7
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = sub i64 0, %29
%31 = getelementptr inbounds i32, i32* %27, i64 %30
%32 = load i32*, i32** %9
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = call i32 @memcpy(i32* %31, i32* %32, i64 %34)
%36 = load i32, i32* %8
store i32 %36, i32* %6
br label %37
37: ; preds = %17, %15
%38 = load i32, i32* %6
ret i32 %38
}

LLVM IR (-O2):
@str = [34 x i8] c"from length larger than to length\00"
define i32 @rsa_padding_check_none(i32* %0, i32 %1, i32* %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %1, %3
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %19
9: ; preds = %5
%10 = sub nsw i32 %1, %3
%11 = sext i32 %10 to i64
%12 = tail call i32 @memset(i32* %0, i32 0, i64 %11)
%13 = sext i32 %1 to i64
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = sext i32 %3 to i64
%16 = sub nsw i64 0, %15
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = tail call i32 @memcpy(i32* %17, i32* %2, i64 %15)
br label %19
19: ; preds = %9, %7
%20 = phi i32 [ -1, %7 ], [ %1, %9 ]
ret i32 %20
}