// File: /workspace/github_c_makefile_star2_O2/veltzer[P]xmeltdown/src/xmeltdown.c
// Function: main
int main(int argc, char** argv, char** envp) {
	char *display=NULL;
	unsigned long vmask;
	XSetWindowAttributes xswat;
	XGCValues gcvals;
	Bool use_planes=False;
	int i;

	srandom(getpid());
	for (i=1; i < argc; i++) {
		if (strncmp(argv[i], "-dis", 4) == 0) {
			if (argv[i+1])
				display=argv[++i];
			else
				usage();
		} else if (strncmp(argv[i], "-p", 2) == 0) {
			use_planes=1;
		} else
			usage();
	}
	if ((dpy=XOpenDisplay(display)) == NULL) {
		fprintf(stderr, "can't open display\n");
		exit(0);
	}
	screen=DefaultScreen(dpy);

	xswat.override_redirect=True;
	xswat.do_not_propagate_mask=KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask;
	vmask=CWOverrideRedirect|CWDontPropagate;
	win=XCreateWindow(dpy, RootWindow(dpy, screen), 0, 0,
		DisplayWidth(dpy, screen), DisplayHeight(dpy, screen),
		0, CopyFromParent, CopyFromParent, CopyFromParent, vmask,
		&xswat);
	XMapWindow(dpy, win);

	gcvals.graphics_exposures=False;
	/* copyplane gc wants to leave the data alone */
	gcvals.foreground=1;
	gcvals.background=0;
	copygc=XCreateGC(dpy, win,
		GCForeground|GCBackground|GCGraphicsExposures, &gcvals);

	gcvals.foreground=BlackPixel(dpy, screen);
	fillgc=XCreateGC(dpy, win, GCForeground, &gcvals);

	XSync(dpy, 0);
	if (use_planes) {
		do_planes();
	} else {
		do_all();
	}
	sleep(2);
	return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %rbx
movl %edi, 0x34(%rsp)
callq 0x1080
movl %eax, %edi
callq 0x1070
pushq $0x1
popq %r12
xorl %r14d, %r14d
xorl %r15d, %r15d
cmpl 0x34(%rsp), %r12d
jge 0x12f4
movslq %r12d, %rbp
movq (%rbx,%rbp,8), %r13
movq %r13, %rdi
leaq 0xd81(%rip), %rsi       # 0x2038
pushq $0x4
popq %rdx
callq 0x1040
testl %eax, %eax
je 0x12de
cmpb $0x2d, (%r13)
jne 0x143c
cmpb $0x70, 0x1(%r13)
pushq $0x1
popq %r15
je 0x12ef
jmp 0x143c
movq 0x8(%rbx,%rbp,8), %r14
testq %r14, %r14
je 0x143c
incl %r12d
incl %r12d
jmp 0x129f
movq %r14, %rdi
callq 0x1090
movq %rax, 0x2dbd(%rip)      # 0x40c0
testq %rax, %rax
je 0x1441
movslq 0xe0(%rax), %rcx
movl %ecx, 0x2daf(%rip)      # 0x40c8
leaq 0x38(%rsp), %rdx
movl $0x1, 0x58(%rdx)
movq $0xf, 0x50(%rdx)
movq 0xe8(%rax), %rdi
shlq $0x7, %rcx
movq 0x10(%rdi,%rcx), %rsi
movl 0x18(%rdi,%rcx), %r8d
movl 0x1c(%rdi,%rcx), %r9d
andq $0x0, 0x18(%rsp)
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
movq %rdx, 0x28(%rsp)
movq $0x1200, 0x20(%rsp)     # imm = 0x1200
movq %rax, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x1060
movq %rax, 0x2d54(%rip)      # 0x40d0
movq 0x2d3d(%rip), %rdi      # 0x40c0
movq %rax, %rsi
callq 0x10e0
leaq 0xa8(%rsp), %rbx
andl $0x0, 0x64(%rbx)
movq $0x1, 0x10(%rbx)
andq $0x0, 0x18(%rbx)
movq 0x2d15(%rip), %rdi      # 0x40c0
movq 0x2d1e(%rip), %rsi      # 0x40d0
movl $0x1000c, %edx          # imm = 0x1000C
movq %rbx, %rcx
callq 0x10f0
movq %rax, 0x2d12(%rip)      # 0x40d8
movq 0x2cf3(%rip), %rdi      # 0x40c0
movq 0xe8(%rdi), %rax
movslq 0x2ced(%rip), %rcx      # 0x40c8
shlq $0x7, %rcx
movq 0x60(%rax,%rcx), %rax
movq %rax, 0x10(%rbx)
movq 0x2ce1(%rip), %rsi      # 0x40d0
pushq $0x4
popq %rdx
movq %rbx, %rcx
callq 0x10f0
movq %rax, 0x2cdf(%rip)      # 0x40e0
movq 0x2cb8(%rip), %rdi      # 0x40c0
xorl %esi, %esi
callq 0x1100
testl %r15d, %r15d
je 0x141b
callq 0x1464
jmp 0x1420
callq 0x1777
pushq $0x2
popq %rdi
callq 0x10c0
xorl %eax, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x124c
movq 0x2ba8(%rip), %rax      # 0x3ff0
movq (%rax), %rcx
leaq 0xbeb(%rip), %rdi       # 0x203d
pushq $0x13
popq %rsi
pushq $0x1
popq %rdx
callq 0x1140
xorl %edi, %edi
callq 0x1030