#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*/ BIGNUM;

/* Variables and functions */
scalar_t__ BN_cmp(int /*<<< orphan*/ *, int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_lshift1(int /*<<< orphan*/ *, int /*<<< orphan*/ const *);
int BN_sub(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ const *);
int /*<<< orphan*/ bn_check_top(int /*<<< orphan*/ *);
int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m) {
  if (!BN_lshift1(r, a))
    return 0;
  bn_check_top(r);
  if (BN_cmp(r, m) >= 0)
    return BN_sub(r, r, m);
  return 1;
}


x86 assembly (clang, -O0):
<BN_mod_lshift1_quick>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <BN_lshift1@plt>
cmp    $0x0,%eax
jne    1176 <BN_mod_lshift1_quick+0x36>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <BN_mod_lshift1_quick+0x76>
mov    -0x10(%rbp),%rdi
call   1040 <bn_check_top@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <BN_cmp@plt>
cmp    $0x0,%rax
jl     11af <BN_mod_lshift1_quick+0x6f>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <BN_sub@plt>
mov    %eax,-0x4(%rbp)
jmp    11b6 <BN_mod_lshift1_quick+0x76>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BN_mod_lshift1_quick>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
call   1050 <BN_lshift1@plt>
test   %eax,%eax
je     1180 <BN_mod_lshift1_quick+0x40>
mov    %rbx,%rdi
call   1040 <bn_check_top@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <BN_cmp@plt>
test   %rax,%rax
js     1184 <BN_mod_lshift1_quick+0x44>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <BN_sub@plt>
xor    %eax,%eax
jmp    1189 <BN_mod_lshift1_quick+0x49>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @BN_mod_lshift1_quick(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%8 = load i32*, i32** %5
%9 = load i32*, i32** %6
%10 = call i32 @BN_lshift1(i32* %8, i32* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %3
store i32 0, i32* %4
br label %26
13: ; preds = %3
%14 = load i32*, i32** %5
%15 = call i32 @bn_check_top(i32* %14)
%16 = load i32*, i32** %5
%17 = load i32*, i32** %7
%18 = call i64 @BN_cmp(i32* %16, i32* %17)
%19 = icmp sge i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %13
%21 = load i32*, i32** %5
%22 = load i32*, i32** %5
%23 = load i32*, i32** %7
%24 = call i32 @BN_sub(i32* %21, i32* %22, i32* %23)
store i32 %24, i32* %4
br label %26
25: ; preds = %13
store i32 1, i32* %4
br label %26
26: ; preds = %25, %20, %12
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
define i32 @BN_mod_lshift1_quick(i32* %0, i32* %1, i32* %2) {
%4 = tail call i32 @BN_lshift1(i32* %0, i32* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %3
%7 = tail call i32 @bn_check_top(i32* %0)
%8 = tail call i64 @BN_cmp(i32* %0, i32* %2)
%9 = icmp sgt i64 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @BN_sub(i32* %0, i32* %0, i32* %2)
br label %12
12: ; preds = %6, %3, %10
%13 = phi i32 [ %11, %10 ], [ 0, %3 ], [ 1, %6 ]
ret i32 %13
}