#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 ssh1_read_bignum(unsigned char *, int, int /*<<< orphan*/ *);
int rsa_public_blob_len(void *data, int maxlen) {
  unsigned char *p = (unsigned char *)data;
  int n;
  if (maxlen < 4)
    return -1;
  p += 4;
  maxlen -= 4;
  n = ssh1_read_bignum(p, maxlen, NULL);
  if (n < 0)
    return -1;
  p += n;
  n = ssh1_read_bignum(p, maxlen, NULL);
  if (n < 0)
    return -1;
  p += n;
  return p - (unsigned char *)data;
}


x86 assembly (clang, -O0):
<rsa_public_blob_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    113d <rsa_public_blob_len+0x2d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d4 <rsa_public_blob_len+0xc4>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <ssh1_read_bignum@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    117b <rsa_public_blob_len+0x6b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d4 <rsa_public_blob_len+0xc4>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <ssh1_read_bignum@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11b5 <rsa_public_blob_len+0xa5>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d4 <rsa_public_blob_len+0xc4>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rsa_public_blob_len>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%r15d
cmp    $0x4,%esi
jl     115b <rsa_public_blob_len+0x4b>
mov    %esi,%ebp
mov    %rdi,%r14
lea    0x4(%rdi),%rbx
add    $0xfffffffc,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
call   1030 <ssh1_read_bignum@plt>
test   %eax,%eax
js     115b <rsa_public_blob_len+0x4b>
mov    %eax,%eax
add    %rax,%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
call   1030 <ssh1_read_bignum@plt>
test   %eax,%eax
js     115b <rsa_public_blob_len+0x4b>
add    %eax,%ebx
sub    %r14d,%ebx
mov    %ebx,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @rsa_public_blob_len(i8* %0, i32 %1) {
%3 = icmp slt i32 %1, 4
br i1 %3, label %21, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8, i8* %0, i64 4
%6 = add nsw i32 %1, -4
%7 = tail call i32 @ssh1_read_bignum(i8* %5, i32 %6, i32* null)
%8 = icmp slt i32 %7, 0
br i1 %8, label %21, label %9
9: ; preds = %4
%10 = zext i32 %7 to i64
%11 = getelementptr inbounds i8, i8* %5, i64 %10
%12 = tail call i32 @ssh1_read_bignum(i8* %11, i32 %6, i32* null)
%13 = icmp slt i32 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %9
%15 = zext i32 %12 to i64
%16 = getelementptr inbounds i8, i8* %11, i64 %15
%17 = ptrtoint i8* %16 to i64
%18 = ptrtoint i8* %0 to i64
%19 = sub i64 %17, %18
%20 = trunc i64 %19 to i32
br label %21
21: ; preds = %9, %4, %2, %14
%22 = phi i32 [ %20, %14 ], [ -1, %2 ], [ -1, %4 ], [ -1, %9 ]
ret i32 %22
}