	.file	"ASP2x.c"
	.section	.rodata
	.p2align 5
.LC0:
	.string	"Chyba pri zistovani mena stroja"
.LC1:
	.string	"\nMeno stroja:%s"
.LC2:
	.string	"Chyba pri zistovani PID"
.LC3:
	.string	"\nPID %ld"
.LC4:
	.string	"Chyba pri zistovani UID"
.LC5:
	.string	"\nZeby sme mali uid %ld"
.LC6:
	.string	"Chyba pri zistovani loginu"
.LC7:
	.string	"\nLogin:"
	.p2align 5
.LC8:
	.string	"\n\nZadajte retazec (max 100 znakov):"
.LC9:
	.string	"Toto by sa nemalo vypisat"
.LC10:
	.string	"\nPocet znakov retazca je:%d\n"
	.text
	.p2align 2,,3
.globl main
	.type	main, @function
main:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$296, %esp
	andl	$-16, %esp
	movl	$0, %eax
	subl	%eax, %esp
	subl	$4, %esp
	pushl	$25
	leal	-56(%ebp), %eax
	pushl	%eax
	pushl	$87
	call	syscall
	addl	$16, %esp
	cmpl	$-1, %eax
	jne	.L10
	subl	$12, %esp
	pushl	$.LC0
	call	perror
	addl	$16, %esp
.L10:
	subl	$8, %esp
	leal	-56(%ebp), %eax
	pushl	%eax
	pushl	$.LC1
	call	printf
	addl	$16, %esp
	subl	$12, %esp
	pushl	$20
	call	syscall
	addl	$16, %esp
	movl	%eax, -12(%ebp)
	movl	-12(%ebp), %eax
	cmpl	$-1, %eax
	jne	.L11
	subl	$12, %esp
	pushl	$.LC2
	call	perror
	addl	$16, %esp
.L11:
	subl	$8, %esp
	pushl	-12(%ebp)
	pushl	$.LC3
	call	printf
	addl	$16, %esp
	subl	$8, %esp
	leal	-16(%ebp), %eax
	pushl	%eax
	pushl	$24
	call	syscall
	addl	$16, %esp
	movl	%eax, -16(%ebp)
	movl	-16(%ebp), %eax
	cmpl	$-1, %eax
	jne	.L12
	subl	$12, %esp
	pushl	$.LC4
	call	perror
	addl	$16, %esp
.L12:
	subl	$8, %esp
	pushl	-16(%ebp)
	pushl	$.LC5
	call	printf
	addl	$16, %esp
	subl	$4, %esp
	pushl	$100
	leal	-168(%ebp), %eax
	pushl	%eax
	pushl	$49
	call	syscall
	addl	$16, %esp
	cmpl	$-1, %eax
	jne	.L13
	subl	$12, %esp
	pushl	$.LC6
	call	perror
	addl	$16, %esp
.L13:
	subl	$12, %esp
	pushl	$.LC7
	call	printf
	addl	$16, %esp
	subl	$12, %esp
	leal	-168(%ebp), %eax
	pushl	%eax
	call	puts
	addl	$16, %esp
	subl	$12, %esp
	pushl	$.LC8
	call	printf
	addl	$16, %esp
	subl	$4, %esp
	pushl	__stdinp
	pushl	$102
	leal	-280(%ebp), %eax
	pushl	%eax
	call	fgets
	addl	$16, %esp
	subl	$12, %esp
	leal	-280(%ebp), %eax
	pushl	%eax
	call	puts
	addl	$16, %esp
	subl	$12, %esp
	leal	-280(%ebp), %eax
	pushl	%eax
	call	Funkcia
	addl	$16, %esp
	movl	%eax, -284(%ebp)
	call	Jump
	subl	$12, %esp
	pushl	$.LC9
	call	printf
	addl	$16, %esp
	subl	$8, %esp
	pushl	-284(%ebp)
	pushl	$.LC10
	call	printf
	addl	$16, %esp
	movl	$1, %eax
	leave
	ret
	.size	main, .-main
	.section	.rodata
	.p2align 5
.LC11:
	.string	"\n\nZadajte znak, ktory mam hladat:"
	.p2align 5
.LC12:
	.string	"V retazci \"%s\" bolo najdenych %d vyskytov znaku %c\n"
	.text
	.p2align 2,,3
.globl Funkcia
	.type	Funkcia, @function
Funkcia:
	pushl	%ebp		;odlozenie base pointera do zasobnika
	movl	%esp, %ebp
	subl	$8, %esp	;alokovanie lokalnych premennych
	movl	$0, -8(%ebp)
.L15:
	movl	-8(%ebp), %eax
	addl	8(%ebp), %eax
	cmpb	$0, (%eax)
	jne	.L17
	jmp	.L16
.L17:
	leal	-8(%ebp), %eax
	incl	(%eax)
	movl	-8(%ebp), %eax	;vlozi zisteny pocet znakov do eax
	decl	%eax		;znizi pocet znakov o 1
	movl	%eax, -4(%ebp)	;vlozi hodnotu na prislusne miesto na zasobniku
	jmp	.L15
.L16:
	movl	-8(%ebp), %eax
	addl	8(%ebp), %eax
	decl	%eax
	movb	$0, (%eax)
	subl	$12, %esp
	pushl	$.LC11
	call	printf		;hlaska
	addl	$16, %esp
	call	getchar		;vstup znaku
	movl	%eax, -12(%ebp)
	movl	$0, -8(%ebp)	;nulovanie pocitadla
	movl	$0, -16(%ebp)	;nulovanie poctu najdenych znakov
.L18:
	movl	-8(%ebp), %eax
	addl	8(%ebp), %eax	;inkrementacia pocitadla
	cmpb	$0, (%eax)
	jne	.L20
	jmp	.L19
.L20:
	movl	-8(%ebp), %eax	;hladanie znakov
	addl	8(%ebp), %eax
	movsbl	(%eax),%eax
	cmpl	-12(%ebp), %eax
	jne	.L21
	leal	-16(%ebp), %eax
	incl	(%eax)
.L21:
	leal	-8(%ebp), %eax
	incl	(%eax)
	jmp	.L18
.L19:
	pushl	-12(%ebp)
	pushl	-16(%ebp)
	pushl	8(%ebp)
	pushl	$.LC12
	call	printf			;hlaska
	addl	$16, %esp
	movl	-4(%ebp), %eax           ;nastavenie navratovej hodnoty funkcie(eax)
;					na vyraz [ebp -4](pocet znakov) (adresa kam ukazuje base pointer -4)
;					4 preto lebo potrebujeme 32 bitov na long premennu
	leave
	ret
	.size	Funkcia, .-Funkcia
	.p2align 2,,3
.globl Jump
	.type	Jump, @function
Jump:
	pushl	%ebp		;do zasobnika odloz odkaz na base pointer
	movl	%esp, %ebp	;do base pointer vloz vrch stack pointera
	subl	$4, %esp	;nastav stack pointer
	leal	4(%ebp), %eax	;nastav efektivnu adresu na adresu
;				 na ktoru sa program vrati po ukonceni funkcie 
	addl	$16, (%eax)	;pridanie 16 (10H) na adresu, na ktoru
				;ukazuje register eax(zmena navratovej adresy)
	leave
	ret
	.size	Jump, .-Jump
	.ident	"GCC: (GNU) 3.3.3 [FreeBSD] 20031106"
