#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_off(unsigned short number) {
  unsigned short led_state;
  unsigned short led_bit_off;
  led_bit_off = 1 << (3 - number);
  if (USBSTK5515_ULED_getall(&led_state))
    return -1;
  led_state = led_state | led_bit_off;
  if (USBSTK5515_ULED_setall(led_state))
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<USBSTK5515_ULED_off>:
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_off+0x43>
movw   $0xffff,-0x2(%rbp)
jmp    1195 <USBSTK5515_ULED_off+0x75>
movzwl -0x6(%rbp),%eax
movzwl -0x8(%rbp),%ecx
or     %ecx,%eax
mov    %ax,-0x6(%rbp)
movzwl -0x6(%rbp),%edi
call   1040 <USBSTK5515_ULED_setall@plt>
cmp    $0x0,%rax
je     118f <USBSTK5515_ULED_off+0x6f>
movw   $0xffff,-0x2(%rbp)
jmp    1195 <USBSTK5515_ULED_off+0x75>
movw   $0x0,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBSTK5515_ULED_off>:
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_off+0x3f>
mov    $0x3,%cl
sub    %bl,%cl
mov    $0x1,%eax
shl    %cl,%eax
or     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_off(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 %26
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 = or i32 %16, %18
%20 = trunc i32 %19 to i16
store i16 %20, i16* %4
%21 = load i16, i16* %4
%22 = call i64 @USBSTK5515_ULED_setall(i16 zeroext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %14
store i16 -1, i16* %2
br label %26
25: ; preds = %14
store i16 0, i16* %2
br label %26
26: ; preds = %25, %24, %13
%27 = load i16, i16* %2
ret i16 %27
}

LLVM IR (-O2):
define signext i16 @USBSTK5515_ULED_off(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 %16
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 = or i16 %10, %11
store i16 %12, i16* %2
%13 = call i64 @USBSTK5515_ULED_setall(i16 zeroext %12)
%14 = icmp ne i64 %13, 0
%15 = sext i1 %14 to i16
br label %16
16: ; preds = %6, %1
%17 = phi i16 [ -1, %1 ], [ %15, %6 ]
ret i16 %17
}