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

/* Variables and functions */
int getOutputPower(unsigned int *,
                   int (*)(unsigned char *const, unsigned int, void *const),
                   void *const);
int setOutputPower(unsigned int const *const,
                   int (*)(unsigned char *const, unsigned int, void *const),
                   void *const);
int setOutputPowerChecked(const unsigned int *const power,
                          int (*spiTransfer)(unsigned char *const, unsigned int,
                                             void *const customData),
                          void *const customData) {
  int res = setOutputPower(power, spiTransfer, customData);
  if (res < 0) {
    return res;
  }
  unsigned int outputPowerNew;
  res = getOutputPower(&outputPowerNew, spiTransfer, customData);
  if (res < 0) {
    return res;
  }
  if (outputPowerNew != *power) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<setOutputPowerChecked>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <setOutputPower@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    115d <setOutputPowerChecked+0x3d>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a8 <setOutputPowerChecked+0x88>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rdi
call   1040 <getOutputPower@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1186 <setOutputPowerChecked+0x66>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a8 <setOutputPowerChecked+0x88>
mov    -0x28(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
je     11a1 <setOutputPowerChecked+0x81>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a8 <setOutputPowerChecked+0x88>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setOutputPowerChecked>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <setOutputPower@plt>
test   %eax,%eax
js     115d <setOutputPowerChecked+0x3d>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <getOutputPower@plt>
test   %eax,%eax
js     115d <setOutputPowerChecked+0x3d>
mov    0xc(%rsp),%ecx
xor    %eax,%eax
cmp    (%r14),%ecx
setne  %al
neg    %eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @setOutputPowerChecked(i32* %0, i32 (i8*, i32, i8*)* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32 (i8*, i32, i8*)*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32 (i8*, i32, i8*)* %1, i32 (i8*, i32, i8*)** %6
store i8* %2, i8** %7
%10 = load i32*, i32** %5
%11 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** %6
%12 = load i8*, i8** %7
%13 = call i32 @setOutputPower(i32* %10, i32 (i8*, i32, i8*)* %11, i8* %12)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = load i32, i32* %8
store i32 %17, i32* %4
br label %33
18: ; preds = %3
%19 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** %6
%20 = load i8*, i8** %7
%21 = call i32 @getOutputPower(i32* %9, i32 (i8*, i32, i8*)* %19, i8* %20)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = load i32, i32* %8
store i32 %25, i32* %4
br label %33
26: ; preds = %18
%27 = load i32, i32* %9
%28 = load i32*, i32** %5
%29 = load i32, i32* %28
%30 = icmp ne i32 %27, %29
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 -1, i32* %4
br label %33
32: ; preds = %26
store i32 0, i32* %4
br label %33
33: ; preds = %32, %31, %24, %16
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
define i32 @setOutputPowerChecked(i32* %0, i32 (i8*, i32, i8*)* %1, i8* %2) {
%4 = alloca i32
%5 = tail call i32 @setOutputPower(i32* %0, i32 (i8*, i32, i8*)* %1, i8* %2)
%6 = icmp slt i32 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %3
%8 = bitcast i32* %4 to i8*
%9 = call i32 @getOutputPower(i32* %4, i32 (i8*, i32, i8*)* %1, i8* %2)
%10 = icmp slt i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %7
%12 = load i32, i32* %4
%13 = load i32, i32* %0
%14 = icmp ne i32 %12, %13
%15 = sext i1 %14 to i32
br label %16
16: ; preds = %11, %7
%17 = phi i32 [ %9, %7 ], [ %15, %11 ]
br label %18
18: ; preds = %3, %16
%19 = phi i32 [ %17, %16 ], [ %5, %3 ]
ret i32 %19
}