#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*/ setPurpleBlueBlink(int, int, int);
int /*<<< orphan*/ setPurpleRedBlink(int, int, int);
void setVolumeDependent(int sockfd, short volume) {
  if (volume < 0)
    volume = 0;
  else if (volume > 100)
    volume = 100;
  int dutyCycle;
  if (volume < 51) {
    dutyCycle = volume * 2;
    setPurpleBlueBlink(sockfd, dutyCycle, 100);
  } else {
    volume -= 50;
    dutyCycle = volume * 1.8;
    setPurpleRedBlink(sockfd, dutyCycle, 100);
  }
}


x86 assembly (clang, -O0):
<setVolumeDependent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %si,%ax
mov    %edi,-0x4(%rbp)
mov    %ax,-0x6(%rbp)
movswl -0x6(%rbp),%eax
cmp    $0x0,%eax
jge    114a <setVolumeDependent+0x2a>
movw   $0x0,-0x6(%rbp)
jmp    1162 <setVolumeDependent+0x42>
movswl -0x6(%rbp),%eax
cmp    $0x64,%eax
jle    115d <setVolumeDependent+0x3d>
movw   $0x64,-0x6(%rbp)
jmp    1162 <setVolumeDependent+0x42>
movswl -0x6(%rbp),%eax
cmp    $0x33,%eax
jge    118e <setVolumeDependent+0x6e>
movswl -0x6(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x64,%edx
call   1030 <setPurpleBlueBlink@plt>
jmp    11c4 <setVolumeDependent+0xa4>
movswl -0x6(%rbp),%eax
sub    $0x32,%eax
mov    %ax,-0x6(%rbp)
movswl -0x6(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe57(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x64,%edx
call   1040 <setPurpleRedBlink@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setVolumeDependent>:
cmp    $0x64,%si
mov    $0x64,%eax
cmovl  %esi,%eax
xor    %ecx,%ecx
test   %ax,%ax
cmovns %eax,%ecx
movzwl %cx,%esi
cmp    $0x32,%si
ja     1149 <setVolumeDependent+0x29>
add    %esi,%esi
mov    $0x64,%edx
jmp    1030 <setPurpleBlueBlink@plt>
add    $0xffce,%esi
movzwl %si,%eax
cvtsi2sd %eax,%xmm0
mulsd  0xea2(%rip),%xmm0
cvttsd2si %xmm0,%esi
mov    $0x64,%edx
jmp    1040 <setPurpleRedBlink@plt>

LLVM IR (-O0):
define void @setVolumeDependent(i32 %0, i16 signext %1) {
%3 = alloca i32
%4 = alloca i16
%5 = alloca i32
store i32 %0, i32* %3
store i16 %1, i16* %4
%6 = load i16, i16* %4
%7 = sext i16 %6 to i32
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i16 0, i16* %4
br label %16
10: ; preds = %2
%11 = load i16, i16* %4
%12 = sext i16 %11 to i32
%13 = icmp sgt i32 %12, 100
br i1 %13, label %14, label %15
14: ; preds = %10
store i16 100, i16* %4
br label %15
15: ; preds = %14, %10
br label %16
16: ; preds = %15, %9
%17 = load i16, i16* %4
%18 = sext i16 %17 to i32
%19 = icmp slt i32 %18, 51
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i16, i16* %4
%22 = sext i16 %21 to i32
%23 = mul nsw i32 %22, 2
store i32 %23, i32* %5
%24 = load i32, i32* %3
%25 = load i32, i32* %5
%26 = call i32 @setPurpleBlueBlink(i32 %24, i32 %25, i32 100)
br label %40
27: ; preds = %16
%28 = load i16, i16* %4
%29 = sext i16 %28 to i32
%30 = sub nsw i32 %29, 50
%31 = trunc i32 %30 to i16
store i16 %31, i16* %4
%32 = load i16, i16* %4
%33 = sext i16 %32 to i32
%34 = sitofp i32 %33 to double
%35 = fmul double %34, 1.800000e+00
%36 = fptosi double %35 to i32
store i32 %36, i32* %5
%37 = load i32, i32* %3
%38 = load i32, i32* %5
%39 = call i32 @setPurpleRedBlink(i32 %37, i32 %38, i32 100)
br label %40
40: ; preds = %27, %20
ret void
}

LLVM IR (-O2):
define void @setVolumeDependent(i32 %0, i16 signext %1) {
%3 = icmp slt i16 %1, 100
%4 = select i1 %3, i16 %1, i16 100
%5 = icmp sgt i16 %4, 0
%6 = select i1 %5, i16 %4, i16 0
%7 = zext i16 %6 to i32
%8 = icmp ult i16 %6, 51
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = shl nuw nsw i32 %7, 1
%11 = tail call i32 @setPurpleBlueBlink(i32 %0, i32 %10, i32 100)
br label %19
12: ; preds = %2
%13 = add nuw nsw i32 %7, 65486
%14 = and i32 %13, 65535
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 1.800000e+00
%17 = fptosi double %16 to i32
%18 = tail call i32 @setPurpleRedBlink(i32 %0, i32 %17, i32 100)
br label %19
19: ; preds = %12, %9
ret void
}