// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
cmpl $0x0, 0x23554(%rip)     # 0x2eeec
jle 0xb9b6
leaq 0xbb5d(%rip), %rdi      # 0x174fe
leaq 0xb99c(%rip), %rsi      # 0x17344
movl $0x2c0, %edx            # imm = 0x2C0
movl %ebp, %ecx
xorl %eax, %eax
callq 0xc84f
leaq 0x4(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb30e
cmpl $-0x1, %eax
setne %al
movl (%r14), %r8d
cmpl $0x223e9f78, %r8d       # imm = 0x223E9F78
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xba05
cmpl $0x0, 0x23505(%rip)     # 0x2eeec
jle 0xba2d
leaq 0xbb3e(%rip), %rdi      # 0x1752e
leaq 0xb94d(%rip), %rsi      # 0x17344
movl $0x2cb, %edx            # imm = 0x2CB
xorl %eax, %eax
callq 0xc84f
jmp 0xba2d
cmpl $0x0, 0x234d8(%rip)     # 0x2eee4
jle 0xba2d
leaq 0xbb4f(%rip), %rdi      # 0x17564
leaq 0xb928(%rip), %rsi      # 0x17344
movl $0x2cd, %edx            # imm = 0x2CD
movl $0x223e9f78, %ecx       # imm = 0x223E9F78
xorl %eax, %eax
callq 0xc84f
leaq 0x4(%rbx), %rsi
leaq 0x2(%rsp), %rdi
callq 0xb359
cmpl $-0x1, %eax
je 0xbaf0
cmpl $0x0, 0x234a1(%rip)     # 0x2eeec
jle 0xba8f
movzwl 0x2(%rsp), %ecx
leaq 0xbb56(%rip), %rdi      # 0x175af
leaq 0xb8e4(%rip), %rsi      # 0x17344
movl $0x2d6, %edx            # imm = 0x2D6
xorl %eax, %eax
callq 0xc84f
cmpl $0x0, 0x23479(%rip)     # 0x2eeec
jle 0xba8f
leaq 0xbb66(%rip), %rdi      # 0x175e2
leaq 0xb8c1(%rip), %rsi      # 0x17344
movl $0x2e0, %edx            # imm = 0x2E0
xorl %eax, %eax
callq 0xc84f
cmpl $0x7, %ebp
jl 0xbb20
movslq %ebp, %r13
leaq 0x6(%rbx), %r14
leaq 0xbb7e(%rip), %r15      # 0x17624
leaq 0xb897(%rip), %r12      # 0x17344
cmpl $0x0, 0x23438(%rip)     # 0x2eeec
jle 0xbad2
movq %r14, %rcx
subq 0x23840(%rip), %rcx     # 0x2f300
movq %r15, %rdi
movq %r12, %rsi
movl $0x2e3, %edx            # imm = 0x2E3
xorl %eax, %eax
callq 0xc84f
movq %r14, %rdi
callq 0xb676
testl %eax, %eax
jle 0xbaf7
movl %eax, %eax
addq %rax, %r14
movq %r14, %rax
subq %rbx, %rax
cmpq %r13, %rax
jl 0xbaad
jmp 0xbb20
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0xbb49
cmpl $0x0, 0x233ee(%rip)     # 0x2eeec
jle 0xbb47
incq %r14
leaq 0xbb45(%rip), %rdi      # 0x1764f
leaq 0xb833(%rip), %rsi      # 0x17344
movl $0x2ed, %edx            # imm = 0x2ED
movq %r14, %rcx
xorl %eax, %eax
callq 0xc84f
cmpl $0x0, 0x233c5(%rip)     # 0x2eeec
jle 0xbb47
leaq 0xbba6(%rip), %rdi      # 0x176d6
leaq 0xb80d(%rip), %rsi      # 0x17344
xorl %ebx, %ebx
movl $0x2f2, %edx            # imm = 0x2F2
xorl %eax, %eax
callq 0xc84f
jmp 0xbb49
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq