[BITS 16]
[org 0]
[section .text]

start:
	mov ax,cs
	mov ds,ax
	mov es,ax

	mov ah,03
	mov bh,0
	int 10h

	call _main
	jmp 0x1000:0

global _strstr
global _bzero
global _is_digit
global _strlen
global _atoi
global _scanf
global _print_short
global _printf
global _strcpy
global _main
global _putc
global _getch
global _strcmp

[segment .text]

%include "io.asm"


%define _ret -2
%define _i -4
%define _n -6
%define _off -8
%define _num -20
%define temp1 -22
%define _str 4

_atoi:
	push bp
	mov bp,sp
	sub sp,word 20
	push word 0
	push 4
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	push 10000
	pop dx
	pop di
	mov [di],dx
	push dx
	pop ax
	push word 0
	push 3
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	push 1000
	pop dx
	pop di
	mov [di],dx
	push dx
	pop ax
	push word 0
	push 2
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	push 100
	pop dx
	pop di
	mov [di],dx
	push dx
	pop ax
	push word 0
	push 1
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	push 10
	pop dx
	pop di
	mov [di],dx
	push dx
	pop ax
	push word 0
	push 0
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	push 1
	pop dx
	pop di
	mov [di],dx
	push dx
	pop ax
	push 0
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	push word [bp+_str]
	call _strlen
	add sp,word 2
	push ax
	pop ax
	mov [bp+_n],ax
	push ax
	pop ax
	push word [bp+_n]
	push 1
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop ax
	mov [bp+_off],ax
	push ax
	pop ax
	push 0
	pop ax
	mov [bp+_i],ax
	push ax
.L29:	
	push word [bp+_i]
	push word [bp+_n]
	pop bx
	pop dx
	cmp dx,bx
	jl .L30
	push 0
	jmp .L31
.L30:	
	push 1
.L31:	
	pop ax
	cmp ax,word 0
	je .L28
	sub sp,word 2
	push word 0
	push word [bp+_i]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_str]
	pop dx
	push bx
	add bx,dx
	push bx
	pop bx
	mov al,[bx]
	cpush al
	pop word [bp+temp1]
	mov ax,'0'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L33
	jmp .L32
.L33:	
	mov ax,'1'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L34
	push word [bp+_ret]
	push 1
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L32
.L34:	
	mov ax,'2'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L35
	push word [bp+_ret]
	push 2
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L32
.L35:	
	mov ax,'3'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L36
	push word [bp+_ret]
	push 3
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L32
.L36:	
	mov ax,'4'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L37
	push word [bp+_ret]
	push 4
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L32
.L37:	
	mov ax,'5'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L38
	push word [bp+_ret]
	push 5
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L32
.L38:	
	mov ax,'6'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L39
	push word [bp+_ret]
	push 6
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L32
.L39:	
	mov ax,'7'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L40
	push word [bp+_ret]
	push 7
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L32
.L40:	
	mov ax,'8'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L41
	push word [bp+_ret]
	push 8
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L32
.L41:	
	mov ax,'9'
	mov bx,word [bp+temp1]
	cmp ax,bx
	jne .L42
	push word [bp+_ret]
	push 9
	push word 0
	push word [bp+_off]
	push word [bp+_i]
	pop bx
	pop dx
	sub dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	lea bx,[bp+_num]
	pop dx
	imul dx,word 2
	add bx,dx
	push bx
	pop bx
	mov dx,[bx]
	push dx
	pop bx
	pop dx
	imul bx,dx
	push bx
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	jmp .L32
.L42:	
.L32:	
	inc word [bp+_i]
	push word [bp+_i]
	pop ax
	jmp .L29
.L28:	
	push word [bp+_ret]
	pop ax
	leave
	ret
%undef _ret
%undef _i
%undef _n
%undef _off
%undef _num
%undef temp1
%undef _str

%define _i -2
%define _ptr 4
%define _len 6

_bzero:
	push bp
	mov bp,sp
	sub sp,word 2
	push 0
	pop ax
	mov [bp+_i],ax
	push ax
.L17:	
	push word [bp+_i]
	push word [bp+_len]
	pop bx
	pop dx
	cmp dx,bx
	jl .L18
	push 0
	jmp .L19
.L18:	
	push 1
.L19:	
	pop ax
	cmp ax,word 0
	je .L16
	sub sp,word 0
	push word 0
	push word [bp+_i]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_ptr]
	pop dx
	push bx
	add bx,dx
	push bx
	push word 0
	pop dx
	pop di
	mov [di],dx
	push dx
	pop ax
	inc word [bp+_i]
	push word [bp+_i]
	pop ax
	jmp .L17
.L16:	
	leave
	ret

%undef _i
%undef _ptr
%undef _len

%define _ch 4

_is_digit:
	push bp
	mov bp,sp
	sub sp,word 0
	push word [bp+_ch]
	push word '0'
	pop bx
	pop dx
	cmp dx,bx
	jge .L21
	push 0
	jmp .L22
.L21:	
	push 1
.L22:	
	push word [bp+_ch]
	push word '9'
	pop bx
	pop dx
	cmp dx,bx
	jle .L23
	push 0
	jmp .L24
.L23:	
	push 1
.L24:	
	pop bx
	pop ax
	and ax,bx
	push ax
	pop ax
	cmp ax,word 0
	je .L25
	sub sp,word 0
	push 1
	pop ax
	leave
	ret
	jmp .L20
.L25:	
.L20:	
	push 0
	pop ax
	leave
	ret
%undef _ch


_main:
	push bp
	mov bp,sp
	sub sp,word 0
	push 101
	push C0
	call _printf
	add sp,word 4
	push ax
	pop ax
	push 0
	pop ax
	leave
	ret

%define _ret -2
%define _n -4
%define _byte_array -14
%define _buffer -24
%define _index -26
%define _number 4

_print_short:
	push bp
	mov bp,sp
	sub sp,word 26
	push 0
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	push word 0
	push 0
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '0'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 1
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '1'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 2
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '2'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 3
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '3'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 4
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '4'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 5
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '5'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 6
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '6'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 7
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '7'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 8
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '8'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word 0
	push 9
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	push word '9'
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	push word [bp+_number]
	push 0
	pop bx
	pop dx
	cmp dx,bx
	je .L69
	push 0
	jmp .L70
.L69:	
	push 1
.L70:	
	pop ax
	cmp ax,word 0
	je .L71
	sub sp,word 0
	push word '0'
	call _putc
	add sp,word 2
	push ax
	pop ax
	jmp .L68
.L71:	
.L68:	
	push 0
	pop ax
	mov [bp+_index],ax
	push ax
	pop ax
.L73:	
	push word [bp+_number]
	pop ax
	cmp ax,word 0
	je .L72
	sub sp,word 0
	push word [bp+_number]
	push 10
	pop bx
	pop ax
	xor dx,dx
	idiv bx
	push dx
	pop ax
	mov [bp+_n],ax
	push ax
	pop ax
	push word [bp+_number]
	push 10
	pop bx
	pop ax
	xor dx,dx
	idiv bx
	push ax
	pop ax
	mov [bp+_number],ax
	push ax
	pop ax
	push word 0
	push word [bp+_index]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_buffer]
	cpush al
	push word 0
	push word [bp+_n]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_byte_array]
	cpush al
	pop bx
	mov al,[bx]
	cpush al
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	inc word [bp+_index]
	push word [bp+_index]
	pop ax
	jmp .L73
.L72:	
	dec word [bp+_index]
	push word [bp+_index]
	pop ax
.L75:	
	push word [bp+_index]
	push 0
	pop bx
	pop dx
	cmp dx,bx
	jge .L76
	push 0
	jmp .L77
.L76:	
	push 1
.L77:	
	pop ax
	cmp ax,word 0
	je .L74
	sub sp,word 0
	push word 0
	push word [bp+_index]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_buffer]
	cpush al
	pop bx
	mov al,[bx]
	cpush al
	call _putc
	add sp,word 2
	push ax
	pop ax
	dec word [bp+_index]
	push word [bp+_index]
	pop ax
	jmp .L75
.L74:	
	push word [bp+_ret]
	pop ax
	leave
	ret
%undef _ret
%undef _n
%undef _byte_array
%undef _buffer
%undef _index
%undef _number

%define _ptr -2
%define _ptr0 -4
%define _ptr1 -6
%define _i -8
%define _j -10
%define _ret -12
%define _fmt 4

_printf:
	push bp
	mov bp,sp
	sub sp,word 12
	push 0
	pop ax
	mov [bp+_ret],ax
	push ax
	pop ax
	push word [bp+_fmt]
	pop ax
	mov [bp+_ptr],ax
	push ax
	pop ax
	push 2
	pop ax
	mov [bp+_i],ax
	push ax
	pop ax
.L79:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	cpop al
	cmp al,byte 0
	je .L78
	sub sp,word 0
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	push word '%'
	pop bx
	pop dx
	cmp dx,bx
	je .L81
	push 0
	jmp .L82
.L81:	
	push 1
.L82:	
	pop ax
	cmp ax,word 0
	je .L83
	sub sp,word 0
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	push word '%'
	pop bx
	pop dx
	cmp dx,bx
	je .L85
	push 0
	jmp .L86
.L85:	
	push 1
.L86:	
	pop ax
	cmp ax,word 0
	je .L87
	sub sp,word 0
	push word '%'
	call _putc
	add sp,word 2
	push ax
	pop ax
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	jmp .L84
.L87:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	push word 'x'
	pop bx
	pop dx
	cmp dx,bx
	je .L88
	push 0
	jmp .L89
.L88:	
	push 1
.L89:	
	pop ax
	cmp ax,word 0
	je .L90
	sub sp,word 0
	lea ax,[bp+_fmt]
	push ax
	push word [bp+_i]
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ptr0],ax
	push ax
	pop ax
	push bp
	mov ax,[bp+_ptr0]
	mov bp,ax
	mov dx,[bp]
	pop bp
	push dx
	call _tohex
	add sp,word 2
	push 2
	mov bx,[bp+_i]
	pop dx
	add bx,dx
	push bx
	pop ax
	mov [bp+_i],ax
	push ax
	pop ax
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	jmp .L84
.L90:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	push word 'd'
	pop bx
	pop dx
	cmp dx,bx
	je .L91
	push 0
	jmp .L92
.L91:	
	push 1
.L92:	
	pop ax
	cmp ax,word 0
	je .L93
	sub sp,word 0
	lea ax,[bp+_fmt]
	push ax
	push word [bp+_i]
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ptr0],ax
	push ax
	pop ax
	push bp
	mov ax,[bp+_ptr0]
	mov bp,ax
	mov dx,[bp]
	pop bp
	push dx
	call _print_short
	add sp,word 2
	push ax
	pop ax
	push 2
	mov bx,[bp+_i]
	pop dx
	add bx,dx
	push bx
	pop ax
	mov [bp+_i],ax
	push ax
	pop ax
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	jmp .L84
.L93:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	push word 's'
	pop bx
	pop dx
	cmp dx,bx
	je .L94
	push 0
	jmp .L95
.L94:	
	push 1
.L95:	
	pop ax
	cmp ax,word 0
	je .L96
	sub sp,word 0
	lea ax,[bp+_fmt]
	push ax
	push word [bp+_i]
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ptr0],ax
	push ax
	pop ax
	push bp
	mov ax,[bp+_ptr0]
	mov bp,ax
	mov dx,[bp]
	pop bp
	push dx
	pop ax
	mov [bp+_ptr1],ax
	push ax
	pop ax
.L98:	
	mov di,[bp+_ptr1]
	mov al,[di]
	cpush al
	cpop al
	cmp al,byte 0
	je .L97
	sub sp,word 0
	mov di,[bp+_ptr1]
	mov al,[di]
	cpush al
	call _putc
	add sp,word 2
	push ax
	pop ax
	inc word [bp+_ptr1]
	push word [bp+_ptr1]
	pop ax
	jmp .L98
.L97:	
	push 2
	mov bx,[bp+_i]
	pop dx
	add bx,dx
	push bx
	pop ax
	mov [bp+_i],ax
	push ax
	pop ax
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	jmp .L84
.L96:	
	sub sp,word 0
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
.L84:	
	jmp .L80
.L83:	
	sub sp,word 0
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	call _putc
	add sp,word 2
	push ax
	pop ax
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
.L80:	
	jmp .L79
.L78:	
	push 0
	pop ax
	leave
	ret
%undef _ptr
%undef _ptr0
%undef _ptr1
%undef _i
%undef _j
%undef _ret
%undef _fmt

%define _ptr -2
%define _p -4
%define _temp -6
%define _buffer -106
%define _offset -108
%define _ch -110
%define _count -112
%define _fmt 4

_scanf:
	push bp
	mov bp,sp
	sub sp,word 112
	push 0
	pop ax
	mov [bp+_offset],ax
	push ax
	pop ax
	push 2
	pop ax
	mov [bp+_count],ax
	push ax
	pop ax
	lea ax,[bp+_fmt]
	push ax
	push word [bp+_count]
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ptr],ax
	push ax
	pop ax
	push word [bp+_fmt]
	pop ax
	mov [bp+_p],ax
	push ax
.L44:	
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	cpop al
	cmp al,byte 0
	je .L43
	sub sp,word 0
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	push word '%'
	pop bx
	pop dx
	cmp dx,bx
	je .L46
	push 0
	jmp .L47
.L46:	
	push 1
.L47:	
	pop ax
	cmp ax,word 0
	je .L48
	sub sp,word 0
	inc word [bp+_p]
	push word [bp+_p]
	pop ax
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	push word 'd'
	pop bx
	pop dx
	cmp dx,bx
	je .L50
	push 0
	jmp .L51
.L50:	
	push 1
.L51:	
	pop ax
	cmp ax,word 0
	je .L52
	sub sp,word 0
	push bp
	mov ax,[bp+_ptr]
	mov bp,ax
	mov dx,[bp]
	pop bp
	push dx
	pop ax
	mov [bp+_temp],ax
	push ax
	pop ax
	call _getch
	push ax
	pop ax
	mov [bp+_ch],ax
	push ax
	pop ax
	push word [bp+_ch]
	call _putc
	add sp,word 2
	push ax
	pop ax
	push 0
	pop ax
	mov [bp+_offset],ax
	push ax
	pop ax
.L54:	
	push word [bp+_ch]
	call _is_digit
	add sp,word 2
	push ax
	push word [bp+_ch]
	push word 13
	pop bx
	pop dx
	cmp dx,bx
	jne .L55
	push 0
	jmp .L56
.L55:	
	push 1
.L56:	
	push word [bp+_ch]
	push word 10
	pop bx
	pop dx
	cmp dx,bx
	jne .L57
	push 0
	jmp .L58
.L57:	
	push 1
.L58:	
	pop bx
	pop ax
	and ax,bx
	push ax
	pop bx
	pop ax
	and ax,bx
	push ax
	pop ax
	cmp ax,word 0
	je .L53
	sub sp,word 0
	push word 0
	push word [bp+_offset]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_buffer]
	cpush al
	push word [bp+_ch]
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	inc word [bp+_offset]
	push word [bp+_offset]
	pop ax
	call _getch
	push ax
	pop ax
	mov [bp+_ch],ax
	push ax
	pop ax
	push word [bp+_ch]
	call _putc
	add sp,word 2
	push ax
	pop ax
	jmp .L54
.L53:	
	push word 0
	push word [bp+_offset]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov al,[bp+_buffer]
	cpush al
	push word 0
	cpop al
	pop di
	mov [di],al
	cpush al
	pop ax
	lea ax,[bp+_buffer]
	push ax
	call _atoi
	add sp,word 2
	push ax
	pop ax
	mov di,[bp+_temp]
	mov [di],ax
	push ax
	pop ax
	push word [bp+_count]
	push 2
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_count],ax
	push ax
	pop ax
	lea ax,[bp+_fmt]
	push ax
	push word [bp+_count]
	pop bx
	pop dx
	add dx,bx
	push dx
	pop ax
	mov [bp+_ptr],ax
	push ax
	pop ax
	jmp .L49
.L52:	
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	push word 'f'
	pop bx
	pop dx
	cmp dx,bx
	je .L59
	push 0
	jmp .L60
.L59:	
	push 1
.L60:	
	pop ax
	cmp ax,word 0
	je .L61
	sub sp,word 0
	nop
	jmp .L49
.L61:	
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	push word 's'
	pop bx
	pop dx
	cmp dx,bx
	je .L62
	push 0
	jmp .L63
.L62:	
	push 1
.L63:	
	pop ax
	cmp ax,word 0
	je .L64
	sub sp,word 0
	nop
	jmp .L49
.L64:	
	mov di,[bp+_p]
	mov al,[di]
	cpush al
	push word 'c'
	pop bx
	pop dx
	cmp dx,bx
	je .L65
	push 0
	jmp .L66
.L65:	
	push 1
.L66:	
	pop ax
	cmp ax,word 0
	je .L67
	sub sp,word 0
	nop
	jmp .L49
.L67:	
.L49:	
	jmp .L45
.L48:	
	sub sp,word 0
	nop
.L45:	
	inc word [bp+_p]
	push word [bp+_p]
	pop ax
	jmp .L44
.L43:	
	push 0
	pop ax
	leave
	ret
%undef _ptr
%undef _p
%undef _temp
%undef _buffer
%undef _offset
%undef _ch
%undef _count
%undef _fmt

%define _a 4
%define _b 6

_strcpy:
	push bp
	mov bp,sp
	sub sp,word 0
.L100:	
	mov di,[bp+_b]
	mov al,[di]
	cpush al
	cpop al
	mov di,[bp+_a]
	mov [di],al
	cpush al
	cpop al
	cmp al,byte 0
	je .L99
	sub sp,word 0
	inc word [bp+_a]
	push word [bp+_a]
	pop ax
	inc word [bp+_b]
	push word [bp+_b]
	pop ax
	jmp .L100
.L99:	
	leave
	ret

%undef _a
%undef _b

%define _n -2
%define _ptr 4

_strlen:
	push bp
	mov bp,sp
	sub sp,word 2
	push 0
	pop ax
	mov [bp+_n],ax
	push ax
	pop ax
.L27:	
	mov di,[bp+_ptr]
	mov al,[di]
	cpush al
	cpop al
	cmp al,byte 0
	je .L26
	sub sp,word 0
	inc word [bp+_n]
	push word [bp+_n]
	pop ax
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	jmp .L27
.L26:	
	push word [bp+_n]
	pop ax
	leave
	ret
%undef _n
%undef _ptr

%define _ptr -2
%define _i -4
%define _j -6
%define _count -8
%define _buffer 4
%define _str 6

_strstr:
	push bp
	mov bp,sp
	sub sp,word 8
	push 0
	pop ax
	mov [bp+_ptr],ax
	push ax
	pop ax
	push 0
	pop ax
	mov [bp+_count],ax
	push ax
	pop ax
	push word [bp+_buffer]
	pop ax
	mov [bp+_ptr],ax
	push ax
	pop ax
	push 0
	pop ax
	mov [bp+_i],ax
	push ax
.L1:	
	push word [bp+_i]
	push word [bp+_buffer]
	call _strlen
	add sp,word 2
	push ax
	pop bx
	pop dx
	cmp dx,bx
	jl .L2
	push 0
	jmp .L3
.L2:	
	push 1
.L3:	
	pop ax
	cmp ax,word 0
	je .L0
	sub sp,word 0
	push 0
	pop ax
	mov [bp+_j],ax
	push ax
.L5:	
	push word [bp+_j]
	push word [bp+_str]
	call _strlen
	add sp,word 2
	push ax
	pop bx
	pop dx
	cmp dx,bx
	jl .L6
	push 0
	jmp .L7
.L6:	
	push 1
.L7:	
	pop ax
	cmp ax,word 0
	je .L4
	sub sp,word 0
	push word 0
	push word [bp+_i]
	push word [bp+_j]
	pop bx
	pop dx
	add dx,bx
	push dx
	pop bx
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_buffer]
	pop dx
	push bx
	add bx,dx
	push bx
	pop bx
	mov al,[bx]
	cpush al
	push word 0
	push word [bp+_j]
	pop bx
	pop dx
	add bx,dx
	push bx
	mov bx,[bp+_str]
	pop dx
	push bx
	add bx,dx
	push bx
	pop bx
	mov al,[bx]
	cpush al
	pop bx
	pop dx
	cmp dx,bx
	je .L9
	push 0
	jmp .L10
.L9:	
	push 1
.L10:	
	pop ax
	cmp ax,word 0
	je .L11
	sub sp,word 0
	inc word [bp+_count]
	push word [bp+_count]
	pop ax
	jmp .L8
.L11:	
	sub sp,word 0
	push 0
	pop ax
	mov [bp+_count],ax
	push ax
	pop ax
.L8:	
	inc word [bp+_j]
	push word [bp+_j]
	pop ax
	jmp .L5
.L4:	
	push word [bp+_count]
	push word [bp+_str]
	call _strlen
	add sp,word 2
	push ax
	pop bx
	pop dx
	cmp dx,bx
	je .L13
	push 0
	jmp .L14
.L13:	
	push 1
.L14:	
	pop ax
	cmp ax,word 0
	je .L15
	sub sp,word 0
	jmp .L0
	jmp .L12
.L15:	
.L12:	
	inc word [bp+_ptr]
	push word [bp+_ptr]
	pop ax
	inc word [bp+_i]
	push word [bp+_i]
	pop ax
	jmp .L1
.L0:	
	push word [bp+_ptr]
	pop ax
	leave
	ret
%undef _ptr
%undef _i
%undef _j
%undef _count
%undef _buffer
%undef _str



[section .data]

C0: db 'number == %d',13,10,0

[section .bss]

answer: resb 20

