Program: flood-fill

x86 assembly:
	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_floodfill                      ## -- Begin function floodfill
	.p2align	4, 0x90
_floodfill:                             ## @floodfill
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	subq	$16, %rsp
	movb	%cl, %al
	movb	%dl, %cl
	movb	%sil, %dl
	movq	%rdi, -8(%rbp)
	movb	%dl, -9(%rbp)
	movb	%cl, -10(%rbp)
	movb	%al, -11(%rbp)
	movq	-8(%rbp), %rax
	movsbl	-9(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	$10, %rcx, %rcx
	addq	%rcx, %rax
	movsbl	-10(%rbp), %ecx
	movslq	%ecx, %rcx
	movb	(%rax,%rcx), %al
	movb	%al, -12(%rbp)
	movb	-11(%rbp), %dl
	movq	-8(%rbp), %rax
	movsbl	-9(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	$10, %rcx, %rcx
	addq	%rcx, %rax
	movsbl	-10(%rbp), %ecx
	movslq	%ecx, %rcx
	movb	%dl, (%rax,%rcx)
	movl	$0, -16(%rbp)
LBB0_1:                                 ## =>This Inner Loop Header: Depth=1
	cmpl	$8, -16(%rbp)
	jge	LBB0_10
## %bb.2:                               ##   in Loop: Header=BB0_1 Depth=1
	movsbl	-9(%rbp), %eax
	movslq	-16(%rbp), %rdx
	leaq	_row(%rip), %rcx
	addl	(%rcx,%rdx,4), %eax
	cmpl	$0, %eax
	jl	LBB0_8
## %bb.3:                               ##   in Loop: Header=BB0_1 Depth=1
	movsbl	-9(%rbp), %eax
	movslq	-16(%rbp), %rdx
	leaq	_row(%rip), %rcx
	addl	(%rcx,%rdx,4), %eax
	cmpl	$10, %eax
	jge	LBB0_8
## %bb.4:                               ##   in Loop: Header=BB0_1 Depth=1
	movsbl	-10(%rbp), %eax
	movslq	-16(%rbp), %rdx
	leaq	_col(%rip), %rcx
	addl	(%rcx,%rdx,4), %eax
	cmpl	$0, %eax
	jl	LBB0_8
## %bb.5:                               ##   in Loop: Header=BB0_1 Depth=1
	movsbl	-10(%rbp), %eax
	movslq	-16(%rbp), %rdx
	leaq	_col(%rip), %rcx
	addl	(%rcx,%rdx,4), %eax
	cmpl	$10, %eax
	jge	LBB0_8
## %bb.6:                               ##   in Loop: Header=BB0_1 Depth=1
	movq	-8(%rbp), %rax
	movsbl	-9(%rbp), %ecx
	movslq	-16(%rbp), %rsi
	leaq	_row(%rip), %rdx
	addl	(%rdx,%rsi,4), %ecx
	movslq	%ecx, %rcx
	imulq	$10, %rcx, %rcx
	addq	%rcx, %rax
	movsbl	-10(%rbp), %ecx
	movslq	-16(%rbp), %rsi
	leaq	_col(%rip), %rdx
	addl	(%rdx,%rsi,4), %ecx
	movslq	%ecx, %rcx
	movsbl	(%rax,%rcx), %eax
	movsbl	-12(%rbp), %ecx
	cmpl	%ecx, %eax
	jne	LBB0_8
## %bb.7:                               ##   in Loop: Header=BB0_1 Depth=1
	movq	-8(%rbp), %rdi
	movsbl	-9(%rbp), %eax
	movslq	-16(%rbp), %rdx
	leaq	_row(%rip), %rcx
	addl	(%rcx,%rdx,4), %eax
	movb	%al, %cl
	movsbl	-10(%rbp), %eax
	movslq	-16(%rbp), %rsi
	leaq	_col(%rip), %rdx
	addl	(%rdx,%rsi,4), %eax
                                        ## kill: def $al killed $al killed $eax
	movsbl	%cl, %esi
	movsbl	%al, %edx
	movsbl	-11(%rbp), %ecx
	callq	_floodfill
LBB0_8:                                 ##   in Loop: Header=BB0_1 Depth=1
	jmp	LBB0_9
LBB0_9:                                 ##   in Loop: Header=BB0_1 Depth=1
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
	jmp	LBB0_1
LBB0_10:
	addq	$16, %rsp
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.globl	_printMatrix                    ## -- Begin function printMatrix
	.p2align	4, 0x90
_printMatrix:                           ## @printMatrix
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	$0, -12(%rbp)
LBB1_1:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB1_3 Depth 2
	cmpl	$10, -12(%rbp)
	jge	LBB1_8
## %bb.2:                               ##   in Loop: Header=BB1_1 Depth=1
	movl	$0, -16(%rbp)
LBB1_3:                                 ##   Parent Loop BB1_1 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	cmpl	$10, -16(%rbp)
	jge	LBB1_6
## %bb.4:                               ##   in Loop: Header=BB1_3 Depth=2
	movq	-8(%rbp), %rax
	movslq	-12(%rbp), %rcx
	imulq	$10, %rcx, %rcx
	addq	%rcx, %rax
	movslq	-16(%rbp), %rcx
	movsbl	(%rax,%rcx), %esi
	leaq	L_.str(%rip), %rdi
	movb	$0, %al
	callq	_libmin_printf
## %bb.5:                               ##   in Loop: Header=BB1_3 Depth=2
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
	jmp	LBB1_3
LBB1_6:                                 ##   in Loop: Header=BB1_1 Depth=1
	leaq	L_.str.1(%rip), %rdi
	movb	$0, %al
	callq	_libmin_printf
## %bb.7:                               ##   in Loop: Header=BB1_1 Depth=1
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	LBB1_1
LBB1_8:
	addq	$16, %rsp
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.globl	_main                           ## -- Begin function main
	.p2align	4, 0x90
_main:                                  ## @main
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	subq	$16, %rsp
	movl	$0, -4(%rbp)
	movl	$3, -8(%rbp)
	movl	$9, -12(%rbp)
	movb	$67, -13(%rbp)
	movsbl	-13(%rbp), %esi
	movl	-8(%rbp), %edx
	movl	-12(%rbp), %ecx
	leaq	L_.str.2(%rip), %rdi
	movb	$0, %al
	callq	_libmin_printf
	leaq	_mat(%rip), %rdi
	callq	_printMatrix
	movl	-8(%rbp), %eax
	movb	%al, %cl
	movl	-12(%rbp), %eax
                                        ## kill: def $al killed $al killed $eax
	leaq	_mat(%rip), %rdi
	movsbl	%cl, %esi
	movsbl	%al, %edx
	movsbl	-13(%rbp), %ecx
	callq	_floodfill
	leaq	L_.str.3(%rip), %rdi
	movb	$0, %al
	callq	_libmin_printf
	leaq	_mat(%rip), %rdi
	callq	_printMatrix
	callq	_libmin_success
	xorl	%eax, %eax
	addq	$16, %rsp
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__DATA,__data
	.globl	_mat                            ## @mat
	.p2align	4
_mat:
	.ascii	"YYYGGGGGGG"
	.ascii	"YYYYYYGXXX"
	.ascii	"GXGGGGGXXX"
	.ascii	"WXXWWGGGGX"
	.ascii	"WRRRRRGXXX"
	.ascii	"WWWRRGGXXX"
	.ascii	"WBWRRRRRRX"
	.ascii	"WBBBBRRXXX"
	.ascii	"WBBXBBBBXX"
	.ascii	"WBBXXXXXXX"

	.globl	_row                            ## @row
	.p2align	4
_row:
	.long	4294967295                      ## 0xffffffff
	.long	4294967295                      ## 0xffffffff
	.long	4294967295                      ## 0xffffffff
	.long	0                               ## 0x0
	.long	0                               ## 0x0
	.long	1                               ## 0x1
	.long	1                               ## 0x1
	.long	1                               ## 0x1

	.globl	_col                            ## @col
	.p2align	4
_col:
	.long	4294967295                      ## 0xffffffff
	.long	0                               ## 0x0
	.long	1                               ## 0x1
	.long	4294967295                      ## 0xffffffff
	.long	1                               ## 0x1
	.long	4294967295                      ## 0xffffffff
	.long	0                               ## 0x0
	.long	1                               ## 0x1

	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"  %c"

L_.str.1:                               ## @.str.1
	.asciz	"\n"

L_.str.2:                               ## @.str.2
	.asciz	"\nBEFORE flooding `%c' @ (%d,%d):\n"

L_.str.3:                               ## @.str.3
	.asciz	"\nAFTER:\n"

.subsections_via_symbols


ARM64 assembly:
	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_floodfill                      ; -- Begin function floodfill
	.p2align	2
_floodfill:                             ; @floodfill
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #32
	.cfi_def_cfa_offset 32
	stp	x29, x30, [sp, #16]             ; 16-byte Folded Spill
	add	x29, sp, #16
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	str	x0, [sp, #8]
	strb	w1, [sp, #7]
	strb	w2, [sp, #6]
	strb	w3, [sp, #5]
	ldr	x8, [sp, #8]
	ldrsb	x9, [sp, #7]
	mov	x11, #10
	mul	x9, x9, x11
	add	x8, x8, x9
	ldrsb	x9, [sp, #6]
	add	x8, x8, x9
	ldrb	w8, [x8]
	strb	w8, [sp, #4]
	ldrb	w8, [sp, #5]
	ldr	x9, [sp, #8]
	ldrsb	x10, [sp, #7]
	mul	x10, x10, x11
	add	x9, x9, x10
	ldrsb	x10, [sp, #6]
	add	x9, x9, x10
	strb	w8, [x9]
	str	wzr, [sp]
	b	LBB0_1
LBB0_1:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w8, [sp]
	subs	w8, w8, #8
	cset	w8, ge
	tbnz	w8, #0, LBB0_10
	b	LBB0_2
LBB0_2:                                 ;   in Loop: Header=BB0_1 Depth=1
	ldrsb	w8, [sp, #7]
	ldrsw	x10, [sp]
	adrp	x9, _row@PAGE
	add	x9, x9, _row@PAGEOFF
	ldr	w9, [x9, x10, lsl #2]
	add	w8, w8, w9
	subs	w8, w8, #0
	cset	w8, lt
	tbnz	w8, #0, LBB0_8
	b	LBB0_3
LBB0_3:                                 ;   in Loop: Header=BB0_1 Depth=1
	ldrsb	w8, [sp, #7]
	ldrsw	x10, [sp]
	adrp	x9, _row@PAGE
	add	x9, x9, _row@PAGEOFF
	ldr	w9, [x9, x10, lsl #2]
	add	w8, w8, w9
	subs	w8, w8, #10
	cset	w8, ge
	tbnz	w8, #0, LBB0_8
	b	LBB0_4
LBB0_4:                                 ;   in Loop: Header=BB0_1 Depth=1
	ldrsb	w8, [sp, #6]
	ldrsw	x10, [sp]
	adrp	x9, _col@PAGE
	add	x9, x9, _col@PAGEOFF
	ldr	w9, [x9, x10, lsl #2]
	add	w8, w8, w9
	subs	w8, w8, #0
	cset	w8, lt
	tbnz	w8, #0, LBB0_8
	b	LBB0_5
LBB0_5:                                 ;   in Loop: Header=BB0_1 Depth=1
	ldrsb	w8, [sp, #6]
	ldrsw	x10, [sp]
	adrp	x9, _col@PAGE
	add	x9, x9, _col@PAGEOFF
	ldr	w9, [x9, x10, lsl #2]
	add	w8, w8, w9
	subs	w8, w8, #10
	cset	w8, ge
	tbnz	w8, #0, LBB0_8
	b	LBB0_6
LBB0_6:                                 ;   in Loop: Header=BB0_1 Depth=1
	ldr	x10, [sp, #8]
	ldrsb	w8, [sp, #7]
	ldrsw	x11, [sp]
	adrp	x9, _row@PAGE
	add	x9, x9, _row@PAGEOFF
	ldr	w9, [x9, x11, lsl #2]
	add	w8, w8, w9
	mov	w9, #10
	smaddl	x8, w8, w9, x10
	ldrsb	w9, [sp, #6]
	ldrsw	x11, [sp]
	adrp	x10, _col@PAGE
	add	x10, x10, _col@PAGEOFF
	ldr	w10, [x10, x11, lsl #2]
	add	w9, w9, w10
	ldrsb	w8, [x8, w9, sxtw]
	ldrsb	w9, [sp, #4]
	subs	w8, w8, w9
	cset	w8, ne
	tbnz	w8, #0, LBB0_8
	b	LBB0_7
LBB0_7:                                 ;   in Loop: Header=BB0_1 Depth=1
	ldr	x0, [sp, #8]
	ldrsb	w8, [sp, #7]
	ldrsw	x10, [sp]
	adrp	x9, _row@PAGE
	add	x9, x9, _row@PAGEOFF
	ldr	w9, [x9, x10, lsl #2]
	add	w9, w8, w9
	ldrsb	w8, [sp, #6]
	ldrsw	x11, [sp]
	adrp	x10, _col@PAGE
	add	x10, x10, _col@PAGEOFF
	ldr	w10, [x10, x11, lsl #2]
	add	w8, w8, w10
	ldrsb	w3, [sp, #5]
	sxtb	w1, w9
	sxtb	w2, w8
	bl	_floodfill
	b	LBB0_8
LBB0_8:                                 ;   in Loop: Header=BB0_1 Depth=1
	b	LBB0_9
LBB0_9:                                 ;   in Loop: Header=BB0_1 Depth=1
	ldr	w8, [sp]
	add	w8, w8, #1
	str	w8, [sp]
	b	LBB0_1
LBB0_10:
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #32
	ret
	.cfi_endproc
                                        ; -- End function
	.globl	_printMatrix                    ; -- Begin function printMatrix
	.p2align	2
_printMatrix:                           ; @printMatrix
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #48
	.cfi_def_cfa_offset 48
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	stur	x0, [x29, #-8]
	stur	wzr, [x29, #-12]
	b	LBB1_1
LBB1_1:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_3 Depth 2
	ldur	w8, [x29, #-12]
	subs	w8, w8, #10
	cset	w8, ge
	tbnz	w8, #0, LBB1_8
	b	LBB1_2
LBB1_2:                                 ;   in Loop: Header=BB1_1 Depth=1
	str	wzr, [sp, #16]
	b	LBB1_3
LBB1_3:                                 ;   Parent Loop BB1_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ldr	w8, [sp, #16]
	subs	w8, w8, #10
	cset	w8, ge
	tbnz	w8, #0, LBB1_6
	b	LBB1_4
LBB1_4:                                 ;   in Loop: Header=BB1_3 Depth=2
	ldur	x8, [x29, #-8]
	ldursw	x9, [x29, #-12]
	mov	x10, #10
	mul	x9, x9, x10
	add	x8, x8, x9
	ldrsw	x9, [sp, #16]
	ldrsb	w10, [x8, x9]
	mov	x9, sp
                                        ; implicit-def: $x8
	mov	x8, x10
	str	x8, [x9]
	adrp	x0, l_.str@PAGE
	add	x0, x0, l_.str@PAGEOFF
	bl	_libmin_printf
	b	LBB1_5
LBB1_5:                                 ;   in Loop: Header=BB1_3 Depth=2
	ldr	w8, [sp, #16]
	add	w8, w8, #1
	str	w8, [sp, #16]
	b	LBB1_3
LBB1_6:                                 ;   in Loop: Header=BB1_1 Depth=1
	adrp	x0, l_.str.1@PAGE
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_libmin_printf
	b	LBB1_7
LBB1_7:                                 ;   in Loop: Header=BB1_1 Depth=1
	ldur	w8, [x29, #-12]
	add	w8, w8, #1
	stur	w8, [x29, #-12]
	b	LBB1_1
LBB1_8:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
	.cfi_endproc
                                        ; -- End function
	.globl	_main                           ; -- Begin function main
	.p2align	2
_main:                                  ; @main
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	mov	w8, #0
	stur	w8, [x29, #-20]                 ; 4-byte Folded Spill
	stur	wzr, [x29, #-4]
	mov	w8, #3
	stur	w8, [x29, #-8]
	mov	w8, #9
	stur	w8, [x29, #-12]
	mov	w8, #67
	sturb	w8, [x29, #-13]
	ldursb	w12, [x29, #-13]
	ldur	w8, [x29, #-8]
                                        ; implicit-def: $x10
	mov	x10, x8
	ldur	w9, [x29, #-12]
                                        ; implicit-def: $x8
	mov	x8, x9
	mov	x9, sp
                                        ; implicit-def: $x11
	mov	x11, x12
	str	x11, [x9]
	str	x10, [x9, #8]
	str	x8, [x9, #16]
	adrp	x0, l_.str.2@PAGE
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_libmin_printf
	adrp	x0, _mat@PAGE
	add	x0, x0, _mat@PAGEOFF
	str	x0, [sp, #32]                   ; 8-byte Folded Spill
	bl	_printMatrix
	ldr	x0, [sp, #32]                   ; 8-byte Folded Reload
	ldur	w9, [x29, #-8]
	ldur	w8, [x29, #-12]
	ldursb	w3, [x29, #-13]
	sxtb	w1, w9
	sxtb	w2, w8
	bl	_floodfill
	adrp	x0, l_.str.3@PAGE
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_libmin_printf
	ldr	x0, [sp, #32]                   ; 8-byte Folded Reload
	bl	_printMatrix
	bl	_libmin_success
	ldur	w0, [x29, #-20]                 ; 4-byte Folded Reload
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
	.cfi_endproc
                                        ; -- End function
	.section	__DATA,__data
	.globl	_mat                            ; @mat
_mat:
	.ascii	"YYYGGGGGGG"
	.ascii	"YYYYYYGXXX"
	.ascii	"GXGGGGGXXX"
	.ascii	"WXXWWGGGGX"
	.ascii	"WRRRRRGXXX"
	.ascii	"WWWRRGGXXX"
	.ascii	"WBWRRRRRRX"
	.ascii	"WBBBBRRXXX"
	.ascii	"WBBXBBBBXX"
	.ascii	"WBBXXXXXXX"

	.globl	_row                            ; @row
	.p2align	2
_row:
	.long	4294967295                      ; 0xffffffff
	.long	4294967295                      ; 0xffffffff
	.long	4294967295                      ; 0xffffffff
	.long	0                               ; 0x0
	.long	0                               ; 0x0
	.long	1                               ; 0x1
	.long	1                               ; 0x1
	.long	1                               ; 0x1

	.globl	_col                            ; @col
	.p2align	2
_col:
	.long	4294967295                      ; 0xffffffff
	.long	0                               ; 0x0
	.long	1                               ; 0x1
	.long	4294967295                      ; 0xffffffff
	.long	1                               ; 0x1
	.long	4294967295                      ; 0xffffffff
	.long	0                               ; 0x0
	.long	1                               ; 0x1

	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"  %c"

l_.str.1:                               ; @.str.1
	.asciz	"\n"

l_.str.2:                               ; @.str.2
	.asciz	"\nBEFORE flooding `%c' @ (%d,%d):\n"

l_.str.3:                               ; @.str.3
	.asciz	"\nAFTER:\n"

.subsections_via_symbols