#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 */
int /*<<< orphan*/ BN_is_zero(int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_print_fp(int /*<<< orphan*/, int /*<<< orphan*/ const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int a_is_zero_mod_one(const char *method, const BIGNUM *r, const BIGNUM *a) {
  if (!BN_is_zero(r)) {
    fprintf(stderr, "%s failed:\n", method);
    fprintf(stderr, "a ** 0 mod 1 = r (should be 0)\n");
    fprintf(stderr, "a = ");
    BN_print_fp(stderr, a);
    fprintf(stderr, "\nr = ");
    BN_print_fp(stderr, r);
    fprintf(stderr, "\n");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<a_is_zero_mod_one>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <BN_is_zero@plt>
cmp    $0x0,%eax
jne    11fd <a_is_zero_mod_one+0xcd>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
call   1030 <BN_print_fp@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1030 <BN_print_fp@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1204 <a_is_zero_mod_one+0xd4>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<a_is_zero_mod_one>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %rsi,%rdi
call   1050 <BN_is_zero@plt>
mov    $0x1,%r15d
test   %eax,%eax
jne    11d2 <a_is_zero_mod_one+0xa2>
mov    0x2e86(%rip),%r12
mov    (%r12),%edi
lea    0xe9b(%rip),%rsi
xor    %r15d,%r15d
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edi
lea    0xe8f(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edi
lea    0xe9d(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edi
mov    %r14,%rsi
call   1030 <BN_print_fp@plt>
mov    (%r12),%edi
lea    0xe84(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edi
mov    %rbx,%rsi
call   1030 <BN_print_fp@plt>
mov    (%r12),%edi
lea    0xe5f(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c"%s failed:\0A\00"
@.str.1 = [32 x i8] c"a ** 0 mod 1 = r (should be 0)\0A\00"
@.str.2 = [5 x i8] c"a = \00"
@.str.3 = [6 x i8] c"\0Ar = \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @a_is_zero_mod_one(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%8 = load i32*, i32** %6
%9 = call i32 @BN_is_zero(i32* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %29, label %11
11: ; preds = %3
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %5
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = load i32*, i32** %7
%21 = call i32 @BN_print_fp(i32 %19, i32* %20)
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = load i32*, i32** %6
%26 = call i32 @BN_print_fp(i32 %24, i32* %25)
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %30
29: ; preds = %3
store i32 1, i32* %4
br label %30
30: ; preds = %29, %11
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [12 x i8] c"%s failed:\0A\00"
@.str.1 = [32 x i8] c"a ** 0 mod 1 = r (should be 0)\0A\00"
@.str.2 = [5 x i8] c"a = \00"
@.str.3 = [6 x i8] c"\0Ar = \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @a_is_zero_mod_one(i8* %0, i32* %1, i32* %2) {
%4 = tail call i32 @BN_is_zero(i32* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %21
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = tail call i32 @BN_print_fp(i32 %13, i32* %2)
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = tail call i32 @BN_print_fp(i32 %17, i32* %1)
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %21
21: ; preds = %3, %6
%22 = phi i32 [ 0, %6 ], [ 1, %3 ]
ret i32 %22
}