#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 /*<<< orphan*/ setExtendedMode(int);
int /*<<< orphan*/ setK2ExtendedMode(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
void setPower(int fd, float watts) {
  char cmd[9];
  if (watts <= 12)
    sprintf(cmd, "PC%03d0;", (int)(watts * 10));
  else
    sprintf(cmd, "PC%03d1;", (int)watts);
  setK2ExtendedMode(fd);
  write(fd, cmd, strlen(cmd));
  setExtendedMode(fd);
}


x86 assembly (clang, -O0):
<setPower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
movss  0xe98(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     1198 <setPower+0x48>
lea    -0x11(%rbp),%rdi
movss  0xe86(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
cvttss2si %xmm0,%edx
lea    0xe7a(%rip),%rsi
call   1070 <sprintf@plt>
jmp    11ad <setPower+0x5d>
lea    -0x11(%rbp),%rdi
cvttss2si -0x8(%rbp),%edx
lea    0xe69(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x4(%rbp),%edi
call   1060 <setK2ExtendedMode@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0x11(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x11(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
call   1040 <setExtendedMode@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setPower>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
movss  0xe9f(%rip),%xmm1
ucomiss %xmm0,%xmm1
jb     116e <setPower+0x1e>
mulss  0xe96(%rip),%xmm0
lea    0xe9c(%rip),%rax
lea    0xe8c(%rip),%rsi
cmovb  %rax,%rsi
cvttss2si %xmm0,%edx
lea    0xf(%rsp),%r14
mov    %r14,%rdi
call   1070 <sprintf@plt>
mov    %ebx,%edi
call   1060 <setK2ExtendedMode@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1040 <setExtendedMode@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"PC%03d0;\00"
@.str.1 = [9 x i8] c"PC%03d1;\00"
define void @setPower(i32 %0, float %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca [9 x i8]
store i32 %0, i32* %3
store float %1, float* %4
%6 = load float, float* %4
%7 = fcmp ole float %6, 1.200000e+01
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%10 = load float, float* %4
%11 = fmul float %10, 1.000000e+01
%12 = fptosi float %11 to i32
%13 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %19
14: ; preds = %2
%15 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%16 = load float, float* %4
%17 = fptosi float %16 to i32
%18 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %14, %8
%20 = load i32, i32* %3
%21 = call i32 @setK2ExtendedMode(i32 %20)
%22 = load i32, i32* %3
%23 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%24 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = call i32 @write(i32 %22, i8* %23, i32 %25)
%27 = load i32, i32* %3
%28 = call i32 @setExtendedMode(i32 %27)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"PC%03d0;\00"
@.str.1 = [9 x i8] c"PC%03d1;\00"
define void @setPower(i32 %0, float %1) {
%3 = alloca [9 x i8]
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%5 = fcmp ugt float %1, 1.200000e+01
%6 = fmul float %1, 1.000000e+01
%7 = select i1 %5, float %1, float %6
%8 = select i1 %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0)
%9 = fptosi float %7 to i32
%10 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) %8, i32 %9)
%11 = tail call i32 @setK2ExtendedMode(i32 %0)
%12 = call i32 @strlen(i8* %4)
%13 = call i32 @write(i32 %0, i8* %4, i32 %12)
%14 = call i32 @setExtendedMode(i32 %0)
ret void
}