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

/* Variables and functions */
int /*<<< orphan*/ BIO_flush(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ BIO_write(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ BN_GENCB_get_arg(int /*<<< orphan*/ *);
int dsa_cb(int p, int n, BN_GENCB *arg) {
  char c = '*';
  static int ok = 0, num = 0;
  if (p == 0) {
    c = '.';
    num++;
  };
  if (p == 1)
    c = '+';
  if (p == 2) {
    c = '*';
    ok++;
  }
  if (p == 3)
    c = '\n';
  BIO_write(BN_GENCB_get_arg(arg), &c, 1);
  (void)BIO_flush(BN_GENCB_get_arg(arg));
  if (!ok && (p == 0) && (num > 1)) {
    BIO_printf(BN_GENCB_get_arg(arg), "error in dsatest\n");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<dsa_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movb   $0x2a,-0x19(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1173 <dsa_cb+0x33>
movb   $0x2e,-0x19(%rbp)
mov    0x2ede(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ed5(%rip)
cmpl   $0x1,-0x8(%rbp)
jne    1181 <dsa_cb+0x41>
movb   $0x2b,-0x19(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    119e <dsa_cb+0x5e>
movb   $0x2a,-0x19(%rbp)
mov    0x2eaf(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ea6(%rip)
cmpl   $0x3,-0x8(%rbp)
jne    11ac <dsa_cb+0x6c>
movb   $0xa,-0x19(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <BN_GENCB_get_arg@plt>
mov    %eax,%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1050 <BIO_write@plt>
mov    -0x18(%rbp),%rdi
call   1040 <BN_GENCB_get_arg@plt>
mov    %eax,%edi
call   1060 <BIO_flush@plt>
cmpl   $0x0,0x2e68(%rip)
jne    121c <dsa_cb+0xdc>
cmpl   $0x0,-0x8(%rbp)
jne    121c <dsa_cb+0xdc>
cmpl   $0x1,0x2e55(%rip)
jle    121c <dsa_cb+0xdc>
mov    -0x18(%rbp),%rdi
call   1040 <BN_GENCB_get_arg@plt>
mov    %eax,%edi
lea    0xdf5(%rip),%rsi
call   1030 <BIO_printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1223 <dsa_cb+0xe3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsa_cb>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %edi,%ebp
movb   $0x2a,0xf(%rsp)
cmp    $0x3,%edi
ja     118c <dsa_cb+0x4c>
mov    %ebp,%eax
lea    0xea0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x2e,0xf(%rsp)
addl   $0x1,0x2ed3(%rip)
jmp    118c <dsa_cb+0x4c>
movb   $0x2b,0xf(%rsp)
jmp    118c <dsa_cb+0x4c>
addl   $0x1,0x2ebf(%rip)
jmp    118c <dsa_cb+0x4c>
movb   $0xa,0xf(%rsp)
mov    %r14,%rdi
call   1040 <BN_GENCB_get_arg@plt>
lea    0xf(%rsp),%rsi
mov    $0x1,%ebx
mov    %eax,%edi
mov    $0x1,%edx
call   1050 <BIO_write@plt>
mov    %r14,%rdi
call   1040 <BN_GENCB_get_arg@plt>
mov    %eax,%edi
call   1060 <BIO_flush@plt>
or     0x2e85(%rip),%ebp
jne    11e2 <dsa_cb+0xa2>
cmpl   $0x2,0x2e80(%rip)
jl     11e2 <dsa_cb+0xa2>
mov    %r14,%rdi
call   1040 <BN_GENCB_get_arg@plt>
lea    0xe37(%rip),%rsi
mov    %eax,%edi
call   1030 <BIO_printf@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@dsa_cb.ok = internal global i32 0
@dsa_cb.num = internal global i32 0
@.str = [18 x i8] c"error in dsatest\0A\00"
define i32 @dsa_cb(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i8 42, i8* %8
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %3
store i8 46, i8* %8
%12 = load i32, i32* @dsa_cb.num
%13 = add nsw i32 %12, 1
store i32 %13, i32* @dsa_cb.num
br label %14
14: ; preds = %11, %3
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %18
17: ; preds = %14
store i8 43, i8* %8
br label %18
18: ; preds = %17, %14
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %24
21: ; preds = %18
store i8 42, i8* %8
%22 = load i32, i32* @dsa_cb.ok
%23 = add nsw i32 %22, 1
store i32 %23, i32* @dsa_cb.ok
br label %24
24: ; preds = %21, %18
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, 3
br i1 %26, label %27, label %28
27: ; preds = %24
store i8 10, i8* %8
br label %28
28: ; preds = %27, %24
%29 = load i32*, i32** %7
%30 = call i32 @BN_GENCB_get_arg(i32* %29)
%31 = call i32 @BIO_write(i32 %30, i8* %8, i32 1)
%32 = load i32*, i32** %7
%33 = call i32 @BN_GENCB_get_arg(i32* %32)
%34 = call i32 @BIO_flush(i32 %33)
%35 = load i32, i32* @dsa_cb.ok
%36 = icmp ne i32 %35, 0
br i1 %36, label %47, label %37
37: ; preds = %28
%38 = load i32, i32* %5
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %37
%41 = load i32, i32* @dsa_cb.num
%42 = icmp sgt i32 %41, 1
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = load i32*, i32** %7
%45 = call i32 @BN_GENCB_get_arg(i32* %44)
%46 = call i32 @BIO_printf(i32 %45, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %48
47: ; preds = %40, %37, %28
store i32 1, i32* %4
br label %48
48: ; preds = %47, %43
%49 = load i32, i32* %4
ret i32 %49
}

LLVM IR (-O2):
@dsa_cb.ok = internal unnamed_addr global i32 0
@dsa_cb.num = internal unnamed_addr global i32 0
@.str = [18 x i8] c"error in dsatest\0A\00"
define i32 @dsa_cb(i32 %0, i32 %1, i32* %2) {
%4 = alloca i8
store i8 42, i8* %4
switch i32 %0, label %13 [
i32 0, label %5
i32 1, label %8
i32 2, label %9
i32 3, label %12
]
5: ; preds = %3
store i8 46, i8* %4
%6 = load i32, i32* @dsa_cb.num
%7 = add nsw i32 %6, 1
store i32 %7, i32* @dsa_cb.num
br label %13
8: ; preds = %3
store i8 43, i8* %4
br label %13
9: ; preds = %3
%10 = load i32, i32* @dsa_cb.ok
%11 = add nsw i32 %10, 1
store i32 %11, i32* @dsa_cb.ok
br label %13
12: ; preds = %3
store i8 10, i8* %4
br label %13
13: ; preds = %9, %8, %5, %3, %12
%14 = tail call i32 @BN_GENCB_get_arg(i32* %2)
%15 = call i32 @BIO_write(i32 %14, i8* %4, i32 1)
%16 = call i32 @BN_GENCB_get_arg(i32* %2)
%17 = call i32 @BIO_flush(i32 %16)
%18 = load i32, i32* @dsa_cb.ok
%19 = or i32 %18, %0
%20 = icmp eq i32 %19, 0
%21 = load i32, i32* @dsa_cb.num
%22 = icmp sgt i32 %21, 1
%23 = select i1 %20, i1 %22, i1 false
br i1 %23, label %24, label %27
24: ; preds = %13
%25 = call i32 @BN_GENCB_get_arg(i32* %2)
%26 = call i32 @BIO_printf(i32 %25, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %13, %24
%28 = phi i32 [ 0, %24 ], [ 1, %13 ]
ret i32 %28
}