// File: /workspace/github_c_makefile_star2_O1/mikecat[P]x86_interpreter/pe_libs.c
// Function: pe_libs_initialize
int pe_libs_initialize(uint32_t work_start, uint32_t argc, uint32_t argv) {
	if (UINT32_MAX - work_start < WORK_SIZE - 1) {
		fprintf(stderr, "no enough space for PE work\n");
		return 0;
	}
	work_origin = work_start;
	dmemory_allocate(work_origin, WORK_SIZE);
	if (argc == 0) { /* ダミーの引数情報を利用 */
		argc_value = 1;
		argv_value = WORK_ARGV0;
	} else { /* 構築された引数情報を利用 */
		argc_value = argc;
		argv_value = argv;
	}
	dmem_write_uint(WORK_ARGV0, WORK_PNAME, 4);
	dmem_write_uint(WORK_ARGV1, 0, 4);
	dmem_write_uint(WORK_ENV0, 0, 4);
	dmemory_write("x\0\0\0", WORK_PNAME, 4);
	dmem_write_uint(WORK_FMODE, 0x00004000, 4); /* O_TEXT */
	dmem_write_uint(WORK_ERRNO, 0, 4);
	dmem_write_uint(WORK_DAYLIGHT, 0, 4);
	dmem_write_uint(WORK_TIMEZONE, -UINT32_C(9) * 60 * 60, 4);
	dmem_write_uint(WORK_TZNAME, WORK_TZNAME0, 4);
	dmem_write_uint(WORK_TZNAME + 4, WORK_TZNAME1, 4);
	dmemory_write("JST\0", WORK_TZNAME0, 4);
	dmemory_write("\0\0\0\0", WORK_TZNAME1, 4);

	if (!dmem_libc_stdio_initialize(WORK_IOB)) return 0;
	if (!dmem_libc_stdlib_initialize(WORK_HEAP_START)) return 0;
	if (!dmem_libc_string_initialize()) return 0;
	if (!dmem_libc_time_initialize(WORK_LIBC_TIME_DATA)) return 0;
	return 1;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
cmpl $0xffffd001, %edi       # imm = 0xFFFFD001
jae 0xc136
movl %edx, %ebx
movl %esi, %ebp
movl %edi, 0x11e0f(%rip)     # 0x1ddbc
movl $0x3000, %esi           # imm = 0x3000
callq 0x6edb
testl %ebp, %ebp
je 0xbfc3
movl %ebp, 0x11dff(%rip)     # 0x1ddc0
jmp 0xbfd3
movl $0x1, 0x11df3(%rip)     # 0x1ddc0
movl 0x11de9(%rip), %ebx     # 0x1ddbc
movl %ebx, 0x11deb(%rip)     # 0x1ddc4
movl 0x11ddd(%rip), %edi     # 0x1ddbc
leal 0xc(%rdi), %esi
movl $0x4, %edx
callq 0x71e8
movl 0x11dca(%rip), %edi     # 0x1ddbc
addl $0x4, %edi
xorl %ebx, %ebx
xorl %esi, %esi
movl $0x4, %edx
callq 0x71e8
movl 0x11db3(%rip), %edi     # 0x1ddbc
addl $0x8, %edi
xorl %esi, %esi
movl $0x4, %edx
callq 0x71e8
movl 0x11d9e(%rip), %esi     # 0x1ddbc
addl $0xc, %esi
leaq 0x2d2f(%rip), %rdi      # 0xed57
movl $0x4, %edx
callq 0x6d8a
movl 0x11d84(%rip), %edi     # 0x1ddbc
addl $0x10, %edi
movl $0x4000, %esi           # imm = 0x4000
movl $0x4, %edx
callq 0x71e8
movl 0x11d6c(%rip), %edi     # 0x1ddbc
addl $0x14, %edi
xorl %esi, %esi
movl $0x4, %edx
callq 0x71e8
movl 0x11d57(%rip), %edi     # 0x1ddbc
addl $0x18, %edi
xorl %esi, %esi
movl $0x4, %edx
callq 0x71e8
movl 0x11d42(%rip), %edi     # 0x1ddbc
addl $0x18, %edi
movl $0xffff8170, %esi       # imm = 0xFFFF8170
movl $0x4, %edx
callq 0x71e8
movl 0x11d2a(%rip), %esi     # 0x1ddbc
leal 0x1c(%rsi), %edi
addl $0x20, %esi
movl $0x4, %edx
callq 0x71e8
movl 0x11d14(%rip), %esi     # 0x1ddbc
leal 0x20(%rsi), %edi
addl $0x24, %esi
movl $0x4, %edx
callq 0x71e8
movl 0x11cfe(%rip), %esi     # 0x1ddbc
addl $0x20, %esi
leaq 0x2c94(%rip), %rdi      # 0xed5c
movl $0x4, %edx
callq 0x6d8a
movl 0x11ce4(%rip), %esi     # 0x1ddbc
addl $0x24, %esi
leaq 0x2c7f(%rip), %rdi      # 0xed61
movl $0x4, %edx
callq 0x6d8a
movl $0x1000, %edi           # imm = 0x1000
addl 0x11cc5(%rip), %edi     # 0x1ddbc
callq 0x7490
testl %eax, %eax
je 0xc13d
movl $0x3000, %edi           # imm = 0x3000
addl 0x11cb1(%rip), %edi     # 0x1ddbc
callq 0x91d8
testl %eax, %eax
je 0xc13d
callq 0x965c
testl %eax, %eax
je 0xc13d
movl $0x2000, %edi           # imm = 0x2000
addl 0x11c94(%rip), %edi     # 0x1ddbc
callq 0x9c3c
xorl %ebx, %ebx
testl %eax, %eax
setne %bl
jmp 0xc13d
callq 0x1b8f
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq