// File: /workspace/github_c_makefile_star2_O0/inflex[P]ripMIME/tnef/tnef.c
// Function: TNEF_decode_tnef
int TNEF_decode_tnef(uint8 *tnef_stream, int size)
{

	int ra_response;
	uint32 tnefs;
	uint16 tnef_attachkey;
	uint8 *tsp;

	if (TNEF_DEBUG) LOGGER_log("%s:%d:TNEF_decode_tnef:DEBUG: Start. Size = %d\n", FL,size);

	// TSP == TNEF Stream Pointer (well memory block actually!)
	//
	tsp = tnef_stream;

	// Read in the signature of this TNEF
	//
	ra_response = read_32(&tnefs, tsp);
	if ((ra_response != -1)&&(TNEF_SIGNATURE == tnefs))
	{
		if (TNEF_DEBUG) LOGGER_log("%s:%d:TNEF_decode_tnef:DEBUG: TNEF signature is good\n",FL);
	} else {
		if (TNEF_VERBOSE) LOGGER_log("%s:%d:TNEF_decode_tnef:WARNING: Bad TNEF signature, expecting %lx got %lx\n",FL,TNEF_SIGNATURE,tnefs);
	}

	// Move tsp pointer along
	//
	tsp += sizeof(TNEF_SIGNATURE);

	/** Read the TNEF Attach key **/
	if (read_16(&tnef_attachkey, tsp) == -1) return -1;
	if (TNEF_DEBUG) LOGGER_log("%s:%d:TNEF_decode_tnef:DEBUG: TNEF Attach Key: %x\n",FL,tnef_attachkey);

	// Move tsp pointer along
	//
	tsp += sizeof(uint16);

	// While we still have more bytes to process,
	//		go through entire memory block and extract
	//		all the required attributes and files
	//
	if (TNEF_DEBUG) LOGGER_log("%s:%d:TNEF_decode_tnef:DEBUG: TNEF - Commence reading attributes\n",FL);
	while ((tsp - tnef_stream) < size)
	{
		if (TNEF_DEBUG) LOGGER_log("%s:%d:TNEF_decode_tnef:DEBUG: Offset = %d\n", FL,tsp -TNEF_glb.tnef_home);
		ra_response = read_attribute(tsp);
		if ( ra_response > 0 )
		{
			tsp += ra_response;
		} else {

			// Must find out /WHY/ this happens, and, how to rectify the issue.

			tsp++;
			if (TNEF_DEBUG) LOGGER_log("%s:%d:TNEF_decode_tnef:WARNING: TNEF - Attempting to read attribute at %d resulted in a sub-zero response, ending decoding to be safe\n",FL,tsp);
			break;
		}
	}

	if (TNEF_DEBUG) LOGGER_log("%s:%d:TNEF_decode_tnef:DEBUG: Done.\n",FL);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpl $0x0, 0x25316(%rip)     # 0x352dc
jle 0xffe5
movl -0x14(%rbp), %ecx
leaq 0xe620(%rip), %rdi      # 0x1e5f2
leaq 0xe45f(%rip), %rsi      # 0x1e438
movl $0x2c0, %edx            # imm = 0x2C0
movb $0x0, %al
callq 0x117c0
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rsi
leaq -0x1c(%rbp), %rdi
callq 0xf0b0
movl %eax, -0x18(%rbp)
cmpl $-0x1, -0x18(%rbp)
je 0x10032
movl $0x223e9f78, %eax       # imm = 0x223E9F78
cmpl -0x1c(%rbp), %eax
jne 0x10032
cmpl $0x0, 0x252c8(%rip)     # 0x352dc
jle 0x10030
leaq 0xe605(%rip), %rdi      # 0x1e622
leaq 0xe414(%rip), %rsi      # 0x1e438
movl $0x2cb, %edx            # imm = 0x2CB
movb $0x0, %al
callq 0x117c0
jmp 0x10060
cmpl $0x0, 0x2529b(%rip)     # 0x352d4
jle 0x1005e
movl -0x1c(%rbp), %r8d
leaq 0xe612(%rip), %rdi      # 0x1e658
leaq 0xe3eb(%rip), %rsi      # 0x1e438
movl $0x2cd, %edx            # imm = 0x2CD
movl $0x223e9f78, %ecx       # imm = 0x223E9F78
movb $0x0, %al
callq 0x117c0
jmp 0x10060
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rsi
leaq -0x1e(%rbp), %rdi
callq 0xf210
cmpl $-0x1, %eax
jne 0x1008a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x101b4
cmpl $0x0, 0x2524b(%rip)     # 0x352dc
jle 0x100b1
movzwl -0x1e(%rbp), %ecx
leaq 0xe605(%rip), %rdi      # 0x1e6a3
leaq 0xe393(%rip), %rsi      # 0x1e438
movl $0x2d6, %edx            # imm = 0x2D6
movb $0x0, %al
callq 0x117c0
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
cmpl $0x0, 0x25218(%rip)     # 0x352dc
jle 0x100e0
leaq 0xe609(%rip), %rdi      # 0x1e6d6
leaq 0xe364(%rip), %rsi      # 0x1e438
movl $0x2e0, %edx            # imm = 0x2E0
movb $0x0, %al
callq 0x117c0
jmp 0x100e2
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movslq -0x14(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1018a
cmpl $0x0, 0x251db(%rip)     # 0x352dc
jle 0x1012b
movq -0x28(%rbp), %rcx
movq 0x255e2(%rip), %rax     # 0x356f0
subq %rax, %rcx
leaq 0xe600(%rip), %rdi      # 0x1e718
leaq 0xe319(%rip), %rsi      # 0x1e438
movl $0x2e3, %edx            # imm = 0x2E3
movb $0x0, %al
callq 0x117c0
movq -0x28(%rbp), %rdi
callq 0xf7e0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jle 0x10150
movl -0x18(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
jmp 0x10185
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
cmpl $0x0, 0x25179(%rip)     # 0x352dc
jle 0x10183
movq -0x28(%rbp), %rcx
leaq 0xe5d3(%rip), %rdi      # 0x1e743
leaq 0xe2c1(%rip), %rsi      # 0x1e438
movl $0x2ed, %edx            # imm = 0x2ED
movb $0x0, %al
callq 0x117c0
jmp 0x1018a
jmp 0x100e2
cmpl $0x0, 0x2514b(%rip)     # 0x352dc
jle 0x101ad
leaq 0xe630(%rip), %rdi      # 0x1e7ca
leaq 0xe297(%rip), %rsi      # 0x1e438
movl $0x2f2, %edx            # imm = 0x2F2
movb $0x0, %al
callq 0x117c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)