#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 */
scalar_t__ USBSTK5515_ULED_getall(unsigned short *);
scalar_t__ USBSTK5515_ULED_setall(unsigned short);
short USBSTK5515_ULED_on(unsigned short number) {
  unsigned short led_state;
  unsigned short led_bit_on;
  led_bit_on = 1 << (3 - number);
  if (USBSTK5515_ULED_getall(&led_state))
    return -1;
  led_state = led_state & (~led_bit_on);
  if (USBSTK5515_ULED_setall(led_state))
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<USBSTK5515_ULED_on>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x4(%rbp)
movzwl -0x4(%rbp),%eax
mov    $0x3,%ecx
sub    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %ax,-0x8(%rbp)
lea    -0x6(%rbp),%rdi
call   1030 <USBSTK5515_ULED_getall@plt>
cmp    $0x0,%rax
je     1163 <USBSTK5515_ULED_on+0x43>
movw   $0xffff,-0x2(%rbp)
jmp    1198 <USBSTK5515_ULED_on+0x78>
movzwl -0x6(%rbp),%eax
movzwl -0x8(%rbp),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %ax,-0x6(%rbp)
movzwl -0x6(%rbp),%edi
call   1040 <USBSTK5515_ULED_setall@plt>
cmp    $0x0,%rax
je     1192 <USBSTK5515_ULED_on+0x72>
movw   $0xffff,-0x2(%rbp)
jmp    1198 <USBSTK5515_ULED_on+0x78>
movw   $0x0,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBSTK5515_ULED_on>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xe(%rsp),%rdi
call   1030 <USBSTK5515_ULED_getall@plt>
mov    %rax,%rcx
mov    $0xffff,%ax
test   %rcx,%rcx
jne    115f <USBSTK5515_ULED_on+0x3f>
mov    $0x3,%cl
sub    %bl,%cl
mov    $0xfffffffe,%eax
rol    %cl,%eax
and    0xe(%rsp),%ax
mov    %ax,0xe(%rsp)
movzwl %ax,%edi
call   1040 <USBSTK5515_ULED_setall@plt>
neg    %rax
sbb    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define signext i16 @USBSTK5515_ULED_on(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
store i16 %0, i16* %3
%6 = load i16, i16* %3
%7 = zext i16 %6 to i32
%8 = sub nsw i32 3, %7
%9 = shl i32 1, %8
%10 = trunc i32 %9 to i16
store i16 %10, i16* %5
%11 = call i64 @USBSTK5515_ULED_getall(i16* %4)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %1
store i16 -1, i16* %2
br label %27
14: ; preds = %1
%15 = load i16, i16* %4
%16 = zext i16 %15 to i32
%17 = load i16, i16* %5
%18 = zext i16 %17 to i32
%19 = xor i32 %18, -1
%20 = and i32 %16, %19
%21 = trunc i32 %20 to i16
store i16 %21, i16* %4
%22 = load i16, i16* %4
%23 = call i64 @USBSTK5515_ULED_setall(i16 zeroext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %14
store i16 -1, i16* %2
br label %27
26: ; preds = %14
store i16 0, i16* %2
br label %27
27: ; preds = %26, %25, %13
%28 = load i16, i16* %2
ret i16 %28
}

LLVM IR (-O2):
define signext i16 @USBSTK5515_ULED_on(i16 zeroext %0) {
%2 = alloca i16
%3 = bitcast i16* %2 to i8*
%4 = call i64 @USBSTK5515_ULED_getall(i16* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = zext i16 %0 to i32
%8 = sub nsw i32 3, %7
%9 = shl nuw nsw i32 1, %8
%10 = load i16, i16* %2
%11 = trunc i32 %9 to i16
%12 = xor i16 %11, -1
%13 = and i16 %10, %12
store i16 %13, i16* %2
%14 = call i64 @USBSTK5515_ULED_setall(i16 zeroext %13)
%15 = icmp ne i64 %14, 0
%16 = sext i1 %15 to i16
br label %17
17: ; preds = %6, %1
%18 = phi i16 [ -1, %1 ], [ %16, %6 ]
ret i16 %18
}