#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 */
typedef scalar_t__ Window;
typedef int /*<<< orphan*/ KeyCode;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
scalar_t__ DefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ False;
int /*<<< orphan*/ GrabModeAsync;
int /*<<< orphan*/ XGrabKey(int /*<<< orphan*/ *, int /*<<< orphan*/,
                            unsigned int, scalar_t__, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
void grab_key(Display *dpy, KeyCode keycode, unsigned int modifier,
              Window win) {
  XGrabKey(dpy, keycode, modifier, (win ? win : DefaultRootWindow(dpy)), False,
           GrabModeAsync, GrabModeAsync);
}


x86 assembly (clang, -O0):
<grab_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1162 <grab_key+0x42>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    116f <grab_key+0x4f>
mov    -0x8(%rbp),%rdi
call   1030 <DefaultRootWindow@plt>
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%esi
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    0x2e64(%rip),%rax
mov    (%rax),%r8d
mov    0x2e4a(%rip),%rax
mov    (%rax),%r9d
mov    0x2e40(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
call   1040 <XGrabKey@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grab_key>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
test   %rcx,%rcx
jne    1140 <grab_key+0x20>
mov    %rbx,%rdi
call   1030 <DefaultRootWindow@plt>
mov    %rax,%rcx
mov    0x2ea1(%rip),%rax
mov    (%rax),%r8d
mov    0x2e87(%rip),%rax
mov    (%rax),%r9d
mov    %r9d,(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <XGrabKey@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@False = global i32 0
@GrabModeAsync = global i32 0
define void @grab_key(i32* %0, i32 %1, i32 %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i64 %3, i64* %8
%9 = load i32*, i32** %5
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = load i64, i64* %8
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %4
%15 = load i64, i64* %8
br label %19
16: ; preds = %4
%17 = load i32*, i32** %5
%18 = call i64 @DefaultRootWindow(i32* %17)
br label %19
19: ; preds = %16, %14
%20 = phi i64 [ %15, %14 ], [ %18, %16 ]
%21 = load i32, i32* @False
%22 = load i32, i32* @GrabModeAsync
%23 = load i32, i32* @GrabModeAsync
%24 = call i32 @XGrabKey(i32* %9, i32 %10, i32 %11, i64 %20, i32 %21, i32 %22, i32 %23)
ret void
}

LLVM IR (-O2):
@False = global i32 0
@GrabModeAsync = global i32 0
define void @grab_key(i32* %0, i32 %1, i32 %2, i64 %3) {
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i64 @DefaultRootWindow(i32* %0)
br label %8
8: ; preds = %4, %6
%9 = phi i64 [ %7, %6 ], [ %3, %4 ]
%10 = load i32, i32* @False
%11 = load i32, i32* @GrabModeAsync
%12 = tail call i32 @XGrabKey(i32* %0, i32 %1, i32 %2, i64 %9, i32 %10, i32 %11, i32 %11)
ret void
}