LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: fill_last_frag
static FRESULT fill_last_frag (
	FFOBJID* obj,	/* Pointer to the corresponding object */
	DWORD lcl,		/* Last cluster of the fragment */
	DWORD term		/* Value to set the last FAT entry */
)
{
	FRESULT res;


	while (obj->n_frag > 0) {	/* Create the chain of last fragment */
		res = put_fat(obj->fs, lcl - obj->n_frag + 1, (obj->n_frag > 1) ? lcl - obj->n_frag + 2 : term);
		if (res != FR_OK) return res;
		obj->n_frag--;
	}
	return FR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl 0x1c(%rdi), %eax
xorl %ebx, %ebx
testl %eax, %eax
je 0x70b1
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
movq (%r15), %rdi
movl %r14d, %edx
subl %eax, %edx
leal 0x1(%rdx), %esi
addl $0x2, %edx
cmpl $0x1, %eax
cmovel %ebp, %edx
callq 0xb9ca
testl %eax, %eax
jne 0x70af
movl 0x1c(%r15), %eax
decl %eax
movl %eax, 0x1c(%r15)
jne 0x7084
jmp 0x70b1
movl %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: load_obj_xdir
static FRESULT load_obj_xdir (
	DIR* dp,			/* Blank directory object to be used to access containing direcotry */
	const FFOBJID* obj	/* Object with its containing directory information */
)
{
	FRESULT res;

	/* Open object containing directory */
	dp->obj.fs = obj->fs;
	dp->obj.sclust = obj->c_scl;
	dp->obj.stat = (BYTE)obj->c_size;
	dp->obj.objsize = obj->c_size & 0xFFFFFF00;
	dp->obj.n_frag = 0;
	dp->blk_ofs = obj->c_ofs;

	res = dir_sdi(dp, dp->blk_ofs);	/* Goto object's entry block */
	if (res == FR_OK) {
		res = load_xdir(dp);		/* Load the object's entry block */
	}
	return res;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rsi), %rax
movq %rax, (%rdi)
movl 0x20(%rsi), %eax
movl %eax, 0xc(%rdi)
movl 0x24(%rsi), %eax
movb %al, 0xb(%rdi)
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
movq %rax, 0x10(%rdi)
movl $0x0, 0x1c(%rdi)
movl 0x28(%rsi), %esi
movl %esi, 0x54(%rdi)
callq 0x7545
testl %eax, %eax
je 0x70f5
popq %rbx
retq
movq %rbx, %rdi
popq %rbx
jmp 0xbc3b
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: sync_fs
static FRESULT sync_fs (	/* Returns FR_OK or FR_DISK_ERR */
	FATFS* fs		/* Filesystem object */
)
{
	FRESULT res;


	res = sync_window(fs);
	if (res == FR_OK) {
		if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) {	/* FAT32: Update FSInfo sector if needed */
			/* Create FSInfo structure */
			mem_set(fs->win, 0, sizeof fs->win);
			st_word(fs->win + BS_55AA, 0xAA55);					/* Boot signature */
			st_dword(fs->win + FSI_LeadSig, 0x41615252);		/* Leading signature */
			st_dword(fs->win + FSI_StrucSig, 0x61417272);		/* Structure signature */
			st_dword(fs->win + FSI_Free_Count, fs->free_clst);	/* Number of free clusters */
			st_dword(fs->win + FSI_Nxt_Free, fs->last_clst);	/* Last allocated culuster */
			fs->winsect = fs->volbase + 1;						/* Write it into the FSInfo sector (Next to VBR) */
			disk_write(fs->pdrv, fs->win, fs->winsect, 1);
			fs->fsi_flag = 0;
		}
		/* Make sure that no pending write process in the lower layer */
		if (disk_ioctl(fs->pdrv, CTRL_SYNC, 0) != RES_OK) res = FR_DISK_ERR;
	}

	return res;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0xbbd2
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
jne 0x7192
cmpb $0x3, (%rbx)
jne 0x717c
cmpb $0x1, 0x4(%rbx)
jne 0x717c
leaq 0x60(%rbx), %r14
movl $0x200, %edx            # imm = 0x200
movq %r14, %rdi
xorl %esi, %esi
callq 0x2120
movw $0xaa55, 0x25e(%rbx)    # imm = 0xAA55
movl $0x41615252, 0x60(%rbx) # imm = 0x41615252
movl $0x61417272, 0x244(%rbx) # imm = 0x61417272
movq 0x20(%rbx), %rax
movq 0x30(%rbx), %rdx
rolq $0x20, %rax
movq %rax, 0x248(%rbx)
incq %rdx
movq %rdx, 0x58(%rbx)
movzbl 0x1(%rbx), %edi
movq %r14, %rsi
movl $0x1, %ecx
callq 0x2d47
movb $0x0, 0x4(%rbx)
movzbl 0x1(%rbx), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2dcc
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
setne %al
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: f_findnext
FRESULT f_findnext (
	DIR* dp,		/* Pointer to the open directory object */
	FILINFO* fno	/* Pointer to the file information structure */
)
{
	FRESULT res;


	for (;;) {
		res = f_readdir(dp, fno);		/* Get a directory item */
		if (res != FR_OK || !fno || !fno->fname[0]) break;	/* Terminate if any error or end of directory */
		if (pattern_match(dp->pat, fno->fname, 0, FIND_RECURS)) break;		/* Test for the file name */
#if FF_USE_LFN && FF_USE_FIND == 2
		if (pattern_match(dp->pat, fno->altname, 0, FIND_RECURS)) break;	/* Test for alternative name if exist */
#endif
	}
	return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1a(%rsi), %r15
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7676
movl %eax, %ebp
testq %rbx, %rbx
je 0x7df1
testl %ebp, %ebp
jne 0x7df1
cmpb $0x0, (%r15)
je 0x7df1
movq 0x58(%r14), %rdi
movq %r15, %rsi
xorl %edx, %edx
movl $0x4, %ecx
callq 0x7dfe
testl %eax, %eax
je 0x7dbe
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: f_findfirst
FRESULT f_findfirst (
	DIR* dp,				/* Pointer to the blank directory object */
	FILINFO* fno,			/* Pointer to the file information structure */
	const TCHAR* path,		/* Pointer to the directory to open */
	const TCHAR* pattern	/* Pointer to the matching pattern */
)
{
	FRESULT res;


	dp->pat = pattern;		/* Save pointer to pattern string */
	res = f_opendir(dp, path);		/* Open the target directory */
	if (res == FR_OK) {
		res = f_findnext(dp, fno);	/* Find the first item */
	}
	return res;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rcx, 0x58(%rdi)
movq %rdx, %rsi
callq 0x743b
testl %eax, %eax
je 0x7f8c
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x7dad
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: f_stat
FRESULT f_stat (
	const TCHAR* path,	/* Pointer to the file path */
	FILINFO* fno		/* Pointer to file information to return */
)
{
	FRESULT res;
	DIR dj;
	DEF_NAMBUF


	/* Get logical drive */
	res = mount_volume(&path, &dj.obj.fs, 0);
	if (res == FR_OK) {
		INIT_NAMBUF(dj.obj.fs);
		res = follow_path(&dj, path);	/* Follow the file path */
		if (res == FR_OK) {				/* Follow completed */
			if (dj.fn[NSFLAG] & NS_NONAME) {	/* It is origin directory */
				res = FR_INVALID_NAME;
			} else {							/* Found an object */
				if (fno) get_fileinfo(&dj, fno);
			}
		}
		FREE_NAMBUF();
	}

	LEAVE_FF(dj.obj.fs, res);
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x4d8, %rsp            # imm = 0x4D8
movq %rsi, %rbx
leaq 0x8(%rsp), %rax
movq %rdi, (%rax)
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
xorl %edx, %edx
callq 0x4c82
testl %eax, %eax
jne 0x7ff0
leaq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0x70(%rsp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x270(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq 0x8(%rsp), %rsi
callq 0x5747
testl %eax, %eax
je 0x7ffe
movl %eax, %ebp
movl %ebp, %eax
addq $0x4d8, %rsp            # imm = 0x4D8
popq %rbx
popq %rbp
retq
cmpb $0x0, 0x63(%rsp)
js 0x801b
xorl %ebp, %ebp
testq %rbx, %rbx
je 0x7ff2
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x7915
jmp 0x7ff2
movl $0x6, %ebp
jmp 0x7ff2
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: dir_remove
static FRESULT dir_remove (	/* FR_OK:Succeeded, FR_DISK_ERR:A disk error */
	DIR* dp					/* Directory object pointing the entry to be removed */
)
{
	FRESULT res;
	FATFS *fs = dp->obj.fs;
#if FF_USE_LFN		/* LFN configuration */
	DWORD last = dp->dptr;

	res = (dp->blk_ofs == 0xFFFFFFFF) ? FR_OK : dir_sdi(dp, dp->blk_ofs);	/* Goto top of the entry block if LFN is exist */
	if (res == FR_OK) {
		do {
			res = move_window(fs, dp->sect);
			if (res != FR_OK) break;
			if (FF_FS_EXFAT && fs->fs_type == FS_EXFAT) {	/* On the exFAT volume */
				dp->dir[XDIR_Type] &= 0x7F;	/* Clear the entry InUse flag. */
			} else {									/* On the FAT/FAT32 volume */
				dp->dir[DIR_Name] = DDEM;	/* Mark the entry 'deleted'. */
			}
			fs->wflag = 1;
			if (dp->dptr >= last) break;	/* If reached last entry then all entries of the object has been deleted. */
			res = dir_next(dp, 0);	/* Next entry */
		} while (res == FR_OK);
		if (res == FR_NO_FILE) res = FR_INT_ERR;
	}
#else			/* Non LFN configuration */

	res = move_window(fs, dp->sect);
	if (res == FR_OK) {
		dp->dir[DIR_Name] = DDEM;	/* Mark the entry 'deleted'.*/
		fs->wflag = 1;
	}
#endif

	return res;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %r14
movl 0x30(%rdi), %ebp
movl 0x54(%rdi), %esi
cmpl $-0x1, %esi
je 0x84b9
movq %rbx, %rdi
callq 0x7545
movl %eax, %ecx
jmp 0x84bb
xorl %ecx, %ecx
testl %ecx, %ecx
jne 0x850e
jmp 0x84ef
cmpb $0x4, (%r14)
jne 0x84d0
movq 0x40(%rbx), %rax
andb $0x7f, (%rax)
jmp 0x84d7
movq 0x40(%rbx), %rax
movb $-0x1b, (%rax)
movb $0x1, 0x3(%r14)
cmpl %ebp, 0x30(%rbx)
jae 0x8501
movq %rbx, %rdi
xorl %esi, %esi
callq 0x7c47
testl %eax, %eax
jne 0x8503
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x6314
testl %eax, %eax
je 0x84c1
jmp 0x8503
xorl %eax, %eax
cmpl $0x4, %eax
movl $0x2, %ecx
cmovnel %eax, %ecx
movl %ecx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: f_chmod
FRESULT f_chmod (
	const TCHAR* path,	/* Pointer to the file path */
	BYTE attr,			/* Attribute bits */
	BYTE mask			/* Attribute mask to change */
)
{
	FRESULT res;
	DIR dj;
	FATFS *fs;
	DEF_NAMBUF


	res = mount_volume(&path, &fs, FA_WRITE);	/* Get logical drive */
	if (res == FR_OK) {
		dj.obj.fs = fs;
		INIT_NAMBUF(fs);
		res = follow_path(&dj, path);	/* Follow the file path */
		if (res == FR_OK && (dj.fn[NSFLAG] & (NS_DOT | NS_NONAME))) res = FR_INVALID_NAME;	/* Check object validity */
		if (res == FR_OK) {
			mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC;	/* Valid attribute mask */
#if FF_FS_EXFAT
			if (fs->fs_type == FS_EXFAT) {
				fs->dirbuf[XDIR_Attr] = (attr & mask) | (fs->dirbuf[XDIR_Attr] & (BYTE)~mask);	/* Apply attribute change */
				res = store_xdir(&dj);
			} else
#endif
			{
				dj.dir[DIR_Attr] = (attr & mask) | (dj.dir[DIR_Attr] & (BYTE)~mask);	/* Apply attribute change */
				fs->wflag = 1;
			}
			if (res == FR_OK) {
				res = sync_fs(fs);
			}
		}
		FREE_NAMBUF();
	}

	LEAVE_FF(fs, res);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x4d8, %rsp            # imm = 0x4D8
movl %edx, %ebp
movl %esi, %r14d
leaq 0x8(%rsp), %rax
movq %rdi, (%rax)
movq %rsp, %rsi
movq %rax, %rdi
movl $0x2, %edx
callq 0x4c82
testl %eax, %eax
jne 0x8c77
movq (%rsp), %rbx
leaq 0x10(%rsp), %r15
movq %rbx, (%r15)
leaq 0x70(%rsp), %rax
movq %rax, 0x10(%rbx)
leaq 0x270(%rsp), %rax
movq %rax, 0x18(%rbx)
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x5747
movl %eax, %ecx
xorl %edx, %edx
testb $-0x60, 0x53(%r15)
sete %sil
movl $0x6, %eax
cmovel %edx, %eax
testl %ecx, %ecx
sete %dl
cmovnel %ecx, %eax
andb %sil, %dl
cmpb $0x1, %dl
jne 0x8c77
andb $0x27, %bpl
andb %bpl, %r14b
cmpb $0x4, (%rbx)
jne 0x8c52
movq 0x18(%rbx), %rax
notb %bpl
andb 0x4(%rax), %bpl
orb %r14b, %bpl
movb %bpl, 0x4(%rax)
leaq 0x10(%rsp), %rdi
callq 0x60e7
jmp 0x8c6b
movq 0x50(%rsp), %rax
notb %bpl
andb 0xb(%rax), %bpl
orb %r14b, %bpl
movb %bpl, 0xb(%rax)
movb $0x1, 0x3(%rbx)
xorl %eax, %eax
testl %eax, %eax
jne 0x8c77
movq %rbx, %rdi
callq 0x70fe
addq $0x4d8, %rsp            # imm = 0x4D8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: f_utime
FRESULT f_utime (
	const TCHAR* path,	/* Pointer to the file/directory name */
	const FILINFO* fno	/* Pointer to the timestamp to be set */
)
{
	FRESULT res;
	DIR dj;
	FATFS *fs;
	DEF_NAMBUF


	res = mount_volume(&path, &fs, FA_WRITE);	/* Get logical drive */
	if (res == FR_OK) {
		dj.obj.fs = fs;
		INIT_NAMBUF(fs);
		res = follow_path(&dj, path);	/* Follow the file path */
		if (res == FR_OK && (dj.fn[NSFLAG] & (NS_DOT | NS_NONAME))) res = FR_INVALID_NAME;	/* Check object validity */
		if (res == FR_OK) {
#if FF_FS_EXFAT
			if (fs->fs_type == FS_EXFAT) {
				st_dword(fs->dirbuf + XDIR_ModTime, (DWORD)fno->fdate << 16 | fno->ftime);
				res = store_xdir(&dj);
			} else
#endif
			{
				st_dword(dj.dir + DIR_ModTime, (DWORD)fno->fdate << 16 | fno->ftime);
				fs->wflag = 1;
			}
			if (res == FR_OK) {
				res = sync_fs(fs);
			}
		}
		FREE_NAMBUF();
	}

	LEAVE_FF(fs, res);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x4d0, %rsp            # imm = 0x4D0
movq %rsi, %r14
leaq 0x8(%rsp), %rax
movq %rdi, (%rax)
movq %rsp, %rsi
movq %rax, %rdi
movl $0x2, %edx
callq 0x4c82
testl %eax, %eax
jne 0x8d5f
movq (%rsp), %rbx
leaq 0x10(%rsp), %r15
movq %rbx, (%r15)
leaq 0x70(%rsp), %rax
movq %rax, 0x10(%rbx)
leaq 0x270(%rsp), %rax
movq %rax, 0x18(%rbx)
movq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x5747
movl %eax, %ecx
xorl %edx, %edx
testb $-0x60, 0x53(%r15)
sete %sil
movl $0x6, %eax
cmovel %edx, %eax
testl %ecx, %ecx
sete %dl
cmovnel %ecx, %eax
andb %sil, %dl
cmpb $0x1, %dl
jne 0x8d5f
cmpb $0x4, (%rbx)
jne 0x8d32
movq 0x18(%rbx), %rcx
movzwl 0x8(%r14), %eax
movzwl 0xa(%r14), %edx
movb %dl, 0xc(%rcx)
movb %dh, 0xd(%rcx)
movb %al, 0xe(%rcx)
movb %ah, 0xf(%rcx)
leaq 0x10(%rsp), %rdi
callq 0x60e7
jmp 0x8d53
movq 0x50(%rsp), %rcx
movzwl 0x8(%r14), %eax
movzwl 0xa(%r14), %edx
movb %dl, 0x16(%rcx)
movb %dh, 0x17(%rcx)
movb %al, 0x18(%rcx)
movb %ah, 0x19(%rcx)
movb $0x1, 0x3(%rbx)
xorl %eax, %eax
testl %eax, %eax
jne 0x8d5f
movq %rbx, %rdi
callq 0x70fe
addq $0x4d0, %rsp            # imm = 0x4D0
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: test_gpt_header
static int test_gpt_header (	/* 0:Invalid, 1:Valid */
	const BYTE* gpth			/* Pointer to the GPT header */
)
{
	UINT i;
	DWORD bcc;


	if (mem_cmp(gpth + GPTH_Sign, "EFI PART" "\0\0\1\0" "\x5C\0\0", 16)) return 0;	/* Check sign, version (1.0) and length (92) */
	for (i = 0, bcc = 0xFFFFFFFF; i < 92; i++) {		/* Check header BCC */
		bcc = crc32(bcc, i - GPTH_Bcc < 4 ? 0 : gpth[i]);
	}
	if (~bcc != ld_dword(gpth + GPTH_Bcc)) return 0;
	if (ld_dword(gpth + GPTH_PteSize) != SZ_GPTE) return 0;	/* Table entry size (must be SZ_GPTE bytes) */
	if (ld_dword(gpth + GPTH_PtNum) > 128) return 0;	/* Table size (must be 128 entries or less) */

	return 1;
}

// Assembly:
xorl %eax, %eax
leaq 0x2759(%rip), %rcx      # 0xd4c0
movb (%rdi,%rax), %dl
movb (%rax,%rcx), %sil
cmpl $0xf, %eax
je 0xad7b
incq %rax
cmpb %sil, %dl
je 0xad67
xorl %eax, %eax
cmpb %sil, %dl
jne 0xadd6
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
andl $0x7c, %edx
cmpl $0x10, %edx
jne 0xad97
xorl %edx, %edx
jmp 0xad9a
movb (%rdi,%rax), %dl
movb $0x1, %sil
testb %dl, %sil
sete %r8b
xorb %cl, %r8b
movl %ecx, %r9d
shrl %r9d
movl %r9d, %ecx
xorl $0xedb88320, %ecx       # imm = 0xEDB88320
testb $0x1, %r8b
cmovnel %r9d, %ecx
addb %sil, %sil
jne 0xad9d
incq %rax
cmpq $0x5c, %rax
jne 0xad89
xorl 0x10(%rdi), %ecx
xorl %eax, %eax
cmpl $-0x1, %ecx
je 0xadd7
retq
cmpl $0x80, 0x54(%rdi)
jne 0xadd6
xorl %eax, %eax
cmpl $0x81, 0x50(%rdi)
setb %al
retq
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: f_fdisk
FRESULT f_fdisk (
	BYTE pdrv,			/* Physical drive number */
	const LBA_t ptbl[],	/* Pointer to the size table for each partitions */
	void* work			/* Pointer to the working buffer (null: use heap memory) */
)
{
	BYTE *buf = (BYTE*)work;
	DSTATUS stat;


	stat = disk_initialize(pdrv);
	if (stat & STA_NOINIT) return FR_NOT_READY;
	if (stat & STA_PROTECT) return FR_WRITE_PROTECTED;
#if FF_USE_LFN == 3
	if (!buf) buf = ff_memalloc(FF_MAX_SS);	/* Use heap memory for working buffer */
#endif
	if (!buf) return FR_NOT_ENOUGH_CORE;

	LEAVE_MKFS(create_partition(pdrv, ptbl, 0x07, buf));
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %ebp
callq 0x2c58
movl %eax, %ecx
movl $0x3, %eax
testb $0x1, %cl
jne 0xb5a3
movl $0xa, %eax
testb $0x4, %cl
jne 0xb5a3
testq %rbx, %rbx
je 0xb59e
movzbl %bpl, %edi
movq %r14, %rsi
movl $0x7, %edx
movq %rbx, %rcx
popq %rbx
popq %r14
popq %rbp
jmp 0xadf1
movl $0x11, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: check_fs
static UINT check_fs (	/* 0:FAT VBR, 1:exFAT VBR, 2:Not FAT and valid BS, 3:Not FAT and invalid BS, 4:Disk error */
	FATFS* fs,			/* Filesystem object */
	LBA_t sect			/* Sector to load and check if it is an FAT-VBR or not */
)
{
	WORD w, sign;
	BYTE b;


	fs->wflag = 0; fs->winsect = (LBA_t)0 - 1;		/* Invaidate window */
	if (move_window(fs, sect) != FR_OK) return 4;	/* Load the boot sector */
	sign = ld_word(fs->win + BS_55AA);
#if FF_FS_EXFAT
	if (sign == 0xAA55 && !mem_cmp(fs->win + BS_JmpBoot, "\xEB\x76\x90" "EXFAT   ", 11)) return 1;	/* It is an exFAT VBR */
#endif
	b = fs->win[BS_JmpBoot];
	if (b == 0xEB || b == 0xE9 || b == 0xE8) {	/* Valid JumpBoot code? (short jump, near jump or near call) */
		if (sign == 0xAA55 && !mem_cmp(fs->win + BS_FilSysType32, "FAT32   ", 8)) return 0;	/* It is an FAT32 VBR */
		/* FAT volumes formatted with early MS-DOS lack boot signature and FAT string, so that we need to identify the FAT VBR without them. */
		w = ld_word(fs->win + BPB_BytsPerSec);
		if ((w & (w - 1)) == 0 && w >= FF_MIN_SS && w <= FF_MAX_SS) {	/* Properness of sector size */
			b = fs->win[BPB_SecPerClus];
			if (b != 0 && (b & (b - 1)) == 0						/* Properness of cluster size */
			&& (fs->win[BPB_NumFATs] == 1 || fs->win[BPB_NumFATs] == 2)	/* Properness of number of FATs */
			&& ld_word(fs->win + BPB_RootEntCnt) != 0				/* Properness of root entry count */
			&& ld_word(fs->win + BPB_FATSz16) != 0) {				/* Properness of FAT size */
				return 0;	/* Sector can be presumed an FAT VBR */
			}
		}
	}
	return sign == 0xAA55 ? 2 : 3;	/* Not an FAT VBR (valid or invalid BS) */
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movb $0x0, 0x3(%rdi)
movq $-0x1, 0x58(%rdi)
callq 0x6314
movl %eax, %ecx
movl $0x4, %eax
testl %ecx, %ecx
jne 0xb68c
movzwl 0x25e(%rbx), %ecx
cmpl $0xaa55, %ecx           # imm = 0xAA55
jne 0xb608
xorl %eax, %eax
leaq 0x1efc(%rip), %rdx      # 0xd4e0
movb 0x60(%rbx,%rax), %sil
movb (%rax,%rdx), %dil
cmpl $0xa, %eax
je 0xb5fa
incq %rax
cmpb %dil, %sil
je 0xb5e4
movl $0x1, %eax
cmpb %dil, %sil
je 0xb68c
movzbl 0x60(%rbx), %eax
addl $0xffffff18, %eax       # imm = 0xFFFFFF18
movzwl %cx, %ecx
cmpl $0x3, %eax
ja 0xb67e
cmpl $0x2, %eax
je 0xb67e
cmpl $0xaa55, %ecx           # imm = 0xAA55
jne 0xb651
xorl %eax, %eax
leaq 0x1ed4(%rip), %rdx      # 0xd503
movb 0xb2(%rbx,%rax), %sil
movb (%rax,%rdx), %dil
cmpl $0x7, %eax
je 0xb648
incq %rax
cmpb %dil, %sil
je 0xb62f
cmpb %dil, %sil
jne 0xb651
xorl %eax, %eax
jmp 0xb68c
cmpw $0x200, 0x6b(%rbx)      # imm = 0x200
jne 0xb67e
movb 0x6d(%rbx), %al
leal -0x1(%rax), %edx
xorb %dl, %al
cmpb %dl, %al
jbe 0xb67e
movb 0x70(%rbx), %al
decb %al
cmpb $0x1, %al
ja 0xb67e
movb 0x71(%rbx), %al
orb 0x72(%rbx), %al
je 0xb67e
movb 0x76(%rbx), %al
orb 0x77(%rbx), %al
jne 0xb64d
xorl %eax, %eax
cmpl $0xaa55, %ecx           # imm = 0xAA55
sete %al
xorl $0x3, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: xname_sum
static WORD xname_sum (	/* Get check sum (to be used as hash) of the file name */
	const WCHAR* name	/* File name to be calculated */
)
{
	WCHAR chr;
	WORD sum = 0;


	while ((chr = *name++) != 0) {
		chr = (WCHAR)ff_wtoupper(chr);		/* File name needs to be up-case converted */
		sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + (chr & 0xFF);
		sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + (chr >> 8);
	}
	return sum;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movzwl (%rdi), %eax
xorl %ebp, %ebp
testw %ax, %ax
je 0xb9c3
movq %rdi, %rbx
addq $0x2, %rbx
movl $0xff, %r14d
movzwl %ax, %edi
callq 0xbe55
movzwl %bp, %ecx
movl %ecx, %edx
shll $0xf, %edx
shrl %ecx
orl %edx, %ecx
movl %eax, %edx
andl %r14d, %edx
addl %ecx, %edx
movl %edx, %ecx
shll $0xf, %ecx
shrl %edx
andl $0x7fff, %edx           # imm = 0x7FFF
shrl $0x8, %eax
andl %r14d, %eax
orl %ecx, %eax
movl %eax, %ebp
addl %edx, %ebp
movzwl (%rbx), %eax
addq $0x2, %rbx
testw %ax, %ax
jne 0xb983
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: change_bitmap
static FRESULT change_bitmap (
	FATFS* fs,	/* Filesystem object */
	DWORD clst,	/* Cluster number to change from */
	DWORD ncl,	/* Number of clusters to be changed */
	int bv		/* bit value to be set (0 or 1) */
)
{
	BYTE bm;
	UINT i;
	LBA_t sect;


	clst -= 2;	/* The first bit corresponds to cluster #2 */
	sect = fs->bitbase + clst / 8 / SS(fs);	/* Sector address */
	i = clst / 8 % SS(fs);					/* Byte offset in the sector */
	bm = 1 << (clst % 8);					/* Bit mask in the byte */
	for (;;) {
		if (move_window(fs, sect++) != FR_OK) return FR_DISK_ERR;
		do {
			do {
				if (bv == (int)((fs->win[i] & bm) != 0)) return FR_INT_ERR;	/* Is the bit expected value? */
				fs->win[i] ^= bm;	/* Flip the bit */
				fs->wflag = 1;
				if (--ncl == 0) return FR_OK;	/* All bits processed? */
			} while (bm <<= 1);		/* Next bit */
			bm = 1;
		} while (++i < SS(fs));		/* Next byte */
		i = 0;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebx
movl %edx, %ebp
movl %esi, %r12d
movq %rdi, %r14
addl $-0x2, %r12d
movl %r12d, %r15d
shrl $0xc, %r15d
addq 0x50(%rdi), %r15
movq %r15, %rsi
callq 0x6314
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
jne 0xbbc9
movl %r12d, %ecx
andb $0x7, %cl
shll %cl, %eax
shrl $0x3, %r12d
andl $0x1ff, %r12d           # imm = 0x1FF
incq %r15
movb 0x60(%r14,%r12), %cl
movzbl %cl, %edx
xorl %esi, %esi
testl %edx, %eax
setne %sil
cmpl %ebx, %esi
je 0xbbc0
xorb %al, %cl
movb %cl, 0x60(%r14,%r12)
movb $0x1, 0x3(%r14)
decl %ebp
je 0xbbc7
movzbl %al, %edx
leal (%rdx,%rdx), %eax
testb $0x7f, %dl
jne 0xbb67
incq %r12
movl $0x1, %eax
cmpq $0x200, %r12            # imm = 0x200
jne 0xbb62
movq %r14, %rdi
movq %r15, %rsi
callq 0x6314
movl %eax, %ecx
movl $0x1, %eax
movl $0x0, %r12d
testl %ecx, %ecx
je 0xbb5f
jmp 0xbbc9
movl $0x2, %eax
jmp 0xbbc9
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ff.c
// Function: sync_window
static FRESULT sync_window (	/* Returns FR_OK or FR_DISK_ERR */
	FATFS* fs			/* Filesystem object */
)
{
	FRESULT res = FR_OK;


	if (fs->wflag) {	/* Is the disk access window dirty? */
		if (disk_write(fs->pdrv, fs->win, fs->winsect, 1) == RES_OK) {	/* Write it back into the volume */
			fs->wflag = 0;	/* Clear window dirty flag */
			if (fs->winsect - fs->fatbase < fs->fsize) {	/* Is it in the 1st FAT? */
				if (fs->n_fats == 2) disk_write(fs->pdrv, fs->win, fs->winsect + fs->fsize, 1);	/* Reflect it to 2nd FAT if needed */
			}
		} else {
			res = FR_DISK_ERR;
		}
	}
	return res;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
cmpb $0x0, 0x3(%rdi)
je 0xbc32
movq %rdi, %rbx
movzbl 0x1(%rdi), %edi
leaq 0x60(%rbx), %r14
movq 0x58(%rbx), %rdx
movl $0x1, %ebp
movq %r14, %rsi
movl $0x1, %ecx
callq 0x2d47
testl %eax, %eax
jne 0xbc34
movb $0x0, 0x3(%rbx)
movq 0x58(%rbx), %rdx
movq %rdx, %rcx
subq 0x38(%rbx), %rcx
movl 0x2c(%rbx), %eax
cmpq %rax, %rcx
jae 0xbc32
cmpb $0x2, 0x2(%rbx)
jne 0xbc32
movzbl 0x1(%rbx), %edi
addq %rax, %rdx
movq %r14, %rsi
movl $0x1, %ecx
callq 0x2d47
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/ffunicode.c
// Function: ff_uni2oem
WCHAR ff_uni2oem (	/* Returns OEM code character, zero on error */
	DWORD	uni,	/* UTF-16 encoded character to be converted */
	WORD	cp		/* Code page for the conversion */
)
{
	WCHAR c = 0;
	const WCHAR *p = CVTBL(uc, FF_CODE_PAGE);


	if (uni < 0x80) {	/* ASCII? */
		c = (WCHAR)uni;

	} else {			/* Non-ASCII */
		if (uni < 0x10000 && cp == FF_CODE_PAGE) {	/* Is it in BMP and valid code page? */
			for (c = 0; c < 0x80 && uni != p[c]; c++) ;
			c = (c + 0x80) & 0xFF;
		}
	}

	return c;
}

// Assembly:
movl %edi, %eax
cmpl $0x7f, %edi
jbe 0xbe17
cmpl $0x10000, %eax          # imm = 0x10000
setae %cl
movzwl %si, %edx
cmpl $0x1b5, %edx            # imm = 0x1B5
setne %dl
orb %cl, %dl
jne 0xbe18
leaq 0x176e(%rip), %rdx      # 0xd560
xorl %ecx, %ecx
movzwl (%rdx), %esi
cmpl %eax, %esi
je 0xbe0f
incq %rcx
addq $0x2, %rdx
cmpq $0x80, %rcx
jne 0xbdf4
movw $0x80, %cx
movzbl %cl, %eax
xorl $0x80, %eax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/stickyPiston[P]ti-basic-compiler/src/main.c
// Function: openHelp
void openHelp(char *command) {
  puts("tic: TI-BASIC compiler");
  puts("Command line interface usage:");
  printf("%s <input file> <flags>\n", command);
  puts("\nAvailable flags:");
  puts(" -o: Specify the output file path");
  puts(" -i: Ignore whitespace characters, tabs and whitespaces will not be added to the final binary");
  puts(" -d: Enable disassembly mode");
  puts(" -n: Specify the name of the program when sent to the calculator");
  puts(" -h, --help: Show the help page");
  puts(" -l, --lang: Select a language, choices are: nl, en, se");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xad9(%rip), %rdi       # 0xf04c
callq 0xe070
leaq 0xae4(%rip), %rdi       # 0xf063
callq 0xe070
leaq 0xaf6(%rip), %rdi       # 0xf081
movq %rbx, %rsi
xorl %eax, %eax
callq 0xe0b0
leaq 0xafe(%rip), %rdi       # 0xf09a
callq 0xe070
leaq 0xb04(%rip), %rdi       # 0xf0ac
callq 0xe070
leaq 0xb1a(%rip), %rdi       # 0xf0ce
callq 0xe070
leaq 0xb6c(%rip), %rdi       # 0xf12c
callq 0xe070
leaq 0xb7d(%rip), %rdi       # 0xf149
callq 0xe070
leaq 0xbb2(%rip), %rdi       # 0xf18a
callq 0xe070
leaq 0xbc6(%rip), %rdi       # 0xf1aa
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xe070
nop
// File: /workspace/github_c_makefile_star2_O1/stickyPiston[P]ti-basic-compiler/src/tic.c
// Function: readFile
int readFile(char **out) {
  FILE *fp = fopen(inputFile, "r");
  if (fp == NULL) {
    fprintf(stderr, "Could not open %s\n", inputFile);
    abort();
  } 

  // Read all bytes from the source file
  fseek(fp, 0, SEEK_END);
  int filesize = ftell(fp);
  fseek(fp, 0, SEEK_SET);

  *out = malloc(filesize);
  fread(*out, filesize, 1, fp);

  fclose(fp);
  
  return filesize;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0xb5ec(%rip), %rax      # 0x19bf0
movq (%rax), %rdi
leaq 0xfd0(%rip), %rsi       # 0xf5de
callq 0xe130
testq %rax, %rax
je 0xe678
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xe110
movq %rbx, %rdi
callq 0xe0f0
movq %rax, %r15
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe110
movslq %r15d, %r15
movq %r15, %rdi
callq 0xe100
movq %rax, (%r14)
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
movq %rbx, %rcx
callq 0xe080
movq %rbx, %rdi
callq 0xe090
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0xe160
// File: /workspace/github_c_makefile_star2_O1/stickyPiston[P]ti-basic-compiler/src/tic.c
// Function: disassemble
void disassemble() {
  unsigned char *bytes = NULL;
  int filesize = readFile((char **)&bytes);

  for (int i = 74; i < filesize - 2; i++) {
    for (int j = 0; stringTable[j][lang] != NULL; j++) {
      if (bytes[i] == 0x5c || bytes[i] == 0x5d || bytes[i] == 0x5e || bytes[i] == 0x60 || bytes[i] == 0x61 || bytes[i] == 0xaa || bytes[i] == 0xef || bytes[i] == 0x62 || bytes[i] == 0x63 || bytes[i] == 0x7e || bytes[i] == 0xbb) {
        uint16_t twobytevalue = bytes[i] << 8;
        twobytevalue |= bytes[++i];
        if (functionTable[j].opcode == twobytevalue) {
          printf("%s", stringTable[j][lang]);
        }
      } else {
        if (functionTable[j].opcode == bytes[i]) {
          if (strcmp(stringTable[j][lang], "\n") != 0)
            printf("%s", stringTable[j][lang]);
        }
      }
    }
  }

  puts("");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq -0x38(%rbp), %rdi
movq $0x0, (%rdi)
callq 0xe5f0
movl %eax, -0x2c(%rbp)
cmpl $0x4d, %eax
jl 0xebde
addl $-0x2, -0x2c(%rbp)
movl $0x4a, %r15d
movq -0x38(%rbp), %r13
leaq 0x696b(%rip), %rbx      # 0x15470
leaq 0xb0dc(%rip), %rax      # 0x19be8
movl (%rax), %eax
movq (%rbx,%rax,8), %r12
testq %r12, %r12
je 0xebd1
xorl %r14d, %r14d
movslq %r15d, %rax
movzbl (%r13,%rax), %ecx
cmpl $0xa9, %ecx
jg 0xeb96
leal -0x5c(%rcx), %edx
cmpl $0x22, %edx
ja 0xebae
movabsq $0x4000000f7, %rsi      # imm = 0x4000000F7
btq %rdx, %rsi
jae 0xebae
shll $0x8, %ecx
movzbl 0x1(%r13,%rax), %edx
incq %rax
orl %ecx, %edx
leaq 0x4564(%rip), %rcx      # 0x130c0
movzwl (%r14,%rcx), %ecx
movl %eax, %r15d
cmpl %ecx, %edx
jne 0xeb79
leaq 0x26f1(%rip), %rdi      # 0x11260
movq %r12, %rsi
xorl %eax, %eax
callq 0xe0b0
leaq 0xb068(%rip), %rax      # 0x19be8
movl (%rax), %eax
leaq (%rbx,%rax,8), %rax
movq 0x18(%rax,%r14,2), %r12
addq $0xc, %r14
testq %r12, %r12
jne 0xeb1e
jmp 0xebd1
cmpl $0xaa, %ecx
je 0xeb47
cmpl $0xef, %ecx
je 0xeb47
cmpl $0xbb, %ecx
je 0xeb47
leaq 0x450b(%rip), %rax      # 0x130c0
cmpw %cx, (%r14,%rax)
jne 0xeb79
movq %r12, %rdi
leaq 0x2630(%rip), %rsi      # 0x111f6
callq 0xe0d0
testl %eax, %eax
jne 0xeb68
jmp 0xeb79
incl %r15d
cmpl -0x2c(%rbp), %r15d
jl 0xeb05
movl $0xa, %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe030
// File: /workspace/github_c_makefile_star2_O1/giometti[P]mastering_UNIX_programming/chapter_02/lseek.c
// Function: main
int main(void)
{
	char c;
	off_t pos;
	int ret;

	/* Check if the file is lseek()-able */
	ret = lseek(STDIN_FILENO, 0, SEEK_CUR);
	if (ret < 0) {
		perror("cannot lseek()");
		return -1;
	}

	/* Move the offset to position -16 (16 bytes from the end of
	 * the file).
	 */
	pos = lseek(STDIN_FILENO, -16, SEEK_END);
	if (pos < 0) {
		perror("cannot move to position -16");
		return -1;
	}
	
	/* Read and then print out the data */
	ret = read(STDIN_FILENO, &c, 1);
	if (ret == 1)
		printf("file@%ld=%c\n", pos, c);

	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
xorl %edi, %edi
xorl %esi, %esi
movl $0x1, %edx
callq 0x1040
testl %eax, %eax
js 0x11cf
xorl %ebx, %ebx
xorl %edi, %edi
movq $-0x10, %rsi
movl $0x2, %edx
callq 0x1040
testq %rax, %rax
js 0x11d8
movq %rax, %r14
leaq 0x7(%rsp), %rsi
movl $0x1, %edx
xorl %edi, %edi
callq 0x1050
cmpl $0x1, %eax
jne 0x11e9
movsbl 0x7(%rsp), %edx
leaq 0xe6e(%rip), %rdi       # 0x202f
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x1030
jmp 0x11e9
leaq 0xe2e(%rip), %rdi       # 0x2004
jmp 0x11df
leaq 0xe34(%rip), %rdi       # 0x2013
callq 0x1060
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_4/exercise_4_01/strindex.c
// Function: main
int main(void)
{
  char line[MAXLEN];
  char pattern[MAXLEN] = "example";

  get_line(line, MAXLEN);
  printf("%s\n", line);

  printf("Pattern found at index %d\n", strindex(line, pattern));

  return 0;
}

// Assembly:
pushq %rbx
subq $0x3f0, %rsp            # imm = 0x3F0
movq %rsp, %rbx
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x11b6
movq %rbx, %rdi
callq 0x1030
leaq 0xe7d(%rip), %rsi       # 0x2010
movq %rbx, %rdi
callq 0x120c
leaq 0x1256(%rip), %rdi      # 0x23f8
movl %eax, %esi
xorl %eax, %eax
callq 0x1050
xorl %eax, %eax
addq $0x3f0, %rsp            # imm = 0x3F0
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_4/exercise_4_01/strindex.c
// Function: get_line
int get_line(char line[], int lim)
{
  int i = 0, c;

  while (lim > 0 && (c = getchar()) != EOF && c != '\n')
  {
    line[i++] = c;
    --lim;
  }

  if (c == '\n')
  {
    line[i++] = c;
  }

  line[i] = '\0';

  return i;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
testl %esi, %esi
jle 0x11ee
movl %esi, %r15d
xorl %r14d, %r14d
callq 0x1060
cmpl $-0x1, %eax
je 0x11e6
cmpl $0xa, %eax
je 0x11e6
movb %al, (%rbx,%r14)
incq %r14
cmpq %r14, %r15
jne 0x11c8
movl %r15d, %r14d
cmpl $0xa, %eax
sete %al
jmp 0x11f1
xorl %r14d, %r14d
testb $0x1, %al
je 0x11ff
movl %r14d, %eax
incl %r14d
movb $0xa, (%rbx,%rax)
movslq %r14d, %rax
movb $0x0, (%rbx,%rax)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_4/exercise_4_01/strindex.c
// Function: strindex
int strindex(char source[], char pattern[])
{
  int i, j, k;

  printf("line len: %lu\n", strlen(source));

  for (i = strlen(source); i >= 0; --i)
  {
    for (j = i, k = 0; pattern[k] != '\0' && source[j] == pattern[k]; ++j, ++k)
      ;

    if (k > 0 && pattern[k] == '\0')
    {
      return i;
    }
  }

  return -1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
callq 0x1040
leaq 0x11f0(%rip), %rdi      # 0x2413
movq %rax, %rsi
xorl %eax, %eax
callq 0x1050
movq %r14, %rdi
callq 0x1040
movq %rax, %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
js 0x12a7
movb (%rbx), %dl
testb %dl, %dl
setne %sil
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq (%r14,%rcx), %rdi
testb %dl, %dl
je 0x1283
cmpb %dl, (%r14,%rcx)
setne %r8b
jne 0x1286
movl $0x1, %r10d
movb (%rbx,%r10), %r11b
testb %r11b, %r11b
setne %r9b
je 0x1289
leaq 0x1(%r10), %r15
cmpb %r11b, (%rdi,%r10)
movq %r15, %r10
je 0x1267
jmp 0x1289
movb $0x1, %r8b
movl %esi, %r9d
testb %r8b, %r8b
jne 0x1293
testb %r9b, %r9b
je 0x12a5
movq %rcx, %r8
decq %r8
decq %rdi
testl %ecx, %ecx
movq %r8, %rcx
jg 0x1253
jmp 0x12a7
movl %ecx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]libcperciva/tests/aws/main.c
// Function: main
int
main(int argc, char * argv[])
{
	const char * filename_bad = "/dev/null";
	const char * filename_good = "format.key";
	char * key_id;
	char * key_secret;

	WARNP_INIT;
	(void)argc; /* UNUSED */

	/* Generate a failure. */
	fprintf(stderr, "---- Trying to find AWS keys in %s\n", filename_bad);
	if (!aws_readkeys(filename_bad, &key_id, &key_secret)) {
		warn0("That should have failed!");
		goto err0;
	}

	/* Read key info from real file. */
	fprintf(stderr, "---- Trying to find AWS keys in %s\n", filename_good);
	if (aws_readkeys(filename_good, &key_id, &key_secret)) {
		warn0("aws_readkeys");
		goto err0;
	}

	/* Display key info. */
	fprintf(stderr, "id:\t%s\n", key_id);
	fprintf(stderr, "secret:\t%s\n", key_secret);

	/* Generate a header. */
	fprintf(stderr, "---- Generate a header\n");
	if (s3_headers(key_id, key_secret))
		goto err0;

	/* Clean up */
	free(key_id);
	free(key_secret);

	/* Success! */
	exit(0);

err0:
	/* Failure! */
	exit(1);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x1430
callq 0x2538
movq 0x6bc1(%rip), %r14      # 0x7ff8
movq (%r14), %rdi
leaq 0x3bd8(%rip), %rsi      # 0x5019
leaq 0x3bbc(%rip), %rbx      # 0x5004
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1130
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x15d0
testl %eax, %eax
je 0x1589
movq (%r14), %rdi
leaq 0x3ba5(%rip), %rsi      # 0x5019
leaq 0x3b93(%rip), %rbx      # 0x500e
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1130
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x15d0
testl %eax, %eax
jne 0x1592
movq (%r14), %rdi
movq 0x8(%rsp), %rdx
leaq 0x3bb7(%rip), %rsi      # 0x5063
xorl %eax, %eax
callq 0x1130
movq (%r14), %rdi
movq (%rsp), %rdx
leaq 0x3baa(%rip), %rsi      # 0x506b
xorl %eax, %eax
callq 0x1130
movq (%r14), %rcx
leaq 0x3ba5(%rip), %rdi      # 0x5077
movl $0x17, %esi
movl $0x1, %edx
callq 0x11d0
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
subq $0x8, %rsp
leaq 0x20(%rsp), %rax
leaq 0x28(%rsp), %r10
leaq 0x18(%rsp), %r11
leaq 0x3ba2(%rip), %rbx      # 0x50a6
leaq 0x3b84(%rip), %rdx      # 0x508f
leaq 0x3b81(%rip), %rcx      # 0x5093
leaq 0x3b81(%rip), %r8       # 0x509a
leaq 0x3b81(%rip), %r9       # 0x50a1
pushq %rax
pushq %r10
pushq %r11
pushq $0x4
pushq %rbx
callq 0x18b0
addq $0x30, %rsp
movl %eax, %ebx
testl %eax, %eax
jne 0x15b5
movq (%r14), %rdi
movq 0x10(%rsp), %rdx
leaq 0x3b79(%rip), %rsi      # 0x50bf
xorl %eax, %eax
callq 0x1130
movq 0x10(%rsp), %rdi
callq 0x1030
movq 0x20(%rsp), %rdi
callq 0x1030
movq 0x18(%rsp), %rdi
callq 0x1030
testl %ebx, %ebx
jne 0x15ab
movq 0x8(%rsp), %rdi
callq 0x1030
movq (%rsp), %rdi
callq 0x1030
xorl %edi, %edi
callq 0x11c0
leaq 0x3aad(%rip), %rdi      # 0x503d
jmp 0x1599
leaq 0x3abd(%rip), %rdi      # 0x5056
xorl %eax, %eax
callq 0x26d7
callq 0x1060
movl $0x0, (%rax)
movl $0x1, %edi
callq 0x11c0
leaq 0x3aef(%rip), %rdi      # 0x50ab
xorl %eax, %eax
callq 0x26d7
callq 0x1060
movl $0x0, (%rax)
jmp 0x156b
// File: /workspace/github_c_makefile_star2_O1/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_6/exercise_6_04/words_frequency.c
// Function: main
int main(void)
{
  struct tree_node *tree_root = NULL;
  char word[MAX_WORD_LEN];

  while (get_word(word, MAX_WORD_LEN) != EOF)
  {
    if (isalpha(word[0]))
    {
      tree_root = add_to_tree(tree_root, word);
    }
  }

  struct tree_node *tree_node_list[MAX_NR_OF_NODES] = {NULL};
  copy_tree_to_array(tree_node_list, tree_root);

  quick_sort((void **)tree_node_list, 0, nr_of_nodes - 1, (int (*)(void *, void *))tree_node_cmp);

  for (size_t i = 0; i < nr_of_nodes; ++i)
  {
    printf("%4d %s\n", tree_node_list[i]->count, tree_node_list[i]->word);
  }

  return EXIT_SUCCESS;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1fb0, %rsp           # imm = 0x1FB0
movq %rsp, %rdi
movl $0x64, %esi
callq 0x1294
xorl %ebx, %ebx
cmpl $-0x1, %eax
je 0x1216
callq 0x10b0
movq %rax, %r14
movq %rsp, %r15
movq (%r14), %rax
movsbq (%rsp), %rcx
testb $0x4, 0x1(%rax,%rcx,2)
je 0x1204
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1374
movq %rax, %rbx
movq %r15, %rdi
movl $0x64, %esi
callq 0x1294
cmpl $-0x1, %eax
jne 0x11e7
leaq 0x70(%rsp), %r14
movl $0x1f40, %edx           # imm = 0x1F40
movq %r14, %rdi
xorl %esi, %esi
callq 0x1060
movq %r14, %rdi
movq %rbx, %rsi
callq 0x13ee
movq 0x2e3c(%rip), %rdx      # 0x4078
decq %rdx
leaq 0x291(%rip), %rcx       # 0x14d7
movq %r14, %rdi
xorl %esi, %esi
callq 0x1435
cmpq $0x0, 0x2e20(%rip)      # 0x4078
je 0x1285
leaq 0xda3(%rip), %rbx       # 0x2004
xorl %r14d, %r14d
movq 0x70(%rsp,%r14,8), %rax
movl 0x8(%rax), %esi
movq (%rax), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1050
incq %r14
cmpq 0x2df5(%rip), %r14      # 0x4078
jb 0x1264
xorl %eax, %eax
addq $0x1fb0, %rsp           # imm = 0x1FB0
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_6/exercise_6_04/words_frequency.c
// Function: get_word
int get_word(char *word, int max_word_len)
{
  skip_blanks();

  int c = getc(stdin);
  size_t i = 0;

  if (c != EOF)
  {
    word[i++] = c;
  }

  if (!isalpha(c) && c != '_')
  {
    word[i] = '\0';
    return c;
  }

  while ((isalnum(c = getc(stdin)) || c == '_') && i < max_word_len)
  {
    word[i++] = c;
  }
  ungetc(c, stdin);
  word[i] = '\0';

  return word[0];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
callq 0x1510
movq 0x2d30(%rip), %r12      # 0x3fe0
movq (%r12), %rdi
callq 0x10a0
movl %eax, %r15d
cmpl $-0x1, %eax
je 0x12cc
movb %r15b, (%rbx)
movl $0x1, %r13d
jmp 0x12cf
xorl %r13d, %r13d
callq 0x10b0
movq %rax, %r14
cmpl $0x5f, %r15d
je 0x12f5
movq (%r14), %rax
movslq %r15d, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
jne 0x12f5
movb $0x0, (%rbx,%r13)
jmp 0x1362
movq (%r14), %r15
movq (%r12), %rdi
callq 0x10a0
movslq %eax, %rcx
testb $0x8, (%r15,%rcx,2)
sete %dl
cmpl $0x5f, %ecx
setne %cl
andb %dl, %cl
movslq %ebp, %r15
cmpq %r15, %r13
setae %dl
orb %cl, %dl
jne 0x134e
movb %al, (%rbx,%r13)
incq %r13
movq (%r14), %rbp
movq (%r12), %rdi
callq 0x10a0
movslq %eax, %rcx
testb $0x8, (%rbp,%rcx,2)
sete %dl
cmpl $0x5f, %ecx
setne %cl
testb %dl, %cl
jne 0x134e
cmpq %r15, %r13
jb 0x1321
movq (%r12), %rsi
movl %eax, %edi
callq 0x1090
movb $0x0, (%rbx,%r13)
movsbl (%rbx), %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_6/exercise_6_04/words_frequency.c
// Function: add_to_tree
struct tree_node *add_to_tree(struct tree_node *node_p, char *word)
{
  int cond;

  if (node_p == NULL)
  {
    node_p = (struct tree_node *)malloc(sizeof(struct tree_node));
    node_p->word = str_dup(word);
    node_p->count = 1;
    node_p->left = node_p->right = NULL;
  }
  else if ((cond = strcmp(word, node_p->word)) == 0)
  {
    node_p->count++;
  }
  else if (cond < 0)
  {
    node_p->left = add_to_tree(node_p->left, word);
  }
  else if (cond > 0)
  {
    node_p->right = add_to_tree(node_p->right, word);
  }

  return node_p;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
testq %rdi, %rdi
je 0x13a6
movq %rdi, %rbx
movq (%rdi), %rsi
movq %r14, %rdi
callq 0x1070
testl %eax, %eax
je 0x13ce
jns 0x13d3
movq 0x10(%rbx), %rdi
movq %r14, %rsi
callq 0x1374
movq %rax, 0x10(%rbx)
jmp 0x13e3
movl $0x20, %edi
callq 0x1080
movq %rax, %rbx
movq %r14, %rdi
callq 0x14eb
movq %rax, (%rbx)
movl $0x1, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
jmp 0x13e3
incl 0x8(%rbx)
jmp 0x13e3
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0x1374
movq %rax, 0x18(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_6/exercise_6_04/words_frequency.c
// Function: copy_tree_to_array
void copy_tree_to_array(struct tree_node *arr[], struct tree_node *tree_node_p)
{
  if (tree_node_p != NULL)
  {
    copy_tree_to_array(arr, tree_node_p->left);
    if (nr_of_nodes < MAX_NR_OF_NODES)
    {
      arr[nr_of_nodes++] = tree_node_p;
    }
    copy_tree_to_array(arr, tree_node_p->right);
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
testq %rbx, %rbx
je 0x142d
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0x13ee
movq 0x2c68(%rip), %rax      # 0x4078
cmpq $0x3e7, %rax            # imm = 0x3E7
ja 0x1427
leaq 0x1(%rax), %rcx
movq %rcx, 0x2c55(%rip)      # 0x4078
movq %rbx, (%r14,%rax,8)
movq 0x18(%rbx), %rbx
jmp 0x13f8
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_6/exercise_6_04/words_frequency.c
// Function: str_dup
char *str_dup(char *src)
{
  char *dest = (char *)malloc(strlen(src) + 1);
  if (dest != NULL)
  {
    strcpy(dest, src);
  }
  return dest;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x1040
leaq 0x1(%rax), %rdi
callq 0x1080
testq %rax, %rax
je 0x150e
movq %rax, %rdi
movq %rbx, %rsi
popq %rbx
jmp 0x1030
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_6/exercise_6_04/words_frequency.c
// Function: print_tree
void print_tree(struct tree_node *node_p)
{
  if (node_p != NULL)
  {
    print_tree(node_p->left);
    printf("%4d %s\n", node_p->count, node_p->word);
    print_tree(node_p->right);
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xa9d(%rip), %r14       # 0x2004
testq %rbx, %rbx
je 0x158b
movq 0x10(%rbx), %rdi
callq 0x1559
movl 0x8(%rbx), %esi
movq (%rbx), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x1050
movq 0x18(%rbx), %rbx
jmp 0x1567
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/ecc/bch.c
// Function: bch_generate
static bch_poly_t chunk_remainder(const struct bch_def *def,
				  const uint8_t *chunk, size_t len)
{
	bch_poly_t remainder = 0;
	int i;

	for (i = 0; i < len; i++) {
		int j;

		remainder ^= chunk[i] ^ 0xff;

		for (j = 0; j < 8; j++) {
			if (remainder & 1)
				remainder ^= def->generator;
			remainder >>= 1;
		}
	}

	return remainder;
}

// Assembly:
testq %rdx, %rdx
je 0x11d8
xorl %r8d, %r8d
xorl %eax, %eax
movzbl (%rsi,%r8), %r10d
xorq %rax, %r10
xorq $0xff, %r10
movl $0x8, %r9d
movq %r10, %rax
testb $0x1, %al
je 0x11c6
xorq 0x8(%rdi), %rax
shrq %rax
decl %r9d
jne 0x11be
incq %r8
cmpq %rdx, %r8
jne 0x11a6
jmp 0x11da
xorl %eax, %eax
cmpl $0x0, 0x14(%rdi)
jle 0x11fb
xorl %edx, %edx
movl %eax, %esi
notb %sil
movb %sil, (%rcx,%rdx)
shrq $0x8, %rax
incq %rdx
movslq 0x14(%rdi), %rsi
cmpq %rsi, %rdx
jl 0x11e2
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/ecc/bch.c
// Function: poly_eval
static gf13_elem_t poly_eval(const gf13_elem_t *s, gf13_elem_t x)
{
	int i;
	gf13_elem_t sum = 0;
	gf13_elem_t t = x;

	for (i = 0; i < MAX_POLY; i++) {
		const gf13_elem_t c = s[i];

		if (c)
			sum ^= gf13_mul(c, t);

		t = gf13_mul(t, x);
	}

	return sum;
}

// Assembly:
movl %esi, %eax
leaq 0x946(%rip), %rcx       # 0x2070
movzwl (%rcx,%rax,2), %edx
xorl %r8d, %r8d
leaq 0x4938(%rip), %r9       # 0x6070
xorl %eax, %eax
movzwl (%rdi,%r8,2), %r10d
movzwl %si, %esi
testq %r10, %r10
je 0x1770
movzwl (%rcx,%rsi,2), %r11d
addw (%rcx,%r10,2), %r11w
movzwl %r11w, %r10d
leal -0x1fff(%r10), %r11d
cmpl $0x1fff, %r10d          # imm = 0x1FFF
cmovbl %r10d, %r11d
movzwl %r11w, %r10d
xorw (%r9,%r10,2), %ax
movzwl (%rcx,%rsi,2), %esi
addw %dx, %si
movzwl %si, %esi
leal -0x1fff(%rsi), %r10d
cmpl $0x1fff, %esi           # imm = 0x1FFF
cmovbl %esi, %r10d
movzwl %r10w, %esi
movzwl (%r9,%rsi,2), %esi
incq %r8
cmpq $0x10, %r8
jne 0x173a
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/ecc/bch.c
// Function: poly_add
static void poly_add(gf13_elem_t *dst, const gf13_elem_t *src,
		     gf13_elem_t c, int shift)
{
	int i;

	for (i = 0; i < MAX_POLY; i++) {
		int p = i + shift;
		gf13_elem_t v = src[i];

		if (p < 0 || p >= MAX_POLY)
			continue;
		if (!v)
			continue;

		dst[p] ^= gf13_mul(v, c);
	}
}

// Assembly:
pushq %rbx
movl %edx, %eax
movslq %ecx, %rcx
leaq (%rdi,%rcx,2), %rdx
xorl %edi, %edi
leaq 0x8bf(%rip), %r8        # 0x2070
leaq 0x48b8(%rip), %r9       # 0x6070
leaq (%rcx,%rdi), %r11
movzwl (%rsi,%rdi,2), %r10d
cmpq $0x10, %r11
setae %r11b
testw %r10w, %r10w
sete %bl
orb %r11b, %bl
jne 0x1807
movzwl %r10w, %r10d
movzwl (%r8,%rax,2), %r11d
addw (%r8,%r10,2), %r11w
movzwl %r11w, %r10d
leal -0x1fff(%r10), %r11d
cmpl $0x1fff, %r10d          # imm = 0x1FFF
cmovbl %r10d, %r11d
movzwl %r11w, %r10d
movzwl (%r9,%r10,2), %r10d
xorw %r10w, (%rdx,%rdi,2)
incq %rdi
cmpq $0x10, %rdi
jne 0x17b8
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/bch.c
// Function: main
int main(void)
{
	srandom(0);
	test_code(&bch_1bit);
	test_code(&bch_2bit);
	test_code(&bch_3bit);
	test_code(&bch_4bit);

	return 0;
}

// Assembly:
pushq %rax
xorl %edi, %edi
callq 0x1030
leaq 0x7e5(%rip), %rdi       # 0x2008
callq 0x1850
leaq 0x7f1(%rip), %rdi       # 0x2020
callq 0x1850
leaq 0x7fd(%rip), %rdi       # 0x2038
callq 0x1850
leaq 0x809(%rip), %rdi       # 0x2050
callq 0x1850
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tests/bch.c
// Function: test_code
static void test_code(const struct bch_def *def)
{
	uint8_t block[TEST_CHUNK_SIZE];
	int i;

	printf("nbits: %d\n", def->syns / 2);

	memset(block, 0xff, sizeof(block));
	test_properties(def, block);

	for (i = 0; i < 10; i++)
		test_random_block(def);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x420, %rsp            # imm = 0x420
movq %rdi, %rbx
movl (%rdi), %eax
movl %eax, %esi
shrl $0x1f, %esi
addl %eax, %esi
sarl %esi
leaq 0x87fb(%rip), %rdi      # 0xa070
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x1040
leaq 0x210(%rsp), %r14
movl $0x208, %edx            # imm = 0x208
movq %r14, %rdi
movl $0xff, %esi
callq 0x1060
movq %rbx, %rdi
movq %r14, %rsi
callq 0x18ff
leaq 0x200(%rsp), %r14
movq %rsp, %r15
xorl %r13d, %r13d
callq 0x1080
movb %al, (%rsp,%r13)
incq %r13
cmpq $0x200, %r13            # imm = 0x200
jne 0x18b2
movl $0x200, %edx            # imm = 0x200
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x119c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x18ff
incl %r12d
cmpl $0xa, %r12d
jne 0x18af
addq $0x420, %rsp            # imm = 0x420
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq