// File: /workspace/github_c_makefile_star2_O3/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 %r14
pushq %rbx
cmpl $0xffffd001, %edi       # imm = 0xFFFFD001
jae 0xb54c
movl %edx, %ebx
movl %esi, %r14d
movl %edi, 0x129f5(%rip)     # 0x1ddbc
movl $0x3000, %ebp           # imm = 0x3000
movl $0x3000, %esi           # imm = 0x3000
callq 0x6caf
cmpl $0x1, %r14d
movl %r14d, %eax
adcl $0x0, %eax
testl %r14d, %r14d
movl 0x129d3(%rip), %edi     # 0x1ddbc
cmovel %edi, %ebx
movl %eax, 0x129ce(%rip)     # 0x1ddc0
movl %ebx, 0x129cc(%rip)     # 0x1ddc4
leal 0xc(%rdi), %esi
movl $0x4, %edx
callq 0x6f54
movl 0x129b1(%rip), %edi     # 0x1ddbc
addl $0x4, %edi
xorl %ebx, %ebx
xorl %esi, %esi
movl $0x4, %edx
callq 0x6f54
movl 0x1299a(%rip), %edi     # 0x1ddbc
addl $0x8, %edi
xorl %esi, %esi
movl $0x4, %edx
callq 0x6f54
movl 0x12985(%rip), %esi     # 0x1ddbc
addl $0xc, %esi
leaq 0x390e(%rip), %rdi      # 0xed4f
movl $0x4, %edx
callq 0x6b71
movl 0x1296b(%rip), %edi     # 0x1ddbc
addl $0x10, %edi
movl $0x4000, %esi           # imm = 0x4000
movl $0x4, %edx
callq 0x6f54
movl 0x12953(%rip), %edi     # 0x1ddbc
addl $0x14, %edi
xorl %esi, %esi
movl $0x4, %edx
callq 0x6f54
movl 0x1293e(%rip), %edi     # 0x1ddbc
addl $0x18, %edi
xorl %esi, %esi
movl $0x4, %edx
callq 0x6f54
movl 0x12929(%rip), %edi     # 0x1ddbc
addl $0x18, %edi
movl $0xffff8170, %esi       # imm = 0xFFFF8170
movl $0x4, %edx
callq 0x6f54
movl 0x12911(%rip), %esi     # 0x1ddbc
leal 0x1c(%rsi), %edi
addl $0x20, %esi
movl $0x4, %edx
callq 0x6f54
movl 0x128fb(%rip), %esi     # 0x1ddbc
leal 0x20(%rsi), %edi
addl $0x24, %esi
movl $0x4, %edx
callq 0x6f54
movl 0x128e5(%rip), %esi     # 0x1ddbc
addl $0x20, %esi
leaq 0x3873(%rip), %rdi      # 0xed54
movl $0x4, %edx
callq 0x6b71
movl 0x128cb(%rip), %esi     # 0x1ddbc
addl $0x24, %esi
leaq 0x385e(%rip), %rdi      # 0xed59
movl $0x4, %edx
callq 0x6b71
movl $0x1000, %edi           # imm = 0x1000
addl 0x128ac(%rip), %edi     # 0x1ddbc
callq 0x7270
testl %eax, %eax
je 0xb553
addl 0x1289d(%rip), %ebp     # 0x1ddbc
movl %ebp, %edi
callq 0x89f4
testl %eax, %eax
je 0xb553
callq 0x8e78
testl %eax, %eax
je 0xb553
movl $0x2000, %edi           # imm = 0x2000
addl 0x1287e(%rip), %edi     # 0x1ddbc
callq 0x93e8
xorl %ebx, %ebx
testl %eax, %eax
setne %bl
jmp 0xb553
callq 0x1b72
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq