#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*/ strlen(char *);
int pkcs1_v1_5_msg_strip(char **message, size_t *message_len, const char *block,
                         const size_t block_len) {
  if (block_len < 2)
    return -1;
  *message = (char *)block + 2;
  *message += strlen(*message);
  if (((int)(*message - block)) > block_len)
    return -1;
  (*message)++;
  *message_len = block_len - (size_t)(*message - block);
  return 0x01;
}


x86 assembly (clang, -O0):
<pkcs1_v1_5_msg_strip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x2,-0x28(%rbp)
jae    113f <pkcs1_v1_5_msg_strip+0x2f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c3 <pkcs1_v1_5_msg_strip+0xb3>
mov    -0x20(%rbp),%rcx
add    $0x2,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
cltq
cmp    -0x28(%rbp),%rax
jbe    1192 <pkcs1_v1_5_msg_strip+0x82>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c3 <pkcs1_v1_5_msg_strip+0xb3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rdx
sub    %rdx,%rax
sub    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pkcs1_v1_5_msg_strip>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0xffffffff,%r12d
cmp    $0x2,%rcx
jb     116a <pkcs1_v1_5_msg_strip+0x5a>
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rbp
lea    0x2(%rdx),%rdi
mov    %rdi,0x0(%rbp)
call   1030 <strlen@plt>
cltq
add    0x0(%rbp),%rax
mov    %rax,0x0(%rbp)
mov    %eax,%ecx
sub    %ebx,%ecx
movslq %ecx,%rcx
cmp    %r15,%rcx
ja     116a <pkcs1_v1_5_msg_strip+0x5a>
add    $0x1,%rax
mov    %rax,0x0(%rbp)
add    %r15,%rbx
sub    %rax,%rbx
mov    %rbx,(%r14)
mov    $0x1,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @pkcs1_v1_5_msg_strip(i8** %0, i64* %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i64*
%8 = alloca i8*
%9 = alloca i64
store i8** %0, i8*** %6
store i64* %1, i64** %7
store i8* %2, i8** %8
store i64 %3, i64* %9
%10 = load i64, i64* %9
%11 = icmp ult i64 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %4
store i32 -1, i32* %5
br label %48
13: ; preds = %4
%14 = load i8*, i8** %8
%15 = getelementptr inbounds i8, i8* %14, i64 2
%16 = load i8**, i8*** %6
store i8* %15, i8** %16
%17 = load i8**, i8*** %6
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* %18)
%20 = load i8**, i8*** %6
%21 = load i8*, i8** %20
%22 = sext i32 %19 to i64
%23 = getelementptr inbounds i8, i8* %21, i64 %22
store i8* %23, i8** %20
%24 = load i8**, i8*** %6
%25 = load i8*, i8** %24
%26 = load i8*, i8** %8
%27 = ptrtoint i8* %25 to i64
%28 = ptrtoint i8* %26 to i64
%29 = sub i64 %27, %28
%30 = trunc i64 %29 to i32
%31 = sext i32 %30 to i64
%32 = load i64, i64* %9
%33 = icmp ugt i64 %31, %32
br i1 %33, label %34, label %35
34: ; preds = %13
store i32 -1, i32* %5
br label %48
35: ; preds = %13
%36 = load i8**, i8*** %6
%37 = load i8*, i8** %36
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %36
%39 = load i64, i64* %9
%40 = load i8**, i8*** %6
%41 = load i8*, i8** %40
%42 = load i8*, i8** %8
%43 = ptrtoint i8* %41 to i64
%44 = ptrtoint i8* %42 to i64
%45 = sub i64 %43, %44
%46 = sub i64 %39, %45
%47 = load i64*, i64** %7
store i64 %46, i64* %47
store i32 1, i32* %5
br label %48
48: ; preds = %35, %34, %12
%49 = load i32, i32* %5
ret i32 %49
}

LLVM IR (-O2):
define i32 @pkcs1_v1_5_msg_strip(i8** nocapture %0, i64* nocapture writeonly %1, i8* %2, i64 %3) {
%5 = icmp ult i64 %3, 2
br i1 %5, label %23, label %6
6: ; preds = %4
%7 = getelementptr inbounds i8, i8* %2, i64 2
store i8* %7, i8** %0
%8 = tail call i32 @strlen(i8* %7)
%9 = load i8*, i8** %0
%10 = sext i32 %8 to i64
%11 = getelementptr inbounds i8, i8* %9, i64 %10
store i8* %11, i8** %0
%12 = ptrtoint i8* %11 to i64
%13 = ptrtoint i8* %2 to i64
%14 = sub i64 %12, %13
%15 = shl i64 %14, 32
%16 = ashr exact i64 %15, 32
%17 = icmp ugt i64 %16, %3
br i1 %17, label %23, label %18
18: ; preds = %6
%19 = getelementptr inbounds i8, i8* %11, i64 1
store i8* %19, i8** %0
%20 = ptrtoint i8* %19 to i64
%21 = add i64 %13, %3
%22 = sub i64 %21, %20
store i64 %22, i64* %1
br label %23
23: ; preds = %6, %4, %18
%24 = phi i32 [ 1, %18 ], [ -1, %4 ], [ -1, %6 ]
ret i32 %24
}