// File: /workspace/github_cpp_makefile_star2_O2/hyp1231[P]FMSS/generate_disk.cpp
// Function: main
int main() {
    ofstream ofile("./diskdata");				// create a new file

    // super block
    short basic_size = 1024;					// basic size of a block
    ofile.write((char*)&basic_size, sizeof(basic_size));

    char tmp = 0;

    // inode number of '/'
    ofile.write((char*)&tmp, sizeof(tmp));

    // inode bitmap[0] = 1
    tmp = 1;
    ofile.write((char*)&tmp, sizeof(tmp));
    tmp = 0;
    for(int i = 0; i < 9; ++i) {
    	ofile.write((char*)&tmp, sizeof(tmp));
    }

    // data block bitmap[0] = 1
    tmp = 1;
    ofile.write((char*)&tmp, sizeof(tmp));
    tmp = 0;

    // rest of super block
    for(int i = 0; i < 1024 - 2 - 1 - 10 - 1; ++i) {
	    ofile.write((char*)&tmp, sizeof(tmp));	// fill the file with '\0'
	}

	// first inode
	short num = 1;
	ofile.write((char*)&num, sizeof(num));
	tmp = '/';
	ofile.write((char*)&tmp, sizeof(tmp));
	tmp = 0;
	for(int i = 0; i < 7; ++i) {
		ofile.write((char*)&tmp, sizeof(tmp));
	}
	
	// rest of inode table
	for(int i = 0; i < 5 * 1024 - 10; ++i) {
		ofile.write((char*)&tmp, sizeof(tmp));
	}

	// first data block
	tmp = '.';
	ofile.write((char*)&tmp, sizeof(tmp));
	tmp = 0;
	for(int i = 0; i < 7; ++i) {
		ofile.write((char*)&tmp, sizeof(tmp));
	}

	ofile.write((char*)&num, sizeof(num));

	for(int i = 0; i < 2; ++i) {
		ofile.write((char*)&tmp, sizeof(tmp));
	}
	tmp = '.';
	for(int i = 0; i < 2; ++i) {
		ofile.write((char*)&tmp, sizeof(tmp));
	}
	tmp = 0;
	for(int i = 0; i < 6; ++i) {
		ofile.write((char*)&tmp, sizeof(tmp));
	}

	ofile.write((char*)&num, sizeof(num));

	// rest of data block
	for(int i = 0; i < 1024 - 12 - 10 + (1024 - 7) * 1024; ++i) {
		ofile.write((char*)&tmp, sizeof(tmp));
	}

	ofile.close();

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
leaq 0xe24(%rip), %rsi       # 0x2004
leaq 0x8(%rsp), %rbx
pushq $0x10
popq %rdx
movq %rbx, %rdi
callq 0x1040
leaq 0x6(%rsp), %rsi
movw $0x400, (%rsi)          # imm = 0x400
pushq $0x2
popq %rdx
movq %rbx, %rdi
callq 0x1050
leaq 0x3(%rsp), %rsi
movb $0x0, (%rsi)
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x1050
leaq 0x3(%rsp), %rsi
movb $0x1, (%rsi)
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x1050
leaq 0x3(%rsp), %rbx
movb $0x0, (%rbx)
pushq $0x9
popq %rbp
leaq 0x8(%rsp), %r14
pushq $0x1
popq %r15
subl $0x1, %ebp
jb 0x1258
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1050
jmp 0x1243
leaq 0x3(%rsp), %rsi
movb $0x1, (%rsi)
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x1050
leaq 0x3(%rsp), %rbx
movb $0x0, (%rbx)
movl $0x3f2, %ebp            # imm = 0x3F2
leaq 0x8(%rsp), %r14
pushq $0x1
popq %r15
subl $0x1, %ebp
jb 0x1298
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1050
jmp 0x1283
leaq 0x4(%rsp), %rsi
movw $0x1, (%rsi)
leaq 0x8(%rsp), %rdi
pushq $0x2
popq %rdx
callq 0x1050
leaq 0x3(%rsp), %rsi
movb $0x2f, (%rsi)
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x1050
leaq 0x3(%rsp), %rbx
movb $0x0, (%rbx)
pushq $0x7
popq %rbp
leaq 0x8(%rsp), %r14
pushq $0x1
popq %r15
subl $0x1, %ebp
jb 0x12ed
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1050
jmp 0x12d8
movl $0x13f6, %ebp           # imm = 0x13F6
leaq 0x8(%rsp), %rbx
leaq 0x3(%rsp), %r14
pushq $0x1
popq %r15
subl $0x1, %ebp
jb 0x1315
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1050
jmp 0x1300
leaq 0x3(%rsp), %rsi
movb $0x2e, (%rsi)
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x1050
leaq 0x3(%rsp), %rbx
movb $0x0, (%rbx)
pushq $0x7
popq %rbp
leaq 0x8(%rsp), %r14
pushq $0x1
popq %r15
subl $0x1, %ebp
jb 0x1353
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1050
jmp 0x133e
leaq 0x8(%rsp), %rdi
leaq 0x4(%rsp), %rsi
pushq $0x2
popq %rdx
callq 0x1050
pushq $0x2
popq %rbp
leaq 0x8(%rsp), %rbx
leaq 0x3(%rsp), %r14
pushq $0x1
popq %r15
subl $0x1, %ebp
jb 0x138b
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1050
jmp 0x1376
leaq 0x3(%rsp), %rbx
movb $0x2e, (%rbx)
pushq $0x2
popq %rbp
leaq 0x8(%rsp), %r14
pushq $0x1
popq %r15
subl $0x1, %ebp
jb 0x13b4
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1050
jmp 0x139f
leaq 0x3(%rsp), %rbx
movb $0x0, (%rbx)
pushq $0x6
popq %rbp
leaq 0x8(%rsp), %r14
pushq $0x1
popq %r15
subl $0x1, %ebp
jb 0x13dd
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1050
jmp 0x13c8
leaq 0x8(%rsp), %rdi
leaq 0x4(%rsp), %rsi
pushq $0x2
popq %rdx
callq 0x1050
movl $0xfe7ea, %ebp          # imm = 0xFE7EA
leaq 0x8(%rsp), %rbx
leaq 0x3(%rsp), %r14
pushq $0x1
popq %r15
subl $0x1, %ebp
jb 0x1417
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1050
jmp 0x1402
leaq 0x8(%rsp), %rdi
callq 0x1060
leaq 0x8(%rsp), %rdi
callq 0x1070
xorl %eax, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1451
jmp 0x1451
jmp 0x1451
jmp 0x1451
jmp 0x1451
jmp 0x1451
jmp 0x1451
jmp 0x1451
jmp 0x1451
jmp 0x1451
jmp 0x1451
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x1070
movq %rbx, %rdi
callq 0x1090