// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subl -0x8(%rbp), %eax
cmpl $0x2fff, %eax           # imm = 0x2FFF
jae 0xec14
movq 0x63f9(%rip), %rax      # 0x14ff0
movq (%rax), %rdi
leaq 0x399d(%rip), %rsi      # 0x1259e
movb $0x0, %al
callq 0x10d0
movl $0x0, -0x4(%rbp)
jmp 0xee00
movl -0x8(%rbp), %eax
movl %eax, 0x1125f(%rip)     # 0x1fe7c
movl 0x11259(%rip), %edi     # 0x1fe7c
movl $0x3000, %esi           # imm = 0x3000
callq 0x7c60
cmpl $0x0, -0xc(%rbp)
jne 0xec4e
movl $0x1, 0x11243(%rip)     # 0x1fe80
movl 0x11239(%rip), %eax     # 0x1fe7c
addl $0x0, %eax
movl %eax, 0x11238(%rip)     # 0x1fe84
jmp 0xec60
movl -0xc(%rbp), %eax
movl %eax, 0x11229(%rip)     # 0x1fe80
movl -0x10(%rbp), %eax
movl %eax, 0x11224(%rip)     # 0x1fe84
movl 0x11216(%rip), %edi     # 0x1fe7c
addl $0x0, %edi
movl 0x1120d(%rip), %esi     # 0x1fe7c
addl $0xc, %esi
movl $0x4, %edx
callq 0x8070
movl 0x111fa(%rip), %edi     # 0x1fe7c
addl $0x4, %edi
xorl %esi, %esi
movl $0x4, %edx
callq 0x8070
movl 0x111e5(%rip), %edi     # 0x1fe7c
addl $0x8, %edi
xorl %esi, %esi
movl $0x4, %edx
callq 0x8070
movl 0x111d0(%rip), %esi     # 0x1fe7c
addl $0xc, %esi
leaq 0x4169(%rip), %rdi      # 0x12e1f
movl $0x4, %edx
callq 0x7ad0
movl 0x111b6(%rip), %edi     # 0x1fe7c
addl $0x10, %edi
movl $0x4000, %esi           # imm = 0x4000
movl $0x4, %edx
callq 0x8070
movl 0x1119e(%rip), %edi     # 0x1fe7c
addl $0x14, %edi
xorl %esi, %esi
movl $0x4, %edx
callq 0x8070
movl 0x11189(%rip), %edi     # 0x1fe7c
addl $0x18, %edi
xorl %esi, %esi
movl $0x4, %edx
callq 0x8070
movl 0x11174(%rip), %edi     # 0x1fe7c
addl $0x18, %edi
movl $0xffff8170, %esi       # imm = 0xFFFF8170
movl $0x4, %edx
callq 0x8070
movl 0x1115c(%rip), %edi     # 0x1fe7c
addl $0x1c, %edi
movl 0x11153(%rip), %esi     # 0x1fe7c
addl $0x20, %esi
movl $0x4, %edx
callq 0x8070
movl 0x11140(%rip), %edi     # 0x1fe7c
addl $0x1c, %edi
addl $0x4, %edi
movl 0x11134(%rip), %esi     # 0x1fe7c
addl $0x24, %esi
movl $0x4, %edx
callq 0x8070
movl 0x11121(%rip), %esi     # 0x1fe7c
addl $0x20, %esi
leaq 0x40bf(%rip), %rdi      # 0x12e24
movl $0x4, %edx
callq 0x7ad0
movl 0x11107(%rip), %esi     # 0x1fe7c
addl $0x24, %esi
leaq 0x40aa(%rip), %rdi      # 0x12e29
movl $0x4, %edx
callq 0x7ad0
movl 0x110ed(%rip), %edi     # 0x1fe7c
addl $0x1000, %edi           # imm = 0x1000
callq 0x8400
cmpl $0x0, %eax
jne 0xeda8
movl $0x0, -0x4(%rbp)
jmp 0xee00
movl 0x110ce(%rip), %edi     # 0x1fe7c
addl $0x3000, %edi           # imm = 0x3000
callq 0xab80
cmpl $0x0, %eax
jne 0xedc7
movl $0x0, -0x4(%rbp)
jmp 0xee00
callq 0xb320
cmpl $0x0, %eax
jne 0xedda
movl $0x0, -0x4(%rbp)
jmp 0xee00
movl 0x1109c(%rip), %edi     # 0x1fe7c
addl $0x2000, %edi           # imm = 0x2000
callq 0xba60
cmpl $0x0, %eax
jne 0xedf9
movl $0x0, -0x4(%rbp)
jmp 0xee00
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)