// File: /workspace/github_c_makefile_star2_O0/seanpringle[P]xoat/./textbox.c
// Function: textbox_create
Textbox* textbox_create(Window parent, unsigned long flags, short x, short y, short w, short h, char *font, char *fg, char *bg, char *text, char *prompt)
{
	Textbox *tb = calloc(1, sizeof(Textbox));

	tb->flags = flags;
	tb->parent = parent;

	tb->x = x; tb->y = y; tb->w = MAX(1, w); tb->h = MAX(1, h);

	XColor color; Colormap map = DefaultColormap(display, DefaultScreen(display));
	unsigned int cp = XAllocNamedColor(display, map, bg, &color, &color) ? color.pixel: None;

	tb->window = XCreateSimpleWindow(display, tb->parent, tb->x, tb->y, tb->w, tb->h, 0, None, cp);

	// need to preload the font to calc line height
	textbox_font(tb, font, fg, bg);

	tb->prompt = strdup(prompt ? prompt: "");
	textbox_text(tb, text ? text: "");

	// auto height/width modes get handled here
	textbox_moveresize(tb, tb->x, tb->y, tb->w, tb->h);

	// edit mode controls
	if (tb->flags & TB_EDITABLE)
	{
		tb->xim = XOpenIM(display, NULL, NULL, NULL);
		tb->xic = XCreateIC(tb->xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, tb->window, XNFocusWindow, tb->window, NULL);
	}

	return tb;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl %r8d, -0x54(%rbp)
movl %ecx, %eax
movl -0x54(%rbp), %ecx
movl %eax, -0x50(%rbp)
movl %edx, %eax
movl -0x50(%rbp), %edx
movl %eax, -0x4c(%rbp)
movq %rsi, %rax
movl -0x4c(%rbp), %esi
movq %rax, -0x48(%rbp)
movq %rdi, %r8
movq -0x48(%rbp), %rdi
movw %r9w, %ax
movq 0x30(%rbp), %r9
movq 0x28(%rbp), %r9
movq 0x20(%rbp), %r9
movq 0x18(%rbp), %r9
movq 0x10(%rbp), %r9
movq %r8, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movw %si, -0x12(%rbp)
movw %dx, -0x14(%rbp)
movw %cx, -0x16(%rbp)
movw %ax, -0x18(%rbp)
movl $0x1, %edi
movl $0x80, %esi
callq 0x3500
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movw -0x12(%rbp), %cx
movq -0x20(%rbp), %rax
movw %cx, 0x18(%rax)
movw -0x14(%rbp), %cx
movq -0x20(%rbp), %rax
movw %cx, 0x1a(%rax)
movswl -0x16(%rbp), %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jle 0x3ce9
movl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x3cf0
movswl -0x16(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x1c(%rax)
movswl -0x18(%rbp), %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jle 0x3d15
movl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x3d1c
movswl -0x18(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x1e(%rax)
movq 0xfe6f(%rip), %rax      # 0x13ba0
movq 0xe8(%rax), %rax
movq 0xfe61(%rip), %rcx      # 0x13ba0
movslq 0xe0(%rcx), %rcx
shlq $0x7, %rcx
addq %rcx, %rax
movq 0x50(%rax), %rax
movq %rax, -0x38(%rbp)
movq 0xfe44(%rip), %rdi      # 0x13ba0
movq -0x38(%rbp), %rsi
movq 0x20(%rbp), %rdx
leaq -0x30(%rbp), %r8
movq %r8, %rcx
callq 0x31a0
cmpl $0x0, %eax
je 0x3d7f
movq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x3d87
xorl %eax, %eax
movq %rax, -0x68(%rbp)
jmp 0x3d87
movq -0x68(%rbp), %rax
movl %eax, -0x3c(%rbp)
movq 0xfe0b(%rip), %rdi      # 0x13ba0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rax
movswl 0x18(%rax), %edx
movq -0x20(%rbp), %rax
movswl 0x1a(%rax), %ecx
movq -0x20(%rbp), %rax
movswl 0x1c(%rax), %r8d
movq -0x20(%rbp), %rax
movswl 0x1e(%rax), %r9d
movl -0x3c(%rbp), %eax
xorl %r10d, %r10d
xorl %r10d, %r10d
movl $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x31e0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq 0x20(%rbp), %rcx
callq 0x3f30
cmpq $0x0, 0x30(%rbp)
je 0x3e13
movq 0x30(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x3e20
leaq 0xb7ec(%rip), %rax      # 0xf606
movq %rax, -0x70(%rbp)
jmp 0x3e20
movq -0x70(%rbp), %rdi
callq 0x3430
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, 0x28(%rbp)
je 0x3e4d
movq 0x28(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x3e5a
leaq 0xb7b2(%rip), %rax      # 0xf606
movq %rax, -0x80(%rbp)
jmp 0x3e5a
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x4070
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movswl 0x18(%rax), %esi
movq -0x20(%rbp), %rax
movswl 0x1a(%rax), %edx
movq -0x20(%rbp), %rax
movswl 0x1c(%rax), %ecx
movq -0x20(%rbp), %rax
movswl 0x1e(%rax), %r8d
callq 0x4180
movq -0x20(%rbp), %rax
movq (%rax), %rax
andq $0x80000, %rax          # imm = 0x80000
cmpq $0x0, %rax
je 0x3f19
movq 0xfcf5(%rip), %rdi      # 0x13ba0
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x34a0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %r8
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
leaq 0xb39a(%rip), %rsi      # 0xf27e
movl $0x408, %edx            # imm = 0x408
leaq 0xb399(%rip), %rcx      # 0xf289
leaq 0xb39f(%rip), %r9       # 0xf296
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, %al
callq 0x3030
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x20(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)