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

/* Variables and functions */
int DefaultScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ False;
int /*<<< orphan*/ PropModeReplace;
int /*<<< orphan*/ RootWindow(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ XA_CARDINAL;
int /*<<< orphan*/ XChangeProperty(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/, int /*<<< orphan*/, int,
                                   int /*<<< orphan*/, unsigned char *, int);
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ XInternAtom(int /*<<< orphan*/ *, char *,
                               int /*<<< orphan*/);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
unsigned long atoi(char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  unsigned long data[4];
  Display *display;
  int screen;
  Window root;
  if (argc < 4) {
    printf("pls, you need to give 4 numbers to me.\n"
           "The first is layout, 0 is horizontal and 1 is vertical.\n"
           "Second and third is number of desks horizontally and vertically.\n"
           "The last is starting corner, 0 = topleft, 1 = topright,\n"
           "                             2 = bottomright, 3 = bottomleft.\n");
    return 1;
  }
  data[0] = atoi(argv[1]);
  data[1] = atoi(argv[2]);
  data[2] = atoi(argv[3]);
  data[3] = atoi(argv[4]);
  display = XOpenDisplay(NULL);
  screen = DefaultScreen(display);
  root = RootWindow(display, screen);
  XChangeProperty(display, root,
                  XInternAtom(display, "_NET_DESKTOP_LAYOUT", False),
                  XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&data, 4);
  XFlush(display);
  XCloseDisplay(display);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11c8 <main+0x38>
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ab <main+0x11b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1090 <atoi@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <XOpenDisplay@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   10a0 <DefaultScreen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%esi
call   1070 <RootWindow@plt>
mov    %eax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rdi
mov    0x2d9b(%rip),%rax
mov    (%rax),%edx
lea    0xec1(%rip),%rsi
call   1050 <XInternAtom@plt>
mov    -0x50(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    %eax,%edx
mov    0x2d6d(%rip),%rax
mov    (%rax),%ecx
mov    0x2d5c(%rip),%rax
mov    (%rax),%r9d
lea    -0x30(%rbp),%rax
mov    $0x20,%r8d
mov    %rax,(%rsp)
movl   $0x4,0x8(%rsp)
call   1060 <XChangeProperty@plt>
mov    -0x38(%rbp),%rdi
call   1080 <XFlush@plt>
mov    -0x38(%rbp),%rdi
call   10b0 <XCloseDisplay@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
cmp    $0x3,%edi
jg     11b4 <main+0x24>
lea    0xe70(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
jmp    1267 <main+0xd7>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %rax,(%rsp)
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
mov    %rax,0x8(%rsp)
mov    0x18(%rbx),%rdi
call   1090 <atoi@plt>
mov    %rax,0x10(%rsp)
mov    0x20(%rbx),%rdi
call   1090 <atoi@plt>
mov    %rax,0x18(%rsp)
xor    %r14d,%r14d
xor    %edi,%edi
call   1040 <XOpenDisplay@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <DefaultScreen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <RootWindow@plt>
mov    %eax,%ebp
mov    0x2dd2(%rip),%rax
mov    (%rax),%edx
lea    0xde1(%rip),%rsi
mov    %rbx,%rdi
call   1050 <XInternAtom@plt>
mov    0x2daa(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2d99(%rip),%rdx
mov    (%rdx),%r9d
mov    %rsp,%r10
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
mov    $0x20,%r8d
push   $0x4
push   %r10
call   1060 <XChangeProperty@plt>
add    $0x10,%rsp
mov    %rbx,%rdi
call   1080 <XFlush@plt>
mov    %rbx,%rdi
call   10b0 <XCloseDisplay@plt>
mov    %r14d,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [279 x i8] c"pls, you need to give 4 numbers to me.\0AThe first is layout, 0 is horizontal and 1 is vertical.\0ASecond and third is number of desks horizontally and vertically.\0AThe last is starting corner, 0 = topleft, 1 = topright,\0A 2 = bottomright, 3 = bottomleft.\0A\00"
@.str.1 = [20 x i8] c"_NET_DESKTOP_LAYOUT\00"
@False = global i32 0
@XA_CARDINAL = global i32 0
@PropModeReplace = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i64]
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([279 x i8], [279 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %54
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @atoi(i8* %17)
%19 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 0
store i64 %18, i64* %19
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i64 @atoi(i8* %22)
%24 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 1
store i64 %23, i64* %24
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
%28 = call i64 @atoi(i8* %27)
%29 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 2
store i64 %28, i64* %29
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 4
%32 = load i8*, i8** %31
%33 = call i64 @atoi(i8* %32)
%34 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 3
store i64 %33, i64* %34
%35 = call i32* @XOpenDisplay(i32* null)
store i32* %35, i32** %7
%36 = load i32*, i32** %7
%37 = call i32 @DefaultScreen(i32* %36)
store i32 %37, i32* %8
%38 = load i32*, i32** %7
%39 = load i32, i32* %8
%40 = call i32 @RootWindow(i32* %38, i32 %39)
store i32 %40, i32* %9
%41 = load i32*, i32** %7
%42 = load i32, i32* %9
%43 = load i32*, i32** %7
%44 = load i32, i32* @False
%45 = call i32 @XInternAtom(i32* %43, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = load i32, i32* @XA_CARDINAL
%47 = load i32, i32* @PropModeReplace
%48 = bitcast [4 x i64]* %6 to i8*
%49 = call i32 @XChangeProperty(i32* %41, i32 %42, i32 %45, i32 %46, i32 32, i32 %47, i8* %48, i32 4)
%50 = load i32*, i32** %7
%51 = call i32 @XFlush(i32* %50)
%52 = load i32*, i32** %7
%53 = call i32 @XCloseDisplay(i32* %52)
store i32 0, i32* %3
br label %54
54: ; preds = %14, %12
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"_NET_DESKTOP_LAYOUT\00"
@False = global i32 0
@XA_CARDINAL = global i32 0
@PropModeReplace = global i32 0
@str = [278 x i8] c"pls, you need to give 4 numbers to me.\0AThe first is layout, 0 is horizontal and 1 is vertical.\0ASecond and third is number of desks horizontally and vertically.\0AThe last is starting corner, 0 = topleft, 1 = topright,\0A 2 = bottomright, 3 = bottomleft.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i64]
%4 = bitcast [4 x i64]* %3 to i8*
%5 = icmp slt i32 %0, 4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([278 x i8], [278 x i8]* @str, i64 0, i64 0))
br label %35
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @atoi(i8* %10)
%12 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 0
store i64 %11, i64* %12
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i64 @atoi(i8* %14)
%16 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 1
store i64 %15, i64* %16
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i64 @atoi(i8* %18)
%20 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 2
store i64 %19, i64* %20
%21 = getelementptr inbounds i8*, i8** %1, i64 4
%22 = load i8*, i8** %21
%23 = tail call i64 @atoi(i8* %22)
%24 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 3
store i64 %23, i64* %24
%25 = tail call i32* @XOpenDisplay(i32* null)
%26 = tail call i32 @DefaultScreen(i32* %25)
%27 = tail call i32 @RootWindow(i32* %25, i32 %26)
%28 = load i32, i32* @False
%29 = tail call i32 @XInternAtom(i32* %25, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* @XA_CARDINAL
%31 = load i32, i32* @PropModeReplace
%32 = call i32 @XChangeProperty(i32* %25, i32 %27, i32 %29, i32 %30, i32 32, i32 %31, i8* %4, i32 4)
%33 = call i32 @XFlush(i32* %25)
%34 = call i32 @XCloseDisplay(i32* %25)
br label %35
35: ; preds = %8, %6
%36 = phi i32 [ 1, %6 ], [ 0, %8 ]
ret i32 %36
}