#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*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int, int);
int RSA_insert_padding(char *source, char *target, int sourceLen, int targetLen,
                       int padding) {
  if (sourceLen + padding > targetLen)
    return 0;
  memcpy(target, source, sourceLen);
  memset(target + sourceLen, padding, padding);
  return 1;
}


x86 assembly (clang, -O0):
<RSA_insert_padding>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    1155 <RSA_insert_padding+0x35>
movl   $0x0,-0x4(%rbp)
jmp    1182 <RSA_insert_padding+0x62>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <memset@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RSA_insert_padding>:
push   %r15
push   %r14
push   %rbx
mov    %r8d,%r15d
mov    %edx,%ebx
lea    (%r15,%rbx,1),%edx
xor    %eax,%eax
cmp    %ecx,%edx
jg     115a <RSA_insert_padding+0x3a>
mov    %rsi,%r14
mov    %rdi,%rsi
mov    %r14,%rdi
mov    %ebx,%edx
call   1040 <memcpy@plt>
movslq %ebx,%rdi
add    %r14,%rdi
mov    %r15d,%esi
mov    %r15d,%edx
call   1030 <memset@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @RSA_insert_padding(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = add nsw i32 %4, %2
%7 = icmp sgt i32 %6, %3
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = tail call i32 @memcpy(i8* %1, i8* %0, i32 %2)
%10 = sext i32 %2 to i64
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = tail call i32 @memset(i8* %11, i32 %4, i32 %4)
br label %13
13: ; preds = %5, %8
%14 = phi i32 [ 1, %8 ], [ 0, %5 ]
ret i32 %14
}