#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_17__ TYPE_5__;
typedef struct TYPE_16__ TYPE_4__;
typedef struct TYPE_15__ TYPE_3__;
typedef struct TYPE_14__ TYPE_2__;
typedef struct TYPE_13__ TYPE_1__;

/* Type definitions */
typedef TYPE_3__ *XkbDescPtr;
struct TYPE_16__ {
  int led_mask;
};
typedef TYPE_4__ XKeyboardState;
struct TYPE_17__ {
  unsigned int led;
  int /*<<< orphan*/ led_mode;
};
typedef TYPE_5__ XKeyboardControl;
struct TYPE_15__ {
  TYPE_2__ *indicators;
};
struct TYPE_14__ {
  int phys_indicators;
  TYPE_1__ *maps;
};
struct TYPE_13__ {
  int flags;
};
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int KBLed;
int KBLedMode;
int /*<<< orphan*/ LedModeOff;
int /*<<< orphan*/ LedModeOn;
int /*<<< orphan*/ True;
int XChangeKeyboardControl(int /*<<< orphan*/ *, int, TYPE_5__ *);
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int XGetKeyboardControl(int /*<<< orphan*/ *, TYPE_4__ *);
int /*<<< orphan*/ *XOpenDisplay(char *);
int /*<<< orphan*/ XkbAllIndicatorsMask;
int /*<<< orphan*/ XkbAllNamesMask;
TYPE_3__ *XkbAllocKeyboard();
int /*<<< orphan*/ XkbFreeKeyboard(TYPE_3__ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/);
scalar_t__ XkbGetIndicatorMap(int /*<<< orphan*/ *, int /*<<< orphan*/,
                              TYPE_3__ *);
scalar_t__ XkbGetNames(int /*<<< orphan*/ *, int /*<<< orphan*/, TYPE_3__ *);
int XkbIM_NoAutomatic;
unsigned int XkbNumIndicators;
int XkbSetIndicatorMap(int /*<<< orphan*/ *, int /*<<< orphan*/, TYPE_3__ *);
int /*<<< orphan*/ printf(char *, ...);
int strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  Display *display = NULL;
  int mask = 0;
  unsigned i;
  XKeyboardState ks;
  XKeyboardControl kc;
  XkbDescPtr xkb;
  int old[32];
  if (argc == 2 || argc == 3) {
    if (!(display = XOpenDisplay(argv[1]))) {
      printf("Cannot open display %s\n", argv[1]);
      return -1;
    }
    if (argc >= 3)
      mask = strtol(argv[2], NULL, 0);
  } else {
    printf("Usage: %s display [mask]\n", argv[0]);
    return -1;
  }
  if (!display && !(display = XOpenDisplay(NULL))) {
    printf("Cannot open default display\n");
    return -1;
  }
  if (!(xkb = XkbAllocKeyboard())) {
    printf("Cannot allocate\n");
    return -1;
  }
  if (XkbGetIndicatorMap(display, XkbAllIndicatorsMask, xkb)) {
    printf("Cannot Get Indicators\n");
    return -1;
  }
  if (XkbGetNames(display, XkbAllNamesMask, xkb)) {
    printf("Cannot Get Names\n");
    return -1;
  }
  for (i = 0; i < XkbNumIndicators; i++) {
    if (xkb->indicators->phys_indicators & (1 << i)) {
      printf("led %d = %d\n", i, xkb->indicators->maps[i].flags);
      old[i] = xkb->indicators->maps[i].flags;
      xkb->indicators->maps[i].flags = XkbIM_NoAutomatic;
    }
  }
  printf("XkbSetIndicatorMap = %d\n", XkbSetIndicatorMap(display, ~0, xkb));
  XkbFreeKeyboard(xkb, 0, True);
  if (!(xkb = XkbAllocKeyboard())) {
    printf("Cannot allocate\n");
    return -1;
  }
  if (XkbGetIndicatorMap(display, XkbAllIndicatorsMask, xkb)) {
    printf("Cannot Get Indicators\n");
    return -1;
  }
  for (i = 0; i < XkbNumIndicators; i++) {
    if (xkb->indicators->phys_indicators & (1 << i))
      printf("led %d = %d\n", i, xkb->indicators->maps[i].flags);
  }
  printf("XGetKeyboardControl = %d\n", XGetKeyboardControl(display, &ks));
  printf("old mask = 0x%08lx\n", ks.led_mask);
  for (i = 0; i < 5; i++) {
    kc.led = i + 1;
    kc.led_mode = (mask & (1 << i)) ? LedModeOn : LedModeOff;
    printf("XChangeKeyboardControl = %d\n",
           XChangeKeyboardControl(display, KBLed | KBLedMode, &kc));
  }
  printf("XGetKeyboardControl = %d\n", XGetKeyboardControl(display, &ks));
  printf("new mask = 0x%08lx\n", ks.led_mask);
  for (i = 0; i < XkbNumIndicators; i++)
    if (xkb->indicators->phys_indicators & (i << 1))
      xkb->indicators->maps[i].flags = old[i];
  printf("XkbSetIndicatorMap = %d\n", XkbSetIndicatorMap(display, ~0, xkb));
  XkbFreeKeyboard(xkb, 0, True);
  XCloseDisplay(display);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ec <main+0x3c>
cmpl   $0x3,-0x8(%rbp)
jne    124e <main+0x9e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1229 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    169e <main+0x4ee>
cmpl   $0x3,-0x8(%rbp)
jl     1249 <main+0x99>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %eax,-0x1c(%rbp)
jmp    126f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    169e <main+0x4ee>
cmpq   $0x0,-0x18(%rbp)
jne    12ab <main+0xfb>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    12ab <main+0xfb>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    169e <main+0x4ee>
mov    $0x0,%al
call   1050 <XkbAllocKeyboard@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    12da <main+0x12a>
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    169e <main+0x4ee>
mov    -0x18(%rbp),%rdi
mov    0x2ceb(%rip),%rax
mov    (%rax),%esi
mov    -0x38(%rbp),%rdx
call   10a0 <XkbGetIndicatorMap@plt>
cmp    $0x0,%rax
je     1314 <main+0x164>
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    169e <main+0x4ee>
mov    -0x18(%rbp),%rdi
mov    0x2ca1(%rip),%rax
mov    (%rax),%esi
mov    -0x38(%rbp),%rdx
call   10c0 <XkbGetNames@plt>
cmp    $0x0,%rax
je     134e <main+0x19e>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    169e <main+0x4ee>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2c39(%rip),%rcx
cmp    (%rcx),%eax
jae    13f1 <main+0x241>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    -0x20(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     13de <main+0x22e>
mov    -0x20(%rbp),%esi
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    -0x20(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
lea    0xce7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    -0x20(%rbp),%ecx
mov    (%rax,%rcx,4),%ecx
mov    -0x20(%rbp),%eax
mov    %ecx,-0xc0(%rbp,%rax,4)
mov    0x2c0d(%rip),%rax
mov    (%rax),%edx
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    -0x20(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
jmp    13e3 <main+0x233>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1355 <main+0x1a5>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0xffffffff,%esi
call   1070 <XkbSetIndicatorMap@plt>
mov    %eax,%esi
lea    0xc8a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    0x2baa(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <XkbFreeKeyboard@plt>
mov    $0x0,%al
call   1050 <XkbAllocKeyboard@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1456 <main+0x2a6>
lea    0xc0c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    169e <main+0x4ee>
mov    -0x18(%rbp),%rdi
mov    0x2b6f(%rip),%rax
mov    (%rax),%esi
mov    -0x38(%rbp),%rdx
call   10a0 <XkbGetIndicatorMap@plt>
cmp    $0x0,%rax
je     1490 <main+0x2e0>
lea    0xbe3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    169e <main+0x4ee>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2af7(%rip),%rcx
cmp    (%rcx),%eax
jae    14fe <main+0x34e>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    -0x20(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     14eb <main+0x33b>
mov    -0x20(%rbp),%esi
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    -0x20(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
lea    0xba5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14f0 <main+0x340>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1497 <main+0x2e7>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <XGetKeyboardControl@plt>
mov    %eax,%esi
lea    0xb9b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xba4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x5,-0x20(%rbp)
jae    15c9 <main+0x419>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1574 <main+0x3c4>
mov    0x2a41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
jmp    1583 <main+0x3d3>
mov    0x2a7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
mov    -0xc4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2a59(%rip),%rax
mov    (%rax),%esi
mov    0x2a10(%rip),%rax
or     (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1030 <XChangeKeyboardControl@plt>
mov    %eax,%esi
lea    0xb29(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1533 <main+0x383>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <XGetKeyboardControl@plt>
mov    %eax,%esi
lea    0xad0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xb0a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2990(%rip),%rcx
cmp    (%rcx),%eax
jae    1658 <main+0x4a8>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    -0x20(%rbp),%ecx
shl    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1645 <main+0x495>
mov    -0x20(%rbp),%eax
mov    -0xc0(%rbp,%rax,4),%edx
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    -0x20(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
jmp    164a <main+0x49a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    15fe <main+0x44e>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0xffffffff,%esi
call   1070 <XkbSetIndicatorMap@plt>
mov    %eax,%esi
lea    0xa23(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    0x2943(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <XkbFreeKeyboard@plt>
mov    -0x18(%rbp),%rdi
call   10d0 <XCloseDisplay@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%rbx
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    123a <main+0x7a>
mov    %edi,%ebp
mov    0x8(%rbx),%rdi
call   1090 <XOpenDisplay@plt>
test   %rax,%rax
je     1246 <main+0x86>
mov    %rax,%r12
xor    %r15d,%r15d
cmp    $0x3,%ebp
jb     1209 <main+0x49>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <strtol@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1060 <XkbAllocKeyboard@plt>
test   %rax,%rax
je     125a <main+0x9a>
mov    %rax,%rbx
mov    0x2db1(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
mov    %rbx,%rdx
call   10b0 <XkbGetIndicatorMap@plt>
test   %rax,%rax
je     1263 <main+0xa3>
lea    0xea0(%rip),%rdi
jmp    1283 <main+0xc3>
mov    (%rbx),%rsi
lea    0xdd4(%rip),%rdi
jmp    1251 <main+0x91>
mov    0x8(%rbx),%rsi
lea    0xdaf(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1288 <main+0xc8>
lea    0xe56(%rip),%rdi
jmp    1283 <main+0xc3>
mov    0x2d56(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
mov    %rbx,%rdx
call   10d0 <XkbGetNames@plt>
test   %rax,%rax
je     12a1 <main+0xe1>
lea    0xe44(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cf0(%rip),%rax
mov    (%rax),%ecx
test   %ecx,%ecx
je     1315 <main+0x155>
mov    (%rbx),%rax
lea    0xd7a(%rip),%r14
mov    0x2d19(%rip),%r13
xor    %ebp,%ebp
jmp    12db <main+0x11b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
mov    %ecx,%edx
cmp    %rdx,%rbp
jae    1315 <main+0x155>
mov    (%rax),%edx
bt     %ebp,%edx
jae    12d0 <main+0x110>
mov    0x8(%rax),%rax
mov    (%rax,%rbp,4),%edx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rbx),%rax
mov    0x8(%rax),%rcx
mov    (%rcx,%rbp,4),%edx
mov    %edx,0x10(%rsp,%rbp,4)
mov    0x0(%r13),%edx
mov    %edx,(%rcx,%rbp,4)
mov    0x2c87(%rip),%rcx
mov    (%rcx),%ecx
jmp    12d0 <main+0x110>
mov    $0xffffffff,%ebp
mov    %r12,%rdi
mov    $0xffffffff,%esi
mov    %rbx,%rdx
call   1080 <XkbSetIndicatorMap@plt>
lea    0xd0e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2c87(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10c0 <XkbFreeKeyboard@plt>
xor    %eax,%eax
call   1060 <XkbAllocKeyboard@plt>
test   %rax,%rax
je     13c4 <main+0x204>
mov    %rax,%r14
mov    0x2c6d(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
mov    %r14,%rdx
call   10b0 <XkbGetIndicatorMap@plt>
test   %rax,%rax
jne    1231 <main+0x71>
mov    0x2c18(%rip),%rax
mov    (%rax),%eax
test   %eax,%eax
je     13d5 <main+0x215>
lea    0xca5(%rip),%rbx
xor    %ebp,%ebp
jmp    139c <main+0x1dc>
add    $0x1,%rbp
mov    %eax,%ecx
cmp    %rcx,%rbp
jae    13d5 <main+0x215>
mov    (%r14),%rcx
mov    (%rcx),%edx
bt     %ebp,%edx
jae    1391 <main+0x1d1>
mov    0x8(%rcx),%rax
mov    (%rax,%rbp,4),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2bd8(%rip),%rax
mov    (%rax),%eax
jmp    1391 <main+0x1d1>
lea    0xcec(%rip),%rdi
call   1050 <puts@plt>
jmp    128d <main+0xcd>
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
call   1040 <XGetKeyboardControl@plt>
lea    0xc6f(%rip),%rdi
xor    %ebp,%ebp
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xc73(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
test   $0x1,%r15b
mov    0x2b97(%rip),%rbx
mov    %rbx,%rax
cmove  0x2bdc(%rip),%rax
movl   $0x1,(%rsp)
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x2bc0(%rip),%rax
mov    0x2b79(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rsp,%rdx
mov    %r12,%rdi
call   1030 <XChangeKeyboardControl@plt>
lea    0xc39(%rip),%r13
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
movl   $0x2,(%rsp)
test   $0x2,%r15b
mov    %rbx,%rax
mov    0x2b8a(%rip),%rcx
cmove  %rcx,%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x2b31(%rip),%rax
mov    (%rax),%esi
mov    0x2b68(%rip),%rax
or     (%rax),%esi
mov    %r12,%rdi
mov    %rsp,%rdx
call   1030 <XChangeKeyboardControl@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
movl   $0x3,(%rsp)
test   $0x4,%r15b
mov    %rbx,%rax
cmove  0x2b41(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x2aec(%rip),%r13
mov    0x0(%r13),%esi
mov    0x2b21(%rip),%rax
or     (%rax),%esi
mov    %r12,%rdi
mov    %rsp,%rdx
call   1030 <XChangeKeyboardControl@plt>
lea    0xba3(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
movl   $0x4,(%rsp)
test   $0x8,%r15b
mov    %rbx,%rax
cmove  0x2af6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x0(%r13),%esi
mov    0x2add(%rip),%rax
or     (%rax),%esi
mov    %r12,%rdi
mov    %rsp,%rdx
call   1030 <XChangeKeyboardControl@plt>
lea    0xb5f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
movl   $0x5,(%rsp)
test   $0x10,%r15b
cmove  0x2ab5(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,0x4(%rsp)
mov    0x0(%r13),%esi
mov    0x2a9c(%rip),%rax
or     (%rax),%esi
mov    %r12,%rdi
mov    %rsp,%rdx
call   1030 <XChangeKeyboardControl@plt>
lea    0xb1e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
lea    0x8(%rsp),%rsi
call   1040 <XGetKeyboardControl@plt>
lea    0xad3(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xb0a(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x29f1(%rip),%rax
mov    (%rax),%eax
test   %eax,%eax
mov    0x2a16(%rip),%r15
je     15e8 <main+0x428>
mov    (%r14),%rcx
mov    (%rcx),%edx
xor    %esi,%esi
xor    %edi,%edi
jmp    15ce <main+0x40e>
add    $0x1,%rdi
mov    %eax,%ebx
add    $0x2,%rsi
cmp    %rbx,%rdi
jae    15e8 <main+0x428>
test   %esi,%edx
je     15bf <main+0x3ff>
mov    0x10(%rsp,%rsi,2),%eax
mov    0x8(%rcx),%rbx
mov    %eax,(%rbx,%rsi,2)
mov    0x29b4(%rip),%rax
mov    (%rax),%eax
jmp    15bf <main+0x3ff>
mov    %r12,%rdi
mov    $0xffffffff,%esi
mov    %r14,%rdx
call   1080 <XkbSetIndicatorMap@plt>
lea    0xa40(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%r15),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10c0 <XkbFreeKeyboard@plt>
mov    %r12,%rdi
call   10e0 <XCloseDisplay@plt>
jmp    128d <main+0xcd>

LLVM IR (-O0):
%struct.TYPE_16__ = type { i32 }
%struct.TYPE_17__ = type { i32, i32 }
%struct.TYPE_15__ = type { %struct.TYPE_14__* }
%struct.TYPE_14__ = type { i32, %struct.TYPE_13__* }
%struct.TYPE_13__ = type { i32 }
@.str = [24 x i8] c"Cannot open display %s\0A\00"
@.str.1 = [26 x i8] c"Usage: %s display [mask]\0A\00"
@.str.2 = [29 x i8] c"Cannot open default display\0A\00"
@.str.3 = [17 x i8] c"Cannot allocate\0A\00"
@XkbAllIndicatorsMask = global i32 0
@.str.4 = [23 x i8] c"Cannot Get Indicators\0A\00"
@XkbAllNamesMask = global i32 0
@.str.5 = [18 x i8] c"Cannot Get Names\0A\00"
@XkbNumIndicators = global i32 0
@.str.6 = [13 x i8] c"led %d = %d\0A\00"
@XkbIM_NoAutomatic = global i32 0
@.str.7 = [25 x i8] c"XkbSetIndicatorMap = %d\0A\00"
@True = global i32 0
@.str.8 = [26 x i8] c"XGetKeyboardControl = %d\0A\00"
@.str.9 = [20 x i8] c"old mask = 0x%08lx\0A\00"
@LedModeOn = global i32 0
@LedModeOff = global i32 0
@.str.10 = [29 x i8] c"XChangeKeyboardControl = %d\0A\00"
@KBLed = global i32 0
@KBLedMode = global i32 0
@.str.11 = [20 x i8] c"new mask = 0x%08lx\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.TYPE_16__
%10 = alloca %struct.TYPE_17__
%11 = alloca %struct.TYPE_15__*
%12 = alloca [32 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32 0, i32* %7
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 2
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %38
18: ; preds = %15, %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @XOpenDisplay(i8* %21)
store i32* %22, i32** %6
%23 = icmp ne i32* %22, null
br i1 %23, label %29, label %24
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %27)
store i32 -1, i32* %3
br label %263
29: ; preds = %18
%30 = load i32, i32* %4
%31 = icmp sge i32 %30, 3
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @strtol(i8* %35, i32* null, i32 0)
store i32 %36, i32* %7
br label %37
37: ; preds = %32, %29
br label %43
38: ; preds = %15
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %41)
store i32 -1, i32* %3
br label %263
43: ; preds = %37
%44 = load i32*, i32** %6
%45 = icmp ne i32* %44, null
br i1 %45, label %51, label %46
46: ; preds = %43
%47 = call i32* @XOpenDisplay(i8* null)
store i32* %47, i32** %6
%48 = icmp ne i32* %47, null
br i1 %48, label %51, label %49
49: ; preds = %46
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %263
51: ; preds = %46, %43
%52 = call %struct.TYPE_15__* (...) @XkbAllocKeyboard()
store %struct.TYPE_15__* %52, %struct.TYPE_15__** %11
%53 = icmp ne %struct.TYPE_15__* %52, null
br i1 %53, label %56, label %54
54: ; preds = %51
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %263
56: ; preds = %51
%57 = load i32*, i32** %6
%58 = load i32, i32* @XkbAllIndicatorsMask
%59 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%60 = call i64 @XkbGetIndicatorMap(i32* %57, i32 %58, %struct.TYPE_15__* %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %56
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %263
64: ; preds = %56
%65 = load i32*, i32** %6
%66 = load i32, i32* @XkbAllNamesMask
%67 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%68 = call i64 @XkbGetNames(i32* %65, i32 %66, %struct.TYPE_15__* %67)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %64
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %263
72: ; preds = %64
store i32 0, i32* %8
br label %73
73: ; preds = %124, %72
%74 = load i32, i32* %8
%75 = load i32, i32* @XkbNumIndicators
%76 = icmp ult i32 %74, %75
br i1 %76, label %77, label %127
77: ; preds = %73
%78 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%79 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %78, i32 0, i32 0
%80 = load %struct.TYPE_14__*, %struct.TYPE_14__** %79
%81 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %80, i32 0, i32 0
%82 = load i32, i32* %81
%83 = load i32, i32* %8
%84 = shl i32 1, %83
%85 = and i32 %82, %84
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %123
87: ; preds = %77
%88 = load i32, i32* %8
%89 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%90 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %89, i32 0, i32 0
%91 = load %struct.TYPE_14__*, %struct.TYPE_14__** %90
%92 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %91, i32 0, i32 1
%93 = load %struct.TYPE_13__*, %struct.TYPE_13__** %92
%94 = load i32, i32* %8
%95 = zext i32 %94 to i64
%96 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %93, i64 %95
%97 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %96, i32 0, i32 0
%98 = load i32, i32* %97
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %88, i32 %98)
%100 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%101 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %100, i32 0, i32 0
%102 = load %struct.TYPE_14__*, %struct.TYPE_14__** %101
%103 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %102, i32 0, i32 1
%104 = load %struct.TYPE_13__*, %struct.TYPE_13__** %103
%105 = load i32, i32* %8
%106 = zext i32 %105 to i64
%107 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %104, i64 %106
%108 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %107, i32 0, i32 0
%109 = load i32, i32* %108
%110 = load i32, i32* %8
%111 = zext i32 %110 to i64
%112 = getelementptr inbounds [32 x i32], [32 x i32]* %12, i64 0, i64 %111
store i32 %109, i32* %112
%113 = load i32, i32* @XkbIM_NoAutomatic
%114 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%115 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %114, i32 0, i32 0
%116 = load %struct.TYPE_14__*, %struct.TYPE_14__** %115
%117 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %116, i32 0, i32 1
%118 = load %struct.TYPE_13__*, %struct.TYPE_13__** %117
%119 = load i32, i32* %8
%120 = zext i32 %119 to i64
%121 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %118, i64 %120
%122 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %121, i32 0, i32 0
store i32 %113, i32* %122
br label %123
123: ; preds = %87, %77
br label %124
124: ; preds = %123
%125 = load i32, i32* %8
%126 = add i32 %125, 1
store i32 %126, i32* %8
br label %73
127: ; preds = %73
%128 = load i32*, i32** %6
%129 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%130 = call i32 @XkbSetIndicatorMap(i32* %128, i32 -1, %struct.TYPE_15__* %129)
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %130)
%132 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%133 = load i32, i32* @True
%134 = call i32 @XkbFreeKeyboard(%struct.TYPE_15__* %132, i32 0, i32 %133)
%135 = call %struct.TYPE_15__* (...) @XkbAllocKeyboard()
store %struct.TYPE_15__* %135, %struct.TYPE_15__** %11
%136 = icmp ne %struct.TYPE_15__* %135, null
br i1 %136, label %139, label %137
137: ; preds = %127
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %263
139: ; preds = %127
%140 = load i32*, i32** %6
%141 = load i32, i32* @XkbAllIndicatorsMask
%142 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%143 = call i64 @XkbGetIndicatorMap(i32* %140, i32 %141, %struct.TYPE_15__* %142)
%144 = icmp ne i64 %143, 0
br i1 %144, label %145, label %147
145: ; preds = %139
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %263
147: ; preds = %139
store i32 0, i32* %8
br label %148
148: ; preds = %176, %147
%149 = load i32, i32* %8
%150 = load i32, i32* @XkbNumIndicators
%151 = icmp ult i32 %149, %150
br i1 %151, label %152, label %179
152: ; preds = %148
%153 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%154 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %153, i32 0, i32 0
%155 = load %struct.TYPE_14__*, %struct.TYPE_14__** %154
%156 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %155, i32 0, i32 0
%157 = load i32, i32* %156
%158 = load i32, i32* %8
%159 = shl i32 1, %158
%160 = and i32 %157, %159
%161 = icmp ne i32 %160, 0
br i1 %161, label %162, label %175
162: ; preds = %152
%163 = load i32, i32* %8
%164 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%165 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %164, i32 0, i32 0
%166 = load %struct.TYPE_14__*, %struct.TYPE_14__** %165
%167 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %166, i32 0, i32 1
%168 = load %struct.TYPE_13__*, %struct.TYPE_13__** %167
%169 = load i32, i32* %8
%170 = zext i32 %169 to i64
%171 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %168, i64 %170
%172 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %171, i32 0, i32 0
%173 = load i32, i32* %172
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %163, i32 %173)
br label %175
175: ; preds = %162, %152
br label %176
176: ; preds = %175
%177 = load i32, i32* %8
%178 = add i32 %177, 1
store i32 %178, i32* %8
br label %148
179: ; preds = %148
%180 = load i32*, i32** %6
%181 = call i32 @XGetKeyboardControl(i32* %180, %struct.TYPE_16__* %9)
%182 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %181)
%183 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %9, i32 0, i32 0
%184 = load i32, i32* %183
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %184)
store i32 0, i32* %8
br label %186
186: ; preds = %211, %179
%187 = load i32, i32* %8
%188 = icmp ult i32 %187, 5
br i1 %188, label %189, label %214
189: ; preds = %186
%190 = load i32, i32* %8
%191 = add i32 %190, 1
%192 = getelementptr inbounds %struct.TYPE_17__, %struct.TYPE_17__* %10, i32 0, i32 0
store i32 %191, i32* %192
%193 = load i32, i32* %7
%194 = load i32, i32* %8
%195 = shl i32 1, %194
%196 = and i32 %193, %195
%197 = icmp ne i32 %196, 0
br i1 %197, label %198, label %200
198: ; preds = %189
%199 = load i32, i32* @LedModeOn
br label %202
200: ; preds = %189
%201 = load i32, i32* @LedModeOff
br label %202
202: ; preds = %200, %198
%203 = phi i32 [ %199, %198 ], [ %201, %200 ]
%204 = getelementptr inbounds %struct.TYPE_17__, %struct.TYPE_17__* %10, i32 0, i32 1
store i32 %203, i32* %204
%205 = load i32*, i32** %6
%206 = load i32, i32* @KBLed
%207 = load i32, i32* @KBLedMode
%208 = or i32 %206, %207
%209 = call i32 @XChangeKeyboardControl(i32* %205, i32 %208, %struct.TYPE_17__* %10)
%210 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %209)
br label %211
211: ; preds = %202
%212 = load i32, i32* %8
%213 = add i32 %212, 1
store i32 %213, i32* %8
br label %186
214: ; preds = %186
%215 = load i32*, i32** %6
%216 = call i32 @XGetKeyboardControl(i32* %215, %struct.TYPE_16__* %9)
%217 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %216)
%218 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %9, i32 0, i32 0
%219 = load i32, i32* %218
%220 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i32 %219)
store i32 0, i32* %8
br label %221
221: ; preds = %250, %214
%222 = load i32, i32* %8
%223 = load i32, i32* @XkbNumIndicators
%224 = icmp ult i32 %222, %223
br i1 %224, label %225, label %253
225: ; preds = %221
%226 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%227 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %226, i32 0, i32 0
%228 = load %struct.TYPE_14__*, %struct.TYPE_14__** %227
%229 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %228, i32 0, i32 0
%230 = load i32, i32* %229
%231 = load i32, i32* %8
%232 = shl i32 %231, 1
%233 = and i32 %230, %232
%234 = icmp ne i32 %233, 0
br i1 %234, label %235, label %249
235: ; preds = %225
%236 = load i32, i32* %8
%237 = zext i32 %236 to i64
%238 = getelementptr inbounds [32 x i32], [32 x i32]* %12, i64 0, i64 %237
%239 = load i32, i32* %238
%240 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%241 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %240, i32 0, i32 0
%242 = load %struct.TYPE_14__*, %struct.TYPE_14__** %241
%243 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %242, i32 0, i32 1
%244 = load %struct.TYPE_13__*, %struct.TYPE_13__** %243
%245 = load i32, i32* %8
%246 = zext i32 %245 to i64
%247 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %244, i64 %246
%248 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %247, i32 0, i32 0
store i32 %239, i32* %248
br label %249
249: ; preds = %235, %225
br label %250
250: ; preds = %249
%251 = load i32, i32* %8
%252 = add i32 %251, 1
store i32 %252, i32* %8
br label %221
253: ; preds = %221
%254 = load i32*, i32** %6
%255 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%256 = call i32 @XkbSetIndicatorMap(i32* %254, i32 -1, %struct.TYPE_15__* %255)
%257 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %256)
%258 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%259 = load i32, i32* @True
%260 = call i32 @XkbFreeKeyboard(%struct.TYPE_15__* %258, i32 0, i32 %259)
%261 = load i32*, i32** %6
%262 = call i32 @XCloseDisplay(i32* %261)
store i32 0, i32* %3
br label %263
263: ; preds = %253, %145, %137, %70, %62, %54, %49, %38, %24
%264 = load i32, i32* %3
ret i32 %264
}

LLVM IR (-O2):
%struct.TYPE_16__ = type { i32 }
%struct.TYPE_17__ = type { i32, i32 }
%struct.TYPE_15__ = type { %struct.TYPE_14__* }
%struct.TYPE_14__ = type { i32, %struct.TYPE_13__* }
%struct.TYPE_13__ = type { i32 }
@.str = [24 x i8] c"Cannot open display %s\0A\00"
@.str.1 = [26 x i8] c"Usage: %s display [mask]\0A\00"
@XkbAllIndicatorsMask = global i32 0
@XkbAllNamesMask = global i32 0
@XkbNumIndicators = global i32 0
@.str.6 = [13 x i8] c"led %d = %d\0A\00"
@XkbIM_NoAutomatic = global i32 0
@.str.7 = [25 x i8] c"XkbSetIndicatorMap = %d\0A\00"
@True = global i32 0
@.str.8 = [26 x i8] c"XGetKeyboardControl = %d\0A\00"
@.str.9 = [20 x i8] c"old mask = 0x%08lx\0A\00"
@LedModeOn = global i32 0
@LedModeOff = global i32 0
@.str.10 = [29 x i8] c"XChangeKeyboardControl = %d\0A\00"
@KBLed = global i32 0
@KBLedMode = global i32 0
@.str.11 = [20 x i8] c"new mask = 0x%08lx\0A\00"
@str.12 = [16 x i8] c"Cannot allocate\00"
@str.14 = [17 x i8] c"Cannot Get Names\00"
@str.15 = [22 x i8] c"Cannot Get Indicators\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.TYPE_16__
%4 = alloca %struct.TYPE_17__
%5 = alloca [32 x i32]
%6 = bitcast %struct.TYPE_16__* %3 to i8*
%7 = bitcast %struct.TYPE_17__* %4 to i8*
%8 = bitcast [32 x i32]* %5 to i8*
%9 = and i32 %0, -2
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %25
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @XOpenDisplay(i8* %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %12
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %218
19: ; preds = %11
%20 = icmp ugt i32 %0, 2
br i1 %20, label %21, label %28
21: ; preds = %19
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32 @strtol(i8* nocapture %23, i32* null, i32 0)
br label %28
25: ; preds = %2
%26 = load i8*, i8** %1
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %218
28: ; preds = %21, %19
%29 = phi i32 [ %24, %21 ], [ 0, %19 ]
%30 = tail call %struct.TYPE_15__* (...) @XkbAllocKeyboard()
%31 = icmp eq %struct.TYPE_15__* %30, null
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0))
br label %218
34: ; preds = %28
%35 = load i32, i32* @XkbAllIndicatorsMask
%36 = tail call i64 @XkbGetIndicatorMap(i32* %14, i32 %35, %struct.TYPE_15__* %30)
%37 = icmp eq i64 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %34
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.15, i64 0, i64 0))
br label %218
40: ; preds = %34
%41 = load i32, i32* @XkbAllNamesMask
%42 = tail call i64 @XkbGetNames(i32* %14, i32 %41, %struct.TYPE_15__* %30)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = load i32, i32* @XkbNumIndicators
%46 = icmp eq i32 %45, 0
br i1 %46, label %82, label %47
47: ; preds = %44
%48 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %30, i64 0, i32 0
%49 = load %struct.TYPE_14__*, %struct.TYPE_14__** %48
br label %52
50: ; preds = %40
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.14, i64 0, i64 0))
br label %218
52: ; preds = %47, %76
%53 = phi i32 [ %45, %47 ], [ %77, %76 ]
%54 = phi %struct.TYPE_14__* [ %49, %47 ], [ %78, %76 ]
%55 = phi i64 [ 0, %47 ], [ %79, %76 ]
%56 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %54, i64 0, i32 0
%57 = load i32, i32* %56
%58 = trunc i64 %55 to i32
%59 = shl nuw i32 1, %58
%60 = and i32 %57, %59
%61 = icmp eq i32 %60, 0
br i1 %61, label %76, label %62
62: ; preds = %52
%63 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %54, i64 0, i32 1
%64 = load %struct.TYPE_13__*, %struct.TYPE_13__** %63
%65 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %64, i64 %55, i32 0
%66 = load i32, i32* %65
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %58, i32 %66)
%68 = load %struct.TYPE_14__*, %struct.TYPE_14__** %48
%69 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %68, i64 0, i32 1
%70 = load %struct.TYPE_13__*, %struct.TYPE_13__** %69
%71 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %70, i64 %55, i32 0
%72 = load i32, i32* %71
%73 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 %55
store i32 %72, i32* %73
%74 = load i32, i32* @XkbIM_NoAutomatic
store i32 %74, i32* %71
%75 = load i32, i32* @XkbNumIndicators
br label %76
76: ; preds = %52, %62
%77 = phi i32 [ %53, %52 ], [ %75, %62 ]
%78 = phi %struct.TYPE_14__* [ %54, %52 ], [ %68, %62 ]
%79 = add nuw nsw i64 %55, 1
%80 = zext i32 %77 to i64
%81 = icmp ult i64 %79, %80
br i1 %81, label %52, label %82
82: ; preds = %76, %44
%83 = tail call i32 @XkbSetIndicatorMap(i32* %14, i32 -1, %struct.TYPE_15__* %30)
%84 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %83)
%85 = load i32, i32* @True
%86 = tail call i32 @XkbFreeKeyboard(%struct.TYPE_15__* %30, i32 0, i32 %85)
%87 = tail call %struct.TYPE_15__* (...) @XkbAllocKeyboard()
%88 = icmp eq %struct.TYPE_15__* %87, null
br i1 %88, label %89, label %91
89: ; preds = %82
%90 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0))
br label %218
91: ; preds = %82
%92 = load i32, i32* @XkbAllIndicatorsMask
%93 = tail call i64 @XkbGetIndicatorMap(i32* %14, i32 %92, %struct.TYPE_15__* %87)
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %100
95: ; preds = %91
%96 = load i32, i32* @XkbNumIndicators
%97 = icmp eq i32 %96, 0
br i1 %97, label %124, label %98
98: ; preds = %95
%99 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %87, i64 0, i32 0
br label %102
100: ; preds = %91
%101 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.15, i64 0, i64 0))
br label %218
102: ; preds = %98, %119
%103 = phi i32 [ %96, %98 ], [ %120, %119 ]
%104 = phi i64 [ 0, %98 ], [ %121, %119 ]
%105 = load %struct.TYPE_14__*, %struct.TYPE_14__** %99
%106 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %105, i64 0, i32 0
%107 = load i32, i32* %106
%108 = trunc i64 %104 to i32
%109 = shl nuw i32 1, %108
%110 = and i32 %107, %109
%111 = icmp eq i32 %110, 0
br i1 %111, label %119, label %112
112: ; preds = %102
%113 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %105, i64 0, i32 1
%114 = load %struct.TYPE_13__*, %struct.TYPE_13__** %113
%115 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %114, i64 %104, i32 0
%116 = load i32, i32* %115
%117 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %108, i32 %116)
%118 = load i32, i32* @XkbNumIndicators
br label %119
119: ; preds = %102, %112
%120 = phi i32 [ %103, %102 ], [ %118, %112 ]
%121 = add nuw nsw i64 %104, 1
%122 = zext i32 %120 to i64
%123 = icmp ult i64 %121, %122
br i1 %123, label %102, label %124
124: ; preds = %119, %95
%125 = call i32 @XGetKeyboardControl(i32* %14, %struct.TYPE_16__* %3)
%126 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %125)
%127 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %3, i64 0, i32 0
%128 = load i32, i32* %127
%129 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %128)
%130 = getelementptr inbounds %struct.TYPE_17__, %struct.TYPE_17__* %4, i64 0, i32 0
%131 = getelementptr inbounds %struct.TYPE_17__, %struct.TYPE_17__* %4, i64 0, i32 1
store i32 1, i32* %130
%132 = and i32 %29, 1
%133 = icmp eq i32 %132, 0
%134 = load i32, i32* @LedModeOn
%135 = load i32, i32* @LedModeOff
%136 = select i1 %133, i32 %135, i32 %134
store i32 %136, i32* %131
%137 = load i32, i32* @KBLed
%138 = load i32, i32* @KBLedMode
%139 = or i32 %138, %137
%140 = call i32 @XChangeKeyboardControl(i32* %14, i32 %139, %struct.TYPE_17__* %4)
%141 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %140)
store i32 2, i32* %130
%142 = and i32 %29, 2
%143 = icmp eq i32 %142, 0
%144 = load i32, i32* @LedModeOn
%145 = load i32, i32* @LedModeOff
%146 = select i1 %143, i32 %145, i32 %144
store i32 %146, i32* %131
%147 = load i32, i32* @KBLed
%148 = load i32, i32* @KBLedMode
%149 = or i32 %148, %147
%150 = call i32 @XChangeKeyboardControl(i32* %14, i32 %149, %struct.TYPE_17__* %4)
%151 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %150)
store i32 3, i32* %130
%152 = and i32 %29, 4
%153 = icmp eq i32 %152, 0
%154 = load i32, i32* @LedModeOn
%155 = load i32, i32* @LedModeOff
%156 = select i1 %153, i32 %155, i32 %154
store i32 %156, i32* %131
%157 = load i32, i32* @KBLed
%158 = load i32, i32* @KBLedMode
%159 = or i32 %158, %157
%160 = call i32 @XChangeKeyboardControl(i32* %14, i32 %159, %struct.TYPE_17__* %4)
%161 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %160)
store i32 4, i32* %130
%162 = and i32 %29, 8
%163 = icmp eq i32 %162, 0
%164 = load i32, i32* @LedModeOn
%165 = load i32, i32* @LedModeOff
%166 = select i1 %163, i32 %165, i32 %164
store i32 %166, i32* %131
%167 = load i32, i32* @KBLed
%168 = load i32, i32* @KBLedMode
%169 = or i32 %168, %167
%170 = call i32 @XChangeKeyboardControl(i32* %14, i32 %169, %struct.TYPE_17__* %4)
%171 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %170)
store i32 5, i32* %130
%172 = and i32 %29, 16
%173 = icmp eq i32 %172, 0
%174 = load i32, i32* @LedModeOn
%175 = load i32, i32* @LedModeOff
%176 = select i1 %173, i32 %175, i32 %174
store i32 %176, i32* %131
%177 = load i32, i32* @KBLed
%178 = load i32, i32* @KBLedMode
%179 = or i32 %178, %177
%180 = call i32 @XChangeKeyboardControl(i32* %14, i32 %179, %struct.TYPE_17__* %4)
%181 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %180)
%182 = call i32 @XGetKeyboardControl(i32* %14, %struct.TYPE_16__* %3)
%183 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %182)
%184 = load i32, i32* %127
%185 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i32 %184)
%186 = load i32, i32* @XkbNumIndicators
%187 = icmp eq i32 %186, 0
br i1 %187, label %212, label %188
188: ; preds = %124
%189 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %87, i64 0, i32 0
%190 = load %struct.TYPE_14__*, %struct.TYPE_14__** %189
%191 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %190, i64 0, i32 0
%192 = load i32, i32* %191
%193 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %190, i64 0, i32 1
br label %194
194: ; preds = %188, %207
%195 = phi i32 [ %186, %188 ], [ %208, %207 ]
%196 = phi i64 [ 0, %188 ], [ %209, %207 ]
%197 = trunc i64 %196 to i32
%198 = shl i32 %197, 1
%199 = and i32 %192, %198
%200 = icmp eq i32 %199, 0
br i1 %200, label %207, label %201
201: ; preds = %194
%202 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 %196
%203 = load i32, i32* %202
%204 = load %struct.TYPE_13__*, %struct.TYPE_13__** %193
%205 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %204, i64 %196, i32 0
store i32 %203, i32* %205
%206 = load i32, i32* @XkbNumIndicators
br label %207
207: ; preds = %194, %201
%208 = phi i32 [ %195, %194 ], [ %206, %201 ]
%209 = add nuw nsw i64 %196, 1
%210 = zext i32 %208 to i64
%211 = icmp ult i64 %209, %210
br i1 %211, label %194, label %212
212: ; preds = %207, %124
%213 = call i32 @XkbSetIndicatorMap(i32* %14, i32 -1, %struct.TYPE_15__* %87)
%214 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %213)
%215 = load i32, i32* @True
%216 = call i32 @XkbFreeKeyboard(%struct.TYPE_15__* %87, i32 0, i32 %215)
%217 = call i32 @XCloseDisplay(i32* %14)
br label %218
218: ; preds = %212, %100, %89, %50, %38, %32, %25, %16
%219 = phi i32 [ -1, %38 ], [ -1, %50 ], [ -1, %100 ], [ 0, %212 ], [ -1, %89 ], [ -1, %32 ], [ -1, %16 ], [ -1, %25 ]
ret i32 %219
}