#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 mods;
  int base_mods;
  int latched_mods;
  int locked_mods;
  int compat_state;
};
typedef TYPE_1__ XkbStateRec;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ XkbGetState(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               TYPE_1__ *);
int /*<<< orphan*/ *XkbOpenDisplay(int /*<<< orphan*/ *, int *, int *, int *,
                                   int *, int *);
int /*<<< orphan*/ XkbUseCoreKbd;
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int event_rtrn = 0;
  int error_rtrn = 0;
  int major_in_out = 1;
  int minor_in_out = 0;
  int reason_rtrn = 0;
  Display *display = NULL;
  display = XkbOpenDisplay(NULL, &event_rtrn, &error_rtrn, &major_in_out,
                           &minor_in_out, &reason_rtrn);
  printf("\n  Display handle:  %#010x\n", (unsigned int)display);
  XkbStateRec state;
  XkbGetState(display, XkbUseCoreKbd, &state);
  printf("\n  mods:          %x", state.mods);
  printf("\n  base_mods:     %x", state.base_mods);
  printf("\n  latched_mods:  %x", state.latched_mods);
  printf("\n  locked_mods:   %x", state.locked_mods);
  printf("\n  compat_state:  %x", state.compat_state);
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
lea    -0x24(%rbp),%r9
call   1050 <XkbOpenDisplay@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %eax,%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdx
call   1030 <XkbGetState@plt>
mov    -0x48(%rbp),%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x1,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0x4(%rsp),%r9
xor    %edi,%edi
call   1060 <XkbOpenDisplay@plt>
mov    %rax,%rbx
lea    0xe69(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <XkbGetState@plt>
mov    0x18(%rsp),%esi
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%esi
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%rsp),%esi
lea    0xe64(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rsp),%esi
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe03(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32, i32, i32, i32 }
@.str = [28 x i8] c"\0A Display handle: %x\0A\00"
@XkbUseCoreKbd = global i32 0
@.str.1 = [21 x i8] c"\0A mods: %x\00"
@.str.2 = [21 x i8] c"\0A base_mods: %x\00"
@.str.3 = [21 x i8] c"\0A latched_mods: %x\00"
@.str.4 = [21 x i8] c"\0A locked_mods: %x\00"
@.str.5 = [21 x i8] c"\0A compat_state: %x\00"
@.str.6 = [3 x i8] c"\0A\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 i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca %struct.TYPE_3__
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 1, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32* null, i32** %11
%13 = call i32* @XkbOpenDisplay(i32* null, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10)
store i32* %13, i32** %11
%14 = load i32*, i32** %11
%15 = ptrtoint i32* %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32*, i32** %11
%18 = load i32, i32* @XkbUseCoreKbd
%19 = call i32 @XkbGetState(i32* %17, i32 %18, %struct.TYPE_3__* %12)
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 1
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 2
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 3
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 4
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32, i32, i32, i32 }
@.str = [28 x i8] c"\0A Display handle: %x\0A\00"
@XkbUseCoreKbd = global i32 0
@.str.1 = [21 x i8] c"\0A mods: %x\00"
@.str.2 = [21 x i8] c"\0A base_mods: %x\00"
@.str.3 = [21 x i8] c"\0A latched_mods: %x\00"
@.str.4 = [21 x i8] c"\0A locked_mods: %x\00"
@.str.5 = [21 x i8] c"\0A compat_state: %x\00"
@str = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.TYPE_3__
%9 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%10 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%11 = bitcast i32* %5 to i8*
store i32 1, i32* %5
%12 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%13 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%14 = call i32* @XkbOpenDisplay(i32* null, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7)
%15 = ptrtoint i32* %14 to i64
%16 = trunc i64 %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = bitcast %struct.TYPE_3__* %8 to i8*
%19 = load i32, i32* @XkbUseCoreKbd
%20 = call i32 @XkbGetState(i32* %14, i32 %19, %struct.TYPE_3__* %8)
%21 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i64 0, i32 0
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i64 0, i32 1
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i64 0, i32 2
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i64 0, i32 3
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i64 0, i32 4
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %34)
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}