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

/* Variables and functions */
int None;
int /*<<< orphan*/ PropModeReplace;
int /*<<< orphan*/ XChangeProperty(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int, int, int, int /*<<< orphan*/,
                                   unsigned char *, int);
int XInternAtom(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
void set_frameless_or_fullscreen(Display *dpy, Window win, int mode) {
  if (mode == 1) {
    Atom atoms[2] = {XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", 0), None};
    XChangeProperty(dpy, win, XInternAtom(dpy, "_NET_WM_STATE", 0), 4, 32,
                    PropModeReplace, (unsigned char *)atoms, 1);
  } else {
    Atom mwmHintsProperty = XInternAtom(dpy, "_MOTIF_WM_HINTS", 0);
    static uint32_t hints[5] = {2, 0, 0, 0, 0};
    XChangeProperty(dpy, win, mwmHintsProperty, mwmHintsProperty, 32,
                    PropModeReplace, (unsigned char *)hints, 5);
  }
}


x86 assembly (clang, -O0):
<set_frameless_or_fullscreen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    11b5 <set_frameless_or_fullscreen+0x95>
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
xor    %edx,%edx
call   1030 <XInternAtom@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e90(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea3(%rip),%rsi
xor    %edx,%edx
call   1030 <XInternAtom@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    %eax,%edx
mov    0x2e4b(%rip),%rax
mov    (%rax),%r9d
lea    -0x18(%rbp),%rax
mov    $0x4,%ecx
mov    $0x20,%r8d
mov    %rax,(%rsp)
movl   $0x1,0x8(%rsp)
call   1040 <XChangeProperty@plt>
jmp    11ff <set_frameless_or_fullscreen+0xdf>
mov    -0x8(%rbp),%rdi
lea    0xe67(%rip),%rsi
xor    %edx,%edx
call   1030 <XInternAtom@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    0x2dfa(%rip),%rax
mov    (%rax),%r9d
mov    $0x20,%r8d
lea    0x2e52(%rip),%rax
mov    %rax,(%rsp)
movl   $0x5,0x8(%rsp)
call   1040 <XChangeProperty@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_frameless_or_fullscreen>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
cmp    $0x1,%edx
jne    1182 <set_frameless_or_fullscreen+0x62>
lea    0xecc(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1030 <XInternAtom@plt>
mov    %eax,(%rsp)
mov    0x2ea0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
lea    0xec4(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1030 <XInternAtom@plt>
mov    0x2e72(%rip),%rcx
mov    (%rcx),%r9d
mov    %rsp,%r10
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
mov    $0x4,%ecx
mov    $0x20,%r8d
push   $0x1
jmp    11b5 <set_frameless_or_fullscreen+0x95>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1030 <XInternAtom@plt>
mov    0x2e3e(%rip),%rcx
mov    (%rcx),%r9d
lea    0x2e9c(%rip),%r10
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
mov    %eax,%ecx
mov    $0x20,%r8d
push   $0x5
push   %r10
call   1040 <XChangeProperty@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"_NET_WM_STATE_FULLSCREEN\00"
@None = global i32 0
@.str.1 = [14 x i8] c"_NET_WM_STATE\00"
@PropModeReplace = global i32 0
@.str.2 = [16 x i8] c"_MOTIF_WM_HINTS\00"
@set_frameless_or_fullscreen.hints = internal global [5 x i32] [i32 2, i32 0, i32 0, i32 0, i32 0]
define void @set_frameless_or_fullscreen(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [2 x i32]
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %25
11: ; preds = %3
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%13 = load i32*, i32** %4
%14 = call i32 @XInternAtom(i32* %13, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %14, i32* %12
%15 = getelementptr inbounds i32, i32* %12, i64 1
%16 = load i32, i32* @None
store i32 %16, i32* %15
%17 = load i32*, i32** %4
%18 = load i32, i32* %5
%19 = load i32*, i32** %4
%20 = call i32 @XInternAtom(i32* %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 0)
%21 = load i32, i32* @PropModeReplace
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%23 = bitcast i32* %22 to i8*
%24 = call i32 @XChangeProperty(i32* %17, i32 %18, i32 %20, i32 4, i32 32, i32 %21, i8* %23, i32 1)
br label %34
25: ; preds = %3
%26 = load i32*, i32** %4
%27 = call i32 @XInternAtom(i32* %26, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 0)
store i32 %27, i32* %8
%28 = load i32*, i32** %4
%29 = load i32, i32* %5
%30 = load i32, i32* %8
%31 = load i32, i32* %8
%32 = load i32, i32* @PropModeReplace
%33 = call i32 @XChangeProperty(i32* %28, i32 %29, i32 %30, i32 %31, i32 32, i32 %32, i8* bitcast ([5 x i32]* @set_frameless_or_fullscreen.hints to i8*), i32 5)
br label %34
34: ; preds = %25, %11
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"_NET_WM_STATE_FULLSCREEN\00"
@None = global i32 0
@.str.1 = [14 x i8] c"_NET_WM_STATE\00"
@PropModeReplace = global i32 0
@.str.2 = [16 x i8] c"_MOTIF_WM_HINTS\00"
@set_frameless_or_fullscreen.hints = internal global [5 x i32] [i32 2, i32 0, i32 0, i32 0, i32 0]
define void @set_frameless_or_fullscreen(i32* %0, i32 %1, i32 %2) {
%4 = alloca [2 x i32]
%5 = icmp eq i32 %2, 1
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = bitcast [2 x i32]* %4 to i8*
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%9 = tail call i32 @XInternAtom(i32* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %9, i32* %8
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%11 = load i32, i32* @None
store i32 %11, i32* %10
%12 = tail call i32 @XInternAtom(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 0)
%13 = load i32, i32* @PropModeReplace
%14 = call i32 @XChangeProperty(i32* %0, i32 %1, i32 %12, i32 4, i32 32, i32 %13, i8* %7, i32 1)
br label %19
15: ; preds = %3
%16 = tail call i32 @XInternAtom(i32* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 0)
%17 = load i32, i32* @PropModeReplace
%18 = tail call i32 @XChangeProperty(i32* %0, i32 %1, i32 %16, i32 %16, i32 32, i32 %17, i8* bitcast ([5 x i32]* @set_frameless_or_fullscreen.hints to i8*), i32 5)
br label %19
19: ; preds = %15, %6
ret void
}