#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 */
struct katcp_sensor {
  int dummy;
};
struct katcp_dispatch {
  int dummy;
};
struct katcp_acquire {
  int dummy;
};

/* Variables and functions */
scalar_t__ create_sensor_boolean_katcp(struct katcp_dispatch *,
                                       struct katcp_sensor *);
struct katcp_sensor *create_sensor_katcp(struct katcp_dispatch *, char *,
                                         char *, char *, int, int, int,
                                         int /*<<< orphan*/ *);
int /*<<< orphan*/ destroy_sensor_katcp(struct katcp_dispatch *,
                                        struct katcp_sensor *);
scalar_t__ link_acquire_katcp(struct katcp_dispatch *, struct katcp_acquire *,
                              struct katcp_sensor *,
                              int (*)(struct katcp_dispatch *,
                                      struct katcp_sensor *));
int register_multi_boolean_sensor_katcp(
    struct katcp_dispatch *d, int mode, char *name, char *description,
    char *units, struct katcp_acquire *a,
    int (*extract)(struct katcp_dispatch *d, struct katcp_sensor *sn)) {
  struct katcp_sensor *sn;
  sn = create_sensor_katcp(d, name, description, units, 2, 1, mode, NULL);
  if (sn == NULL) {
    return -1;
  }
  if (create_sensor_boolean_katcp(d, sn) < 0) {
    destroy_sensor_katcp(d, sn);
    return -1;
  }
  if (link_acquire_katcp(d, a, sn, extract)) {
    destroy_sensor_katcp(d, sn);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<register_multi_boolean_sensor_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x14(%rbp),%eax
mov    $0x2,%r8d
mov    $0x1,%r9d
xor    %r10d,%r10d
mov    %eax,(%rsp)
movq   $0x0,0x8(%rsp)
call   1030 <create_sensor_katcp@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11b1 <register_multi_boolean_sensor_katcp+0x71>
movl   $0xffffffff,-0x4(%rbp)
jmp    1220 <register_multi_boolean_sensor_katcp+0xe0>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1050 <create_sensor_boolean_katcp@plt>
cmp    $0x0,%rax
jge    11e1 <register_multi_boolean_sensor_katcp+0xa1>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1040 <destroy_sensor_katcp@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1220 <register_multi_boolean_sensor_katcp+0xe0>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    0x10(%rbp),%rcx
call   1060 <link_acquire_katcp@plt>
cmp    $0x0,%rax
je     1219 <register_multi_boolean_sensor_katcp+0xd9>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1040 <destroy_sensor_katcp@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1220 <register_multi_boolean_sensor_katcp+0xe0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<register_multi_boolean_sensor_katcp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r9,%r14
mov    %esi,%eax
mov    %rdi,%rbx
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %r8,%rcx
mov    $0x2,%r8d
mov    $0x1,%r9d
push   $0x0
push   %rax
call   1030 <create_sensor_katcp@plt>
add    $0x10,%rsp
mov    $0xffffffff,%r15d
test   %rax,%rax
je     11b6 <register_multi_boolean_sensor_katcp+0x76>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <create_sensor_boolean_katcp@plt>
test   %rax,%rax
js     11a6 <register_multi_boolean_sensor_katcp+0x66>
mov    0x30(%rsp),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1060 <link_acquire_katcp@plt>
test   %rax,%rax
je     11b3 <register_multi_boolean_sensor_katcp+0x73>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <destroy_sensor_katcp@plt>
jmp    11b6 <register_multi_boolean_sensor_katcp+0x76>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.katcp_dispatch = type { i32 }
%struct.katcp_acquire = type { i32 }
%struct.katcp_sensor = type { i32 }
define i32 @register_multi_boolean_sensor_katcp(%struct.katcp_dispatch* %0, i32 %1, i8* %2, i8* %3, i8* %4, %struct.katcp_acquire* %5, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)* %6) {
%8 = alloca i32
%9 = alloca %struct.katcp_dispatch*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca %struct.katcp_acquire*
%15 = alloca i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)*
%16 = alloca %struct.katcp_sensor*
store %struct.katcp_dispatch* %0, %struct.katcp_dispatch** %9
store i32 %1, i32* %10
store i8* %2, i8** %11
store i8* %3, i8** %12
store i8* %4, i8** %13
store %struct.katcp_acquire* %5, %struct.katcp_acquire** %14
store i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)* %6, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)** %15
%17 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %9
%18 = load i8*, i8** %11
%19 = load i8*, i8** %12
%20 = load i8*, i8** %13
%21 = load i32, i32* %10
%22 = call %struct.katcp_sensor* @create_sensor_katcp(%struct.katcp_dispatch* %17, i8* %18, i8* %19, i8* %20, i32 2, i32 1, i32 %21, i32* null)
store %struct.katcp_sensor* %22, %struct.katcp_sensor** %16
%23 = load %struct.katcp_sensor*, %struct.katcp_sensor** %16
%24 = icmp eq %struct.katcp_sensor* %23, null
br i1 %24, label %25, label %26
25: ; preds = %7
store i32 -1, i32* %8
br label %47
26: ; preds = %7
%27 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %9
%28 = load %struct.katcp_sensor*, %struct.katcp_sensor** %16
%29 = call i64 @create_sensor_boolean_katcp(%struct.katcp_dispatch* %27, %struct.katcp_sensor* %28)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %26
%32 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %9
%33 = load %struct.katcp_sensor*, %struct.katcp_sensor** %16
%34 = call i32 @destroy_sensor_katcp(%struct.katcp_dispatch* %32, %struct.katcp_sensor* %33)
store i32 -1, i32* %8
br label %47
35: ; preds = %26
%36 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %9
%37 = load %struct.katcp_acquire*, %struct.katcp_acquire** %14
%38 = load %struct.katcp_sensor*, %struct.katcp_sensor** %16
%39 = load i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)*, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)** %15
%40 = call i64 @link_acquire_katcp(%struct.katcp_dispatch* %36, %struct.katcp_acquire* %37, %struct.katcp_sensor* %38, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)* %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %35
%43 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %9
%44 = load %struct.katcp_sensor*, %struct.katcp_sensor** %16
%45 = call i32 @destroy_sensor_katcp(%struct.katcp_dispatch* %43, %struct.katcp_sensor* %44)
store i32 -1, i32* %8
br label %47
46: ; preds = %35
store i32 0, i32* %8
br label %47
47: ; preds = %46, %42, %31, %25
%48 = load i32, i32* %8
ret i32 %48
}

LLVM IR (-O2):
%struct.katcp_dispatch = type { i32 }
%struct.katcp_acquire = type { i32 }
%struct.katcp_sensor = type { i32 }
define i32 @register_multi_boolean_sensor_katcp(%struct.katcp_dispatch* %0, i32 %1, i8* %2, i8* %3, i8* %4, %struct.katcp_acquire* %5, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)* %6) {
%8 = tail call %struct.katcp_sensor* @create_sensor_katcp(%struct.katcp_dispatch* %0, i8* %2, i8* %3, i8* %4, i32 2, i32 1, i32 %1, i32* null)
%9 = icmp eq %struct.katcp_sensor* %8, null
br i1 %9, label %18, label %10
10: ; preds = %7
%11 = tail call i64 @create_sensor_boolean_katcp(%struct.katcp_dispatch* %0, %struct.katcp_sensor* %8)
%12 = icmp slt i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i64 @link_acquire_katcp(%struct.katcp_dispatch* %0, %struct.katcp_acquire* %5, %struct.katcp_sensor* %8, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)* %6)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13, %10
%17 = tail call i32 @destroy_sensor_katcp(%struct.katcp_dispatch* %0, %struct.katcp_sensor* %8)
br label %18
18: ; preds = %16, %13, %7
%19 = phi i32 [ -1, %7 ], [ 0, %13 ], [ -1, %16 ]
ret i32 %19
}