#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 atrf_dsc {
  int dummy;
};

/* Variables and functions */
double fabs(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double);
int /*<<< orphan*/ set_power_step(struct atrf_dsc *, int, int);
int /*<<< orphan*/ stderr;
int tx_power_dBm2step(struct atrf_dsc *, double);
double tx_power_step2dBm(struct atrf_dsc *, int);
void set_power_dBm(struct atrf_dsc *dsc, double power, int crc) {
  int step;
  double got;
  step = tx_power_dBm2step(dsc, power);
  got = tx_power_step2dBm(dsc, step);
  if (fabs(got - power) > 0.01)
    fprintf(stderr, "TX power %.1f dBm\n", got);
  set_power_step(dsc, step, crc);
}


x86 assembly (clang, -O0):
<set_power_dBm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
call   1060 <tx_power_dBm2step@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1050 <tx_power_step2dBm@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xe89(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe6d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b7 <set_power_dBm+0x77>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
movsd  -0x20(%rbp),%xmm0
lea    0xe6e(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <set_power_step@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_power_dBm>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%rbx
call   1060 <tx_power_dBm2step@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <tx_power_step2dBm@plt>
movapd %xmm0,%xmm1
subsd  0x8(%rsp),%xmm1
andpd  0xe89(%rip),%xmm1
ucomisd 0xe91(%rip),%xmm1
jbe    1196 <set_power_dBm+0x56>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <set_power_step@plt>

LLVM IR (-O0):
%struct.atrf_dsc = type { i32 }
@stderr = global i32 0
@.str = [19 x i8] c"TX power %.1f dBm\0A\00"
define void @set_power_dBm(%struct.atrf_dsc* %0, double %1, i32 %2) {
%4 = alloca %struct.atrf_dsc*
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store %struct.atrf_dsc* %0, %struct.atrf_dsc** %4
store double %1, double* %5
store i32 %2, i32* %6
%9 = load %struct.atrf_dsc*, %struct.atrf_dsc** %4
%10 = load double, double* %5
%11 = call i32 @tx_power_dBm2step(%struct.atrf_dsc* %9, double %10)
store i32 %11, i32* %7
%12 = load %struct.atrf_dsc*, %struct.atrf_dsc** %4
%13 = load i32, i32* %7
%14 = call double @tx_power_step2dBm(%struct.atrf_dsc* %12, i32 %13)
store double %14, double* %8
%15 = load double, double* %8
%16 = load double, double* %5
%17 = fsub double %15, %16
%18 = call double @llvm.fabs.f64(double %17)
%19 = fcmp ogt double %18, 1.000000e-02
br i1 %19, label %20, label %24
20: ; preds = %3
%21 = load i32, i32* @stderr
%22 = load double, double* %8
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %22)
br label %24
24: ; preds = %20, %3
%25 = load %struct.atrf_dsc*, %struct.atrf_dsc** %4
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = call i32 @set_power_step(%struct.atrf_dsc* %25, i32 %26, i32 %27)
ret void
}

LLVM IR (-O2):
%struct.atrf_dsc = type { i32 }
@stderr = global i32 0
@.str = [19 x i8] c"TX power %.1f dBm\0A\00"
define void @set_power_dBm(%struct.atrf_dsc* %0, double %1, i32 %2) {
%4 = tail call i32 @tx_power_dBm2step(%struct.atrf_dsc* %0, double %1)
%5 = tail call double @tx_power_step2dBm(%struct.atrf_dsc* %0, i32 %4)
%6 = fsub double %5, %1
%7 = tail call double @llvm.fabs.f64(double %6)
%8 = fcmp ogt double %7, 1.000000e-02
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %5)
br label %12
12: ; preds = %9, %3
%13 = tail call i32 @set_power_step(%struct.atrf_dsc* %0, i32 %4, i32 %2)
ret void
}