#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*/ Display;

/* Variables and functions */
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ sscanf(char *, char *, scalar_t__ *);
int /*<<< orphan*/ toggle_window_decorations(int /*<<< orphan*/ *, scalar_t__);
int main(int argc, char *argv[]) {
  Display *display;
  Window window;
  display = XOpenDisplay(NULL);
  if (display == NULL)
    return 1;
  window = 0;
  if (argc > 0) {
    sscanf(argv[1], "0x%lx", &window);
    if (window == 0)
      sscanf(argv[1], "%lu", &window);
  }
  if (window == 0)
    return 1;
  toggle_window_decorations(display, window);
  XCloseDisplay(display);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117a <main+0x3a>
movl   $0x1,-0x4(%rbp)
jmp    1200 <main+0xc0>
movq   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11cc <main+0x8c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe65(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <sscanf@plt>
cmpq   $0x0,-0x20(%rbp)
jne    11c7 <main+0x87>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe48(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <sscanf@plt>
jmp    11cc <main+0x8c>
cmpq   $0x0,-0x20(%rbp)
jne    11e3 <main+0xa3>
movl   $0x1,-0x4(%rbp)
jmp    1200 <main+0xc0>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <toggle_window_decorations@plt>
mov    -0x18(%rbp),%rdi
call   1060 <XCloseDisplay@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
xor    %edi,%edi
call   1040 <XOpenDisplay@plt>
mov    $0x1,%r15d
test   %rax,%rax
je     11b8 <main+0x78>
movq   $0x0,(%rsp)
test   %ebp,%ebp
jle    11b8 <main+0x78>
mov    %rax,%rbx
mov    0x8(%r14),%rdi
lea    0xe88(%rip),%rsi
mov    %rsp,%rdx
call   1050 <sscanf@plt>
mov    (%rsp),%rsi
test   %rsi,%rsi
jne    11a5 <main+0x65>
mov    0x8(%r14),%rdi
lea    0xe72(%rip),%rsi
mov    %rsp,%rdx
call   1050 <sscanf@plt>
mov    (%rsp),%rsi
test   %rsi,%rsi
je     11b8 <main+0x78>
mov    %rbx,%rdi
call   1030 <toggle_window_decorations@plt>
mov    %rbx,%rdi
call   1060 <XCloseDisplay@plt>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"0x%lx\00"
@.str.1 = [4 x i8] c"%lu\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32* @XOpenDisplay(i32* null)
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %38
12: ; preds = %2
store i64 0, i64* %7
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %7)
%20 = load i64, i64* %7
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %15
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %7)
br label %27
27: ; preds = %22, %15
br label %28
28: ; preds = %27, %12
%29 = load i64, i64* %7
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 1, i32* %3
br label %38
32: ; preds = %28
%33 = load i32*, i32** %6
%34 = load i64, i64* %7
%35 = call i32 @toggle_window_decorations(i32* %33, i64 %34)
%36 = load i32*, i32** %6
%37 = call i32 @XCloseDisplay(i32* %36)
store i32 0, i32* %3
br label %38
38: ; preds = %32, %31, %11
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [6 x i8] c"0x%lx\00"
@.str.1 = [4 x i8] c"%lu\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call i32* @XOpenDisplay(i32* null)
%6 = icmp eq i32* %5, null
br i1 %6, label %24, label %7
7: ; preds = %2
store i64 0, i64* %3
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %24
9: ; preds = %7
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %3)
%13 = load i64, i64* %3
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %9
%16 = load i8*, i8** %10
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%18 = load i64, i64* %3
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %9, %15
%21 = phi i64 [ %18, %15 ], [ %13, %9 ]
%22 = call i32 @toggle_window_decorations(i32* %5, i64 %21)
%23 = call i32 @XCloseDisplay(i32* %5)
br label %24
24: ; preds = %7, %15, %2, %20
%25 = phi i32 [ 0, %20 ], [ 1, %2 ], [ 1, %15 ], [ 1, %7 ]
ret i32 %25
}