#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_integer_katcp(struct katcp_dispatch *,
                                       struct katcp_sensor *, int, int, int,
                                       int);
struct katcp_sensor *
create_sensor_katcp(struct katcp_dispatch *, char *, char *, char *, int,
                    int /*<<< orphan*/, int,
                    int (*)(struct katcp_dispatch *, struct katcp_sensor *));
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 declare_multi_integer_sensor_katcp(
    struct katcp_dispatch *d, int mode, char *name, char *description,
    char *units, int nom_min, int nom_max, int warn_min, int warn_max,
    struct katcp_acquire *a,
    int (*extract)(struct katcp_dispatch *d, struct katcp_sensor *sn),
    int (*flush)(struct katcp_dispatch *d, struct katcp_sensor *sn)) {
  struct katcp_sensor *sn;
  sn = create_sensor_katcp(d, name, description, units, 2, 0, mode, flush);
  if (sn == NULL) {
    return -1;
  }
  if (create_sensor_integer_katcp(d, sn, nom_min, nom_max, warn_min, warn_max) <
      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):
<declare_multi_integer_sensor_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x14(%rbp),%r10d
mov    0x38(%rbp),%rax
mov    $0x2,%r8d
xor    %r9d,%r9d
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <create_sensor_katcp@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11be <declare_multi_integer_sensor_katcp+0x7e>
movl   $0xffffffff,-0x4(%rbp)
jmp    123b <declare_multi_integer_sensor_katcp+0xfb>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x34(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    0x18(%rbp),%r8d
mov    0x20(%rbp),%r9d
call   1040 <create_sensor_integer_katcp@plt>
cmp    $0x0,%rax
jge    11fc <declare_multi_integer_sensor_katcp+0xbc>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1050 <destroy_sensor_katcp@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    123b <declare_multi_integer_sensor_katcp+0xfb>
mov    -0x10(%rbp),%rdi
mov    0x28(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    0x30(%rbp),%rcx
call   1060 <link_acquire_katcp@plt>
cmp    $0x0,%rax
je     1234 <declare_multi_integer_sensor_katcp+0xf4>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1050 <destroy_sensor_katcp@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    123b <declare_multi_integer_sensor_katcp+0xfb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<declare_multi_integer_sensor_katcp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r9d,%r15d
mov    %esi,%eax
mov    %rdi,%rbx
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %r8,%rcx
mov    $0x2,%r8d
xor    %r9d,%r9d
push   0x58(%rsp)
push   %rax
call   1030 <create_sensor_katcp@plt>
add    $0x10,%rsp
mov    $0xffffffff,%r14d
test   %rax,%rax
je     11c8 <declare_multi_integer_sensor_katcp+0x88>
mov    %rax,%rbp
mov    0x40(%rsp),%r9d
mov    0x38(%rsp),%r8d
mov    0x30(%rsp),%ecx
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r15d,%edx
call   1040 <create_sensor_integer_katcp@plt>
test   %rax,%rax
js     11b8 <declare_multi_integer_sensor_katcp+0x78>
mov    0x50(%rsp),%rcx
mov    0x48(%rsp),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
call   1060 <link_acquire_katcp@plt>
test   %rax,%rax
je     11c5 <declare_multi_integer_sensor_katcp+0x85>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <destroy_sensor_katcp@plt>
jmp    11c8 <declare_multi_integer_sensor_katcp+0x88>
xor    %r14d,%r14d
mov    %r14d,%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 @declare_multi_integer_sensor_katcp(%struct.katcp_dispatch* %0, i32 %1, i8* %2, i8* %3, i8* %4, i32 %5, i32 %6, i32 %7, i32 %8, %struct.katcp_acquire* %9, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)* %10, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)* %11) {
%13 = alloca i32
%14 = alloca %struct.katcp_dispatch*
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca %struct.katcp_acquire*
%24 = alloca i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)*
%25 = alloca i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)*
%26 = alloca %struct.katcp_sensor*
store %struct.katcp_dispatch* %0, %struct.katcp_dispatch** %14
store i32 %1, i32* %15
store i8* %2, i8** %16
store i8* %3, i8** %17
store i8* %4, i8** %18
store i32 %5, i32* %19
store i32 %6, i32* %20
store i32 %7, i32* %21
store i32 %8, i32* %22
store %struct.katcp_acquire* %9, %struct.katcp_acquire** %23
store i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)* %10, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)** %24
store i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)* %11, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)** %25
%27 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %14
%28 = load i8*, i8** %16
%29 = load i8*, i8** %17
%30 = load i8*, i8** %18
%31 = load i32, i32* %15
%32 = load i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)*, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)** %25
%33 = call %struct.katcp_sensor* @create_sensor_katcp(%struct.katcp_dispatch* %27, i8* %28, i8* %29, i8* %30, i32 2, i32 0, i32 %31, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)* %32)
store %struct.katcp_sensor* %33, %struct.katcp_sensor** %26
%34 = load %struct.katcp_sensor*, %struct.katcp_sensor** %26
%35 = icmp eq %struct.katcp_sensor* %34, null
br i1 %35, label %36, label %37
36: ; preds = %12
store i32 -1, i32* %13
br label %62
37: ; preds = %12
%38 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %14
%39 = load %struct.katcp_sensor*, %struct.katcp_sensor** %26
%40 = load i32, i32* %19
%41 = load i32, i32* %20
%42 = load i32, i32* %21
%43 = load i32, i32* %22
%44 = call i64 @create_sensor_integer_katcp(%struct.katcp_dispatch* %38, %struct.katcp_sensor* %39, i32 %40, i32 %41, i32 %42, i32 %43)
%45 = icmp slt i64 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %37
%47 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %14
%48 = load %struct.katcp_sensor*, %struct.katcp_sensor** %26
%49 = call i32 @destroy_sensor_katcp(%struct.katcp_dispatch* %47, %struct.katcp_sensor* %48)
store i32 -1, i32* %13
br label %62
50: ; preds = %37
%51 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %14
%52 = load %struct.katcp_acquire*, %struct.katcp_acquire** %23
%53 = load %struct.katcp_sensor*, %struct.katcp_sensor** %26
%54 = load i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)*, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)** %24
%55 = call i64 @link_acquire_katcp(%struct.katcp_dispatch* %51, %struct.katcp_acquire* %52, %struct.katcp_sensor* %53, i32 (%struct.katcp_dispatch*, %struct.katcp_sensor*)* %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %50
%58 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %14
%59 = load %struct.katcp_sensor*, %struct.katcp_sensor** %26
%60 = call i32 @destroy_sensor_katcp(%struct.katcp_dispatch* %58, %struct.katcp_sensor* %59)
store i32 -1, i32* %13
br label %62
61: ; preds = %50
store i32 0, i32* %13
br label %62
62: ; preds = %61, %57, %46, %36
%63 = load i32, i32* %13
ret i32 %63
}

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