#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 */
#define BIO_CTRL_DUP 128
long BIO_ctrl(int /*<<< orphan*/ *, int, long, void *);
int /*<<< orphan*/ *BIO_next(int /*<<< orphan*/ *);
long watchccs_ctrl(BIO *bio, int cmd, long num, void *ptr) {
  long ret;
  BIO *next = BIO_next(bio);
  if (next == NULL)
    return 0;
  switch (cmd) {
  case BIO_CTRL_DUP:
    ret = 0;
    break;
  default:
    ret = BIO_ctrl(next, cmd, num, ptr);
    break;
  }
  return ret;
}


x86 assembly (clang, -O0):
<watchccs_ctrl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <BIO_next@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    115c <watchccs_ctrl+0x3c>
movq   $0x0,-0x8(%rbp)
jmp    119c <watchccs_ctrl+0x7c>
mov    -0x14(%rbp),%eax
sub    $0x80,%eax
jne    117c <watchccs_ctrl+0x5c>
jmp    116f <watchccs_ctrl+0x4f>
movq   $0x0,-0x30(%rbp)
jmp    1194 <watchccs_ctrl+0x74>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <BIO_ctrl@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<watchccs_ctrl>:
push   %rbp
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%ebp
call   1040 <BIO_next@plt>
cmp    $0x80,%ebp
je     1152 <watchccs_ctrl+0x32>
test   %rax,%rax
je     1152 <watchccs_ctrl+0x32>
mov    %rax,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <BIO_ctrl@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i64 @watchccs_ctrl(i32* %0, i32 %1, i64 %2, i8* %3) {
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32*
store i32* %0, i32** %6
store i32 %1, i32* %7
store i64 %2, i64* %8
store i8* %3, i8** %9
%12 = load i32*, i32** %6
%13 = call i32* @BIO_next(i32* %12)
store i32* %13, i32** %11
%14 = load i32*, i32** %11
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %17
16: ; preds = %4
store i64 0, i64* %5
br label %28
17: ; preds = %4
%18 = load i32, i32* %7
switch i32 %18, label %20 [
i32 128, label %19
]
19: ; preds = %17
store i64 0, i64* %10
br label %26
20: ; preds = %17
%21 = load i32*, i32** %11
%22 = load i32, i32* %7
%23 = load i64, i64* %8
%24 = load i8*, i8** %9
%25 = call i64 @BIO_ctrl(i32* %21, i32 %22, i64 %23, i8* %24)
store i64 %25, i64* %10
br label %26
26: ; preds = %20, %19
%27 = load i64, i64* %10
store i64 %27, i64* %5
br label %28
28: ; preds = %26, %16
%29 = load i64, i64* %5
ret i64 %29
}

LLVM IR (-O2):
define i64 @watchccs_ctrl(i32* %0, i32 %1, i64 %2, i8* %3) {
%5 = tail call i32* @BIO_next(i32* %0)
%6 = icmp eq i32* %5, null
%7 = icmp eq i32 %1, 128
%8 = or i1 %7, %6
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = tail call i64 @BIO_ctrl(i32* %5, i32 %1, i64 %2, i8* %3)
br label %11
11: ; preds = %9, %4
%12 = phi i64 [ 0, %4 ], [ %10, %9 ]
ret i64 %12
}