; Listing generated by Microsoft (R) Optimizing Compiler Version 14.00.50727.42 

	TITLE	c:\Documents and Settings\Tobi\My Documents\Visual Studio 2005\Projects\Scimark2-AMD\source\MonteCarlo.c
	.686P
	.XMM
	include listing.inc
	.model	flat

INCLUDELIB OLDNAMES

_SEED	DD	071H
PUBLIC	__real@4010000000000000
PUBLIC	_MonteCarlo_integrate
;	COMDAT __real@4010000000000000
; File c:\documents and settings\tobi\my documents\visual studio 2005\projects\scimark2-amd\source\random.c
CONST	SEGMENT
__real@4010000000000000 DQ 04010000000000000r	; 4
; Function compile flags: /Ogtpy
; File c:\documents and settings\tobi\my documents\visual studio 2005\projects\scimark2-amd\source\montecarlo.c
CONST	ENDS
_TEXT	SEGMENT
_k$4790 = -4						; size = 4
_k$4776 = -4						; size = 4
_under_curve$ = -4					; size = 4
_Num_samples$ = 8					; size = 4
_MonteCarlo_integrate PROC

; 46   :     {

	push	ecx
	push	ebx
	push	esi
	mov	esi, DWORD PTR _Num_samples$[esp+8]
	push	edi

; 47   : 
; 48   : 
; 49   :         Random R = new_Random_seed(SEED);

	push	112					; 00000070H
	call	_malloc
	mov	edi, eax
	add	esp, 4
	mov	eax, 113				; 00000071H
	call	_initialize
	fldz
	fstp	QWORD PTR [edi+88]

; 50   : 
; 51   : 
; 52   :         int under_curve = 0;

	xor	ebx, ebx

; 53   :         int count;
; 54   : 
; 55   :         for (count=0; count<Num_samples; count++)

	test	esi, esi
	fld1
	fst	QWORD PTR [edi+96]
	mov	DWORD PTR [edi+80], 0
	fst	QWORD PTR [edi+104]
	mov	DWORD PTR _under_curve$[esp+16], ebx
	jle	$LN32@MonteCarlo

; 47   : 
; 48   : 
; 49   :         Random R = new_Random_seed(SEED);

	fld	QWORD PTR _dm1
$LN4@MonteCarlo:

; 56   :         {
; 57   :             double x= Random_nextDouble(R);

	mov	ecx, DWORD PTR [edi+72]
	mov	eax, DWORD PTR [edi+76]
	mov	edx, DWORD PTR [edi+ecx*4]
	sub	edx, DWORD PTR [edi+eax*4]
	mov	DWORD PTR _k$4776[esp+16], edx
	jns	SHORT $LN15@MonteCarlo
	add	edx, 2147483647				; 7fffffffH
	mov	DWORD PTR _k$4776[esp+16], edx
$LN15@MonteCarlo:
	test	ecx, ecx
	mov	DWORD PTR [edi+eax*4], edx
	jne	SHORT $LN14@MonteCarlo
	mov	ecx, 16					; 00000010H
	jmp	SHORT $LN13@MonteCarlo
$LN14@MonteCarlo:
	sub	ecx, 1
$LN13@MonteCarlo:
	test	eax, eax
	mov	DWORD PTR [edi+72], ecx
	jne	SHORT $LN12@MonteCarlo
	mov	eax, 16					; 00000010H
	jmp	SHORT $LN11@MonteCarlo
$LN12@MonteCarlo:
	sub	eax, 1
$LN11@MonteCarlo:
	cmp	DWORD PTR [edi+80], 0
	fild	DWORD PTR _k$4776[esp+16]
	mov	DWORD PTR [edi+76], eax
	fmul	ST(0), ST(1)
	je	SHORT $LN9@MonteCarlo
	fmul	QWORD PTR [edi+104]
	fadd	QWORD PTR [edi+88]
$LN9@MonteCarlo:

; 58   :             double y= Random_nextDouble(R);

	mov	edx, DWORD PTR [edi+ecx*4]
	sub	edx, DWORD PTR [edi+eax*4]
	mov	DWORD PTR _k$4790[esp+16], edx
	jns	SHORT $LN24@MonteCarlo
	add	edx, 2147483647				; 7fffffffH
	mov	DWORD PTR _k$4790[esp+16], edx
$LN24@MonteCarlo:
	test	ecx, ecx
	mov	DWORD PTR [edi+eax*4], edx
	jne	SHORT $LN23@MonteCarlo
	mov	ecx, 16					; 00000010H
	jmp	SHORT $LN22@MonteCarlo
$LN23@MonteCarlo:
	add	ecx, -1
$LN22@MonteCarlo:
	test	eax, eax
	mov	DWORD PTR [edi+72], ecx
	jne	SHORT $LN21@MonteCarlo
	mov	eax, 16					; 00000010H
	jmp	SHORT $LN20@MonteCarlo
$LN21@MonteCarlo:
	add	eax, -1
$LN20@MonteCarlo:
	cmp	DWORD PTR [edi+80], 0
	fild	DWORD PTR _k$4790[esp+16]
	mov	DWORD PTR [edi+76], eax
	fmul	ST(0), ST(2)
	je	SHORT $LN18@MonteCarlo
	fmul	QWORD PTR [edi+104]
	fadd	QWORD PTR [edi+88]
$LN18@MonteCarlo:

; 59   : 
; 60   :             if ( x*x + y*y <= 1.0)

	fmul	ST(0), ST(0)
	fld	ST(1)
	fmulp	ST(2), ST(0)
	faddp	ST(1), ST(0)
	fxch	ST(2)
	fcomi	ST(2)
	fstp	ST(2)
	jb	SHORT $LN3@MonteCarlo

; 61   :                  under_curve ++;

	add	ebx, 1
$LN3@MonteCarlo:

; 53   :         int count;
; 54   : 
; 55   :         for (count=0; count<Num_samples; count++)

	sub	esi, 1
	jne	$LN4@MonteCarlo
	fstp	ST(0)

; 61   :                  under_curve ++;

	mov	DWORD PTR _under_curve$[esp+16], ebx
$LN32@MonteCarlo:

; 62   :             
; 63   :         }
; 64   : 
; 65   :         Random_delete(R);

	push	edi
	fstp	ST(0)
	call	_free

; 66   : 
; 67   :         return ((double) under_curve / Num_samples) * 4.0;

	fild	DWORD PTR _under_curve$[esp+20]
	add	esp, 4

; 68   :     }

	pop	edi
	fidiv	DWORD PTR _Num_samples$[esp+8]
	pop	esi
	pop	ebx
	fmul	QWORD PTR __real@4010000000000000
	pop	ecx
	ret	0
_MonteCarlo_integrate ENDP
_TEXT	ENDS
PUBLIC	_MonteCarlo_num_flops
; Function compile flags: /Ogtpy
_TEXT	SEGMENT
_Num_samples$ = 8					; size = 4
_MonteCarlo_num_flops PROC

; 37   :         /* 3 flops in x^2+y^2 and 1 flop in random routine */
; 38   : 
; 39   :         return ((double) Num_samples)* 4.0;

	fild	DWORD PTR _Num_samples$[esp-4]
	fmul	QWORD PTR __real@4010000000000000

; 40   : 
; 41   :     }

	ret	0
_MonteCarlo_num_flops ENDP
END
