;==============================================================
; Intel Asm
;==============================================================
         .486
         .model flat, stdcall
         option casemap :none
         include \masm32\include\windows.inc
         include \masm32\include\masm32.inc
         include \masm32\include\kernel32.inc
         include \masm32\macros\macros.asm

         includelib \masm32\lib\masm32.lib
         includelib \masm32\lib\kernel32.lib

;==============================================================
         .data
Txt db ?, 0

;==============================================================
; Entry point:
         .code
start:
         FINIT
         PUSH  EBP
         MOV   EBP,  ESP
         SUB   ESP,  28
         ; Let Tu4_27 = 
         ; Unit
         ; Let x_18 = 
         ; Apply direct f_12
         CALL  f_12
         ADD   ESP,  0
         MOV   [EBP-4],  EAX
         ; Let Tu5_26 = 
         ; Unit
         ; Let y_19 = 
         ; Apply direct g_14
         CALL  g_14
         ADD   ESP,  0
         MOV   [EBP-8],  EAX
         ; Let Tu6_25 = 
         ; Unit
         ; Let Ti7_23 = 
         ; Apply direct h_16
         CALL  h_16
         ADD   ESP,  0
         MOV   [EBP-12],  EAX
         ; Let Ti8_24 = 
         ; Integer 0
         MOV   EAX,  0
         MOV   [EBP-16],  EAX
         ; Let Ti9_22 = 
         ; If Ti7_23 == Ti8_24
         MOV   EAX,  [EBP-12]
         CMP   EAX,  [EBP-16]
         JNE   else_28
         ; Sub x_18 - y_19
         MOV   EAX,  [EBP-4]
         SUB   EAX,  [EBP-8]
         MOV   [EBP-20],  EAX
         JMP   cont_29
else_28:
         ; Sub y_19 - x_18
         MOV   EAX,  [EBP-8]
         SUB   EAX,  [EBP-4]
         MOV   [EBP-20],  EAX
cont_29:
         ; Let Ti10_21 = 
         ; Add Ti9_22 + x_18
         MOV   EAX,  [EBP-20]
         ADD   EAX,  [EBP-4]
         MOV   [EBP-24],  EAX
         ; Let Ti11_20 = 
         ; Add Ti10_21 + y_19
         MOV   EAX,  [EBP-24]
         ADD   EAX,  [EBP-8]
         MOV   [EBP-28],  EAX
         ; Apply direct min_caml_print_int
         PUSH  dword ptr [EBP-28]
         CALL  min_caml_print_int
         ADD   ESP,  4
         MOV   ESP,  EBP
         POP   EBP
         PUSH  0
         CALL  ExitProcess

;==============================================================
; Function f_12:

f_12 proc
         PUSH  EBP
         MOV   EBP,  ESP
         SUB   ESP,  0
         ; Integer 123
         MOV   EAX,  123
         MOV   ESP,  EBP
         POP   EBP
         RET
f_12 endp

;==============================================================
; Function g_14:

g_14 proc
         PUSH  EBP
         MOV   EBP,  ESP
         SUB   ESP,  0
         ; Integer 456
         MOV   EAX,  456
         MOV   ESP,  EBP
         POP   EBP
         RET
g_14 endp

;==============================================================
; Function h_16:

h_16 proc
         PUSH  EBP
         MOV   EBP,  ESP
         SUB   ESP,  0
         ; Integer 789
         MOV   EAX,  789
         MOV   ESP,  EBP
         POP   EBP
         RET
h_16 endp

;==============================================================
; need to copy min_caml_intel.asm from min-caml directory to output directoty
include min_caml_intel.asm

END start

;==============================================================

