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

/* Variables and functions */
int /*<<< orphan*/ CopyFromParent;
int /*<<< orphan*/ PropModeReplace;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ True;
int /*<<< orphan*/ WhitePixel(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XA_CARDINAL;
int /*<<< orphan*/ XA_WINDOW;
int /*<<< orphan*/ XChangeProperty(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/, int /*<<< orphan*/, int,
                                   int /*<<< orphan*/, unsigned char *, int);
int /*<<< orphan*/ XCreateWindow(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                 int, int, int, int, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XInternAtom(int /*<<< orphan*/ *, char *,
                               int /*<<< orphan*/);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XSetWindowBackground(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int main() {
  Display *display;
  Window win, twin;
  XEvent report;
  Atom atime, atimewin;
  int x = 10, y = 10, h = 400, w = 400;
  Time num;
  display = XOpenDisplay(NULL);
  if (display == NULL) {
    fprintf(stderr, "couldn't connect to X server :0\n");
    return 0;
  }
  atime = XInternAtom(display, "_NET_WM_USER_TIME", True);
  atimewin = XInternAtom(display, "_NET_WM_USER_TIME_WINDOW", True);
  win = XCreateWindow(display, RootWindow(display, 0), x, y, w, h, 10,
                      CopyFromParent, CopyFromParent, CopyFromParent, 0, 0);
  twin = XCreateWindow(display, RootWindow(display, 0), x, y, w / 2, h / 2, 10,
                       CopyFromParent, CopyFromParent, CopyFromParent, 0, 0);
  XSetWindowBackground(display, win, WhitePixel(display, 0));
  XMapWindow(display, win);
  XFlush(display);
  sleep(2);
  printf("Setting time window\n");
  XChangeProperty(display, win, atimewin, XA_WINDOW, 32, PropModeReplace,
                  (unsigned char *)&twin, 1);
  XFlush(display);
  sleep(1);
  num = 100;
  printf("Setting time stamp on time window\n");
  XChangeProperty(display, twin, atime, XA_CARDINAL, 32, PropModeReplace,
                  (unsigned char *)&num, 1);
  XFlush(display);
  while (1) {
    XNextEvent(display, &report);
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x98,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0xa,-0x30(%rbp)
movl   $0xa,-0x34(%rbp)
movl   $0x190,-0x38(%rbp)
movl   $0x190,-0x3c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1238 <main+0x68>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %rbp
ret
mov    -0x18(%rbp),%rdi
mov    0x2da5(%rip),%rax
mov    (%rax),%edx
lea    0xdd5(%rip),%rsi
call   1080 <XInternAtom@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2d89(%rip),%rax
mov    (%rax),%edx
lea    0xdcb(%rip),%rsi
call   1080 <XInternAtom@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   10b0 <RootWindow@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%esi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    0x2d1a(%rip),%rax
mov    (%rax),%r11d
mov    0x2d10(%rip),%rax
mov    (%rax),%r10d
mov    0x2d06(%rip),%rax
mov    (%rax),%eax
xor    %ebx,%ebx
movl   $0xa,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
call   10a0 <XCreateWindow@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   10b0 <RootWindow@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%esi
mov    -0x30(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x34(%rbp),%ecx
mov    -0x3c(%rbp),%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    %eax,%r8d
mov    -0x38(%rbp),%eax
mov    $0x2,%r9d
cltd
idiv   %r9d
mov    -0x54(%rbp),%edx
mov    %eax,%r9d
mov    0x2c89(%rip),%rax
mov    (%rax),%r11d
mov    0x2c7f(%rip),%rax
mov    (%rax),%r10d
mov    0x2c75(%rip),%rax
mov    (%rax),%eax
xor    %ebx,%ebx
movl   $0xa,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
call   10a0 <XCreateWindow@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1040 <WhitePixel@plt>
mov    -0x50(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    %eax,%edx
call   10e0 <XSetWindowBackground@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10d0 <XMapWindow@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <XFlush@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
lea    0xc8b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    0x2bf9(%rip),%rax
mov    (%rax),%ecx
mov    0x2be0(%rip),%rax
mov    (%rax),%r9d
lea    -0x20(%rbp),%rax
mov    $0x20,%r8d
mov    %rax,(%rsp)
movl   $0x1,0x8(%rsp)
call   1090 <XChangeProperty@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <XFlush@plt>
mov    $0x1,%edi
call   10f0 <sleep@plt>
movl   $0x64,-0x40(%rbp)
lea    0xc42(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    0x2b93(%rip),%rax
mov    (%rax),%ecx
mov    0x2b82(%rip),%rax
mov    (%rax),%r9d
lea    -0x40(%rbp),%rax
mov    $0x20,%r8d
mov    %rax,(%rsp)
movl   $0x1,0x8(%rsp)
call   1090 <XChangeProperty@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <XFlush@plt>
mov    -0x18(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1070 <XNextEvent@plt>
jmp    1465 <main+0x295>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1050 <XOpenDisplay@plt>
test   %rax,%rax
je     138d <main+0x1bd>
mov    %rax,%rbx
mov    0x2df0(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xe1f(%rip),%rsi
mov    %rax,%rdi
call   1080 <XInternAtom@plt>
mov    %eax,%r14d
mov    0x0(%rbp),%edx
lea    0xe1c(%rip),%rsi
mov    %rbx,%rdi
call   1080 <XInternAtom@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <RootWindow@plt>
mov    0x2d85(%rip),%r12
mov    (%r12),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xa,%edx
mov    $0xa,%ecx
mov    $0x190,%r8d
mov    $0x190,%r9d
push   $0x0
push   $0x0
push   %rbp
push   %rbp
push   %rbp
push   $0xa
call   10a0 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,%r13d
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <RootWindow@plt>
mov    (%r12),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xa,%edx
mov    $0xa,%ecx
mov    $0xc8,%r8d
mov    $0xc8,%r9d
push   $0x0
push   $0x0
push   %rbp
push   %rbp
push   %rbp
push   $0xa
call   10a0 <XCreateWindow@plt>
add    $0x30,%rsp
mov    %eax,0xc(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <WhitePixel@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %eax,%edx
call   10e0 <XSetWindowBackground@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
call   10d0 <XMapWindow@plt>
mov    %rbx,%rdi
call   10c0 <XFlush@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
lea    0xd6b(%rip),%rdi
call   1030 <puts@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%ecx
mov    0x2cca(%rip),%r12
mov    (%r12),%r9d
lea    0xc(%rsp),%rax
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    $0x20,%r8d
push   $0x1
push   %rax
call   1090 <XChangeProperty@plt>
add    $0x10,%rsp
mov    %rbx,%rdi
call   10c0 <XFlush@plt>
mov    $0x1,%edi
call   10f0 <sleep@plt>
movl   $0x64,0x10(%rsp)
lea    0xd25(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
mov    0x2c7d(%rip),%rax
mov    (%rax),%ecx
mov    (%r12),%r9d
lea    0x10(%rsp),%rax
mov    %rbx,%rdi
mov    %r14d,%edx
mov    $0x20,%r8d
push   $0x1
push   %rax
call   1090 <XChangeProperty@plt>
add    $0x10,%rsp
mov    %rbx,%rdi
call   10c0 <XFlush@plt>
lea    0x14(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <XNextEvent@plt>
jmp    1380 <main+0x1b0>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
lea    0xc63(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@.str.1 = [18 x i8] c"_NET_WM_USER_TIME\00"
@True = global i32 0
@.str.2 = [25 x i8] c"_NET_WM_USER_TIME_WINDOW\00"
@CopyFromParent = global i32 0
@.str.3 = [21 x i8] c"Setting time window\0A\00"
@XA_WINDOW = global i32 0
@PropModeReplace = global i32 0
@.str.4 = [35 x i8] c"Setting time stamp on time window\0A\00"
@XA_CARDINAL = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %8
store i32 10, i32* %9
store i32 400, i32* %10
store i32 400, i32* %11
%13 = call i32* @XOpenDisplay(i32* null)
store i32* %13, i32** %2
%14 = load i32*, i32** %2
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %0
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret i32 0
19: ; preds = %0
%20 = load i32*, i32** %2
%21 = load i32, i32* @True
%22 = call i32 @XInternAtom(i32* %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %21)
store i32 %22, i32* %6
%23 = load i32*, i32** %2
%24 = load i32, i32* @True
%25 = call i32 @XInternAtom(i32* %23, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %24)
store i32 %25, i32* %7
%26 = load i32*, i32** %2
%27 = load i32*, i32** %2
%28 = call i32 @RootWindow(i32* %27, i32 0)
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = load i32, i32* %11
%32 = load i32, i32* %10
%33 = load i32, i32* @CopyFromParent
%34 = load i32, i32* @CopyFromParent
%35 = load i32, i32* @CopyFromParent
%36 = call i32 @XCreateWindow(i32* %26, i32 %28, i32 %29, i32 %30, i32 %31, i32 %32, i32 10, i32 %33, i32 %34, i32 %35, i32 0, i32 0)
store i32 %36, i32* %3
%37 = load i32*, i32** %2
%38 = load i32*, i32** %2
%39 = call i32 @RootWindow(i32* %38, i32 0)
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = load i32, i32* %11
%43 = sdiv i32 %42, 2
%44 = load i32, i32* %10
%45 = sdiv i32 %44, 2
%46 = load i32, i32* @CopyFromParent
%47 = load i32, i32* @CopyFromParent
%48 = load i32, i32* @CopyFromParent
%49 = call i32 @XCreateWindow(i32* %37, i32 %39, i32 %40, i32 %41, i32 %43, i32 %45, i32 10, i32 %46, i32 %47, i32 %48, i32 0, i32 0)
store i32 %49, i32* %4
%50 = load i32*, i32** %2
%51 = load i32, i32* %3
%52 = load i32*, i32** %2
%53 = call i32 @WhitePixel(i32* %52, i32 0)
%54 = call i32 @XSetWindowBackground(i32* %50, i32 %51, i32 %53)
%55 = load i32*, i32** %2
%56 = load i32, i32* %3
%57 = call i32 @XMapWindow(i32* %55, i32 %56)
%58 = load i32*, i32** %2
%59 = call i32 @XFlush(i32* %58)
%60 = call i32 @sleep(i32 2)
%61 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%62 = load i32*, i32** %2
%63 = load i32, i32* %3
%64 = load i32, i32* %7
%65 = load i32, i32* @XA_WINDOW
%66 = load i32, i32* @PropModeReplace
%67 = bitcast i32* %4 to i8*
%68 = call i32 @XChangeProperty(i32* %62, i32 %63, i32 %64, i32 %65, i32 32, i32 %66, i8* %67, i32 1)
%69 = load i32*, i32** %2
%70 = call i32 @XFlush(i32* %69)
%71 = call i32 @sleep(i32 1)
store i32 100, i32* %12
%72 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%73 = load i32*, i32** %2
%74 = load i32, i32* %4
%75 = load i32, i32* %6
%76 = load i32, i32* @XA_CARDINAL
%77 = load i32, i32* @PropModeReplace
%78 = bitcast i32* %12 to i8*
%79 = call i32 @XChangeProperty(i32* %73, i32 %74, i32 %75, i32 %76, i32 32, i32 %77, i8* %78, i32 1)
%80 = load i32*, i32** %2
%81 = call i32 @XFlush(i32* %80)
br label %82
82: ; preds = %19, %82
%83 = load i32*, i32** %2
%84 = call i32 @XNextEvent(i32* %83, i32* %5)
br label %82
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"couldn't connect to X server :0\0A\00"
@.str.1 = [18 x i8] c"_NET_WM_USER_TIME\00"
@True = global i32 0
@.str.2 = [25 x i8] c"_NET_WM_USER_TIME_WINDOW\00"
@CopyFromParent = global i32 0
@XA_WINDOW = global i32 0
@PropModeReplace = global i32 0
@XA_CARDINAL = global i32 0
@str = [20 x i8] c"Setting time window\00"
@str.5 = [34 x i8] c"Setting time stamp on time window\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32* @XOpenDisplay(i32* null)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret i32 0
12: ; preds = %0
%13 = load i32, i32* @True
%14 = tail call i32 @XInternAtom(i32* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @True
%16 = tail call i32 @XInternAtom(i32* %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = tail call i32 @RootWindow(i32* %7, i32 0)
%18 = load i32, i32* @CopyFromParent
%19 = tail call i32 @XCreateWindow(i32* %7, i32 %17, i32 10, i32 10, i32 400, i32 400, i32 10, i32 %18, i32 %18, i32 %18, i32 0, i32 0)
%20 = tail call i32 @RootWindow(i32* %7, i32 0)
%21 = load i32, i32* @CopyFromParent
%22 = tail call i32 @XCreateWindow(i32* %7, i32 %20, i32 10, i32 10, i32 200, i32 200, i32 10, i32 %21, i32 %21, i32 %21, i32 0, i32 0)
store i32 %22, i32* %1
%23 = tail call i32 @WhitePixel(i32* %7, i32 0)
%24 = tail call i32 @XSetWindowBackground(i32* %7, i32 %19, i32 %23)
%25 = tail call i32 @XMapWindow(i32* %7, i32 %19)
%26 = tail call i32 @XFlush(i32* %7)
%27 = tail call i32 @sleep(i32 2)
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%29 = load i32, i32* @XA_WINDOW
%30 = load i32, i32* @PropModeReplace
%31 = call i32 @XChangeProperty(i32* %7, i32 %19, i32 %16, i32 %29, i32 32, i32 %30, i8* %4, i32 1)
%32 = call i32 @XFlush(i32* %7)
%33 = call i32 @sleep(i32 1)
store i32 100, i32* %3
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.5, i64 0, i64 0))
%35 = load i32, i32* %1
%36 = load i32, i32* @XA_CARDINAL
%37 = load i32, i32* @PropModeReplace
%38 = call i32 @XChangeProperty(i32* %7, i32 %35, i32 %14, i32 %36, i32 32, i32 %37, i8* %6, i32 1)
%39 = call i32 @XFlush(i32* %7)
br label %40
40: ; preds = %40, %12
%41 = call i32 @XNextEvent(i32* %7, i32* %2)
br label %40
}