#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 group;
};
typedef TYPE_1__ XkbStateRec;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
scalar_t__ Success;
scalar_t__ XkbGetState(int /*<<< orphan*/ *, int /*<<< orphan*/, TYPE_1__ *);
int /*<<< orphan*/ XkbUseCoreKbd;
int /*<<< orphan*/ printf(char *);
void get_active_gr(Display *dpy, int *active) {
  XkbStateRec state;
  if (XkbGetState(dpy, XkbUseCoreKbd, &state) != Success)
    printf("XkbGetState() failed\n");
  *active = state.group;
}


x86 assembly (clang, -O0):
<get_active_gr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2ea5(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1030 <XkbGetState@plt>
mov    0x2eab(%rip),%rcx
cmp    (%rcx),%rax
je     1162 <get_active_gr+0x42>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_active_gr>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    0x2eb1(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
call   1040 <XkbGetState@plt>
mov    0x2eb6(%rip),%rcx
cmp    (%rcx),%rax
je     1153 <get_active_gr+0x33>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%eax
mov    %eax,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@XkbUseCoreKbd = global i32 0
@Success = global i64 0
@.str = [22 x i8] c"XkbGetState() failed\0A\00"
define void @get_active_gr(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca %struct.TYPE_3__
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %3
%7 = load i32, i32* @XkbUseCoreKbd
%8 = call i64 @XkbGetState(i32* %6, i32 %7, %struct.TYPE_3__* %5)
%9 = load i64, i64* @Success
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i32 0, i32 0
%15 = load i32, i32* %14
%16 = load i32*, i32** %4
store i32 %15, i32* %16
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32 }
@XkbUseCoreKbd = global i32 0
@Success = global i64 0
@str = [21 x i8] c"XkbGetState() failed\00"
define void @get_active_gr(i32* %0, i32* nocapture writeonly %1) {
%3 = alloca %struct.TYPE_3__
%4 = bitcast %struct.TYPE_3__* %3 to i8*
%5 = load i32, i32* @XkbUseCoreKbd
%6 = call i64 @XkbGetState(i32* %0, i32 %5, %struct.TYPE_3__* %3)
%7 = load i64, i64* @Success
%8 = icmp eq i64 %6, %7
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 0
%13 = load i32, i32* %12
store i32 %13, i32* %1
ret void
}