#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int led_mode;
  int led;
};
typedef TYPE_1__ XKeyboardControl;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int KBLed;
int KBLedMode;
int /*<<< orphan*/ XChangeKeyboardControl(int /*<<< orphan*/ *, int,
                                          TYPE_1__ *);
void set_led(Display *dpy, int led, int led_mode) {
  XKeyboardControl values;
  values.led_mode = led_mode;
  if (led != -1) {
    values.led = led;
    XChangeKeyboardControl(dpy, KBLed | KBLedMode, &values);
  } else {
    XChangeKeyboardControl(dpy, KBLedMode, &values);
  }
  return;
}


x86 assembly (clang, -O0):
<set_led>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
je     115c <set_led+0x4c>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2eb5(%rip),%rax
mov    (%rax),%esi
mov    0x2e8c(%rip),%rax
or     (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1030 <XChangeKeyboardControl@plt>
jmp    1172 <set_led+0x62>
mov    -0x8(%rbp),%rdi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1030 <XChangeKeyboardControl@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_led>:
push   %rax
mov    %edx,(%rsp)
cmp    $0xffffffff,%esi
je     1131 <set_led+0x21>
mov    %esi,0x4(%rsp)
mov    0x2ed4(%rip),%rax
mov    0x2ead(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
jmp    113a <set_led+0x2a>
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
call   1030 <XChangeKeyboardControl@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@KBLed = global i32 0
@KBLedMode = global i32 0
define void @set_led(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.TYPE_3__
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
store i32 %8, i32* %9
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %20
12: ; preds = %3
%13 = load i32, i32* %5
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 1
store i32 %13, i32* %14
%15 = load i32*, i32** %4
%16 = load i32, i32* @KBLed
%17 = load i32, i32* @KBLedMode
%18 = or i32 %16, %17
%19 = call i32 @XChangeKeyboardControl(i32* %15, i32 %18, %struct.TYPE_3__* %7)
br label %24
20: ; preds = %3
%21 = load i32*, i32** %4
%22 = load i32, i32* @KBLedMode
%23 = call i32 @XChangeKeyboardControl(i32* %21, i32 %22, %struct.TYPE_3__* %7)
br label %24
24: ; preds = %20, %12
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@KBLed = global i32 0
@KBLedMode = global i32 0
define void @set_led(i32* %0, i32 %1, i32 %2) {
%4 = alloca %struct.TYPE_3__
%5 = bitcast %struct.TYPE_3__* %4 to i8*
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i64 0, i32 0
store i32 %2, i32* %6
%7 = icmp eq i32 %1, -1
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i64 0, i32 1
store i32 %1, i32* %9
%10 = load i32, i32* @KBLed
%11 = load i32, i32* @KBLedMode
%12 = or i32 %11, %10
br label %15
13: ; preds = %3
%14 = load i32, i32* @KBLedMode
br label %15
15: ; preds = %13, %8
%16 = phi i32 [ %14, %13 ], [ %12, %8 ]
%17 = call i32 @XChangeKeyboardControl(i32* %0, i32 %16, %struct.TYPE_3__* %4)
ret void
}