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

/* Variables and functions */
int /*<<< orphan*/ BIO_flush(void *);
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ BIO_write(void *, char *, int);
int /*<<< orphan*/ cb_exit(int);
void dsa_cb(int p, int n, void *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(arg, &c, 1);
  (void)BIO_flush(arg);
  if (!ok && (p == 0) && (num > 1)) {
    BIO_printf((BIO *)arg, "error in dsatest\n");
    cb_exit(1);
  }
}


x86 assembly (clang, -O0):
<dsa_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movb   $0x2a,-0x11(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1173 <dsa_cb+0x33>
movb   $0x2e,-0x11(%rbp)
mov    0x2ede(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ed5(%rip)
cmpl   $0x1,-0x4(%rbp)
jne    1181 <dsa_cb+0x41>
movb   $0x2b,-0x11(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    119e <dsa_cb+0x5e>
movb   $0x2a,-0x11(%rbp)
mov    0x2eaf(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ea6(%rip)
cmpl   $0x3,-0x4(%rbp)
jne    11ac <dsa_cb+0x6c>
movb   $0xa,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1050 <BIO_write@plt>
mov    -0x10(%rbp),%rdi
call   1060 <BIO_flush@plt>
cmpl   $0x0,0x2e76(%rip)
jne    1205 <dsa_cb+0xc5>
cmpl   $0x0,-0x4(%rbp)
jne    1205 <dsa_cb+0xc5>
cmpl   $0x1,0x2e63(%rip)
jle    1205 <dsa_cb+0xc5>
mov    -0x10(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1030 <BIO_printf@plt>
mov    $0x1,%edi
call   1040 <cb_exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsa_cb>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %edi,%ebp
movb   $0x2a,0x7(%rsp)
cmp    $0x3,%edi
ja     1187 <dsa_cb+0x47>
mov    %ebp,%eax
lea    0xea5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x2e,0x7(%rsp)
addl   $0x1,0x2ed8(%rip)
jmp    1187 <dsa_cb+0x47>
movb   $0x2b,0x7(%rsp)
jmp    1187 <dsa_cb+0x47>
addl   $0x1,0x2ec4(%rip)
jmp    1187 <dsa_cb+0x47>
movb   $0xa,0x7(%rsp)
lea    0x7(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1050 <BIO_write@plt>
mov    %rbx,%rdi
call   1060 <BIO_flush@plt>
or     0x2e9d(%rip),%ebp
jne    11cb <dsa_cb+0x8b>
cmpl   $0x2,0x2e98(%rip)
jl     11cb <dsa_cb+0x8b>
lea    0xe57(%rip),%rsi
mov    %rbx,%rdi
call   1030 <BIO_printf@plt>
mov    $0x1,%edi
call   1040 <cb_exit@plt>
add    $0x8,%rsp
pop    %rbx
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 void @dsa_cb(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i8 42, i8* %7
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %3
store i8 46, i8* %7
%11 = load i32, i32* @dsa_cb.num
%12 = add nsw i32 %11, 1
store i32 %12, i32* @dsa_cb.num
br label %13
13: ; preds = %10, %3
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %13
store i8 43, i8* %7
br label %17
17: ; preds = %16, %13
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %23
20: ; preds = %17
store i8 42, i8* %7
%21 = load i32, i32* @dsa_cb.ok
%22 = add nsw i32 %21, 1
store i32 %22, i32* @dsa_cb.ok
br label %23
23: ; preds = %20, %17
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 3
br i1 %25, label %26, label %27
26: ; preds = %23
store i8 10, i8* %7
br label %27
27: ; preds = %26, %23
%28 = load i8*, i8** %6
%29 = call i32 @BIO_write(i8* %28, i8* %7, i32 1)
%30 = load i8*, i8** %6
%31 = call i32 @BIO_flush(i8* %30)
%32 = load i32, i32* @dsa_cb.ok
%33 = icmp ne i32 %32, 0
br i1 %33, label %45, label %34
34: ; preds = %27
%35 = load i32, i32* %4
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %45
37: ; preds = %34
%38 = load i32, i32* @dsa_cb.num
%39 = icmp sgt i32 %38, 1
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = load i8*, i8** %6
%42 = bitcast i8* %41 to i32*
%43 = call i32 @BIO_printf(i32* %42, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%44 = call i32 @cb_exit(i32 1)
br label %45
45: ; preds = %40, %37, %34, %27
ret void
}

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 void @dsa_cb(i32 %0, i32 %1, i8* %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 = call i32 @BIO_write(i8* %2, i8* %4, i32 1)
%15 = call i32 @BIO_flush(i8* %2)
%16 = load i32, i32* @dsa_cb.ok
%17 = or i32 %16, %0
%18 = icmp eq i32 %17, 0
%19 = load i32, i32* @dsa_cb.num
%20 = icmp sgt i32 %19, 1
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %22, label %26
22: ; preds = %13
%23 = bitcast i8* %2 to i32*
%24 = call i32 @BIO_printf(i32* %23, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @cb_exit(i32 1)
br label %26
26: ; preds = %22, %13
ret void
}