Program: bubble-sort

x86 assembly:
	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_print_data                     ## -- Begin function print_data
	.p2align	4, 0x90
_print_data:                            ## @print_data
	.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	%esi, -12(%rbp)
	leaq	L_.str(%rip), %rdi
	movb	$0, %al
	callq	_libmin_printf
	movl	$0, -16(%rbp)
LBB0_1:                                 ## =>This Inner Loop Header: Depth=1
	movl	-16(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jae	LBB0_4
## %bb.2:                               ##   in Loop: Header=BB0_1 Depth=1
	movl	-16(%rbp), %esi
	movq	-8(%rbp), %rax
	movl	-16(%rbp), %ecx
                                        ## kill: def $rcx killed $ecx
	movl	(%rax,%rcx,4), %edx
	leaq	L_.str.1(%rip), %rdi
	movb	$0, %al
	callq	_libmin_printf
## %bb.3:                               ##   in Loop: Header=BB0_1 Depth=1
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
	jmp	LBB0_1
LBB0_4:
	addq	$16, %rsp
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.globl	_bubblesort                     ## -- Begin function bubblesort
	.p2align	4, 0x90
_bubblesort:                            ## @bubblesort
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	$0, -16(%rbp)
LBB1_1:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB1_3 Depth 2
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %ecx
	subl	$1, %ecx
	cmpl	%ecx, %eax
	jae	LBB1_12
## %bb.2:                               ##   in Loop: Header=BB1_1 Depth=1
	movl	$0, -20(%rbp)
	movl	$0, -24(%rbp)
LBB1_3:                                 ##   Parent Loop BB1_1 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movl	-24(%rbp), %eax
	movl	-12(%rbp), %ecx
	subl	$1, %ecx
	cmpl	%ecx, %eax
	jae	LBB1_8
## %bb.4:                               ##   in Loop: Header=BB1_3 Depth=2
	movq	-8(%rbp), %rax
	movl	-24(%rbp), %ecx
                                        ## kill: def $rcx killed $ecx
	movl	(%rax,%rcx,4), %eax
	movq	-8(%rbp), %rcx
	movl	-24(%rbp), %edx
	addl	$1, %edx
	movl	%edx, %edx
                                        ## kill: def $rdx killed $edx
	cmpl	(%rcx,%rdx,4), %eax
	jle	LBB1_6
## %bb.5:                               ##   in Loop: Header=BB1_3 Depth=2
	movq	-8(%rbp), %rax
	movl	-24(%rbp), %ecx
                                        ## kill: def $rcx killed $ecx
	movl	(%rax,%rcx,4), %eax
	movl	%eax, -28(%rbp)
	movq	-8(%rbp), %rax
	movl	-24(%rbp), %ecx
	addl	$1, %ecx
	movl	%ecx, %ecx
                                        ## kill: def $rcx killed $ecx
	movl	(%rax,%rcx,4), %edx
	movq	-8(%rbp), %rax
	movl	-24(%rbp), %ecx
                                        ## kill: def $rcx killed $ecx
	movl	%edx, (%rax,%rcx,4)
	movl	-28(%rbp), %edx
	movq	-8(%rbp), %rax
	movl	-24(%rbp), %ecx
	addl	$1, %ecx
	movl	%ecx, %ecx
                                        ## kill: def $rcx killed $ecx
	movl	%edx, (%rax,%rcx,4)
	movl	$1, -20(%rbp)
	movq	_swaps(%rip), %rax
	addq	$1, %rax
	movq	%rax, _swaps(%rip)
LBB1_6:                                 ##   in Loop: Header=BB1_3 Depth=2
	jmp	LBB1_7
LBB1_7:                                 ##   in Loop: Header=BB1_3 Depth=2
	movl	-24(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -24(%rbp)
	jmp	LBB1_3
LBB1_8:                                 ##   in Loop: Header=BB1_1 Depth=1
	cmpl	$0, -20(%rbp)
	jne	LBB1_10
## %bb.9:
	jmp	LBB1_12
LBB1_10:                                ##   in Loop: Header=BB1_1 Depth=1
	jmp	LBB1_11
LBB1_11:                                ##   in Loop: Header=BB1_1 Depth=1
	movl	-16(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
	jmp	LBB1_1
LBB1_12:
	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	$42, %edi
	callq	_libmin_srand
	movl	$0, -8(%rbp)
LBB2_1:                                 ## =>This Inner Loop Header: Depth=1
	cmpl	$256, -8(%rbp)                  ## imm = 0x100
	jae	LBB2_4
## %bb.2:                               ##   in Loop: Header=BB2_1 Depth=1
	callq	_libmin_rand
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	movl	%eax, %ecx
	movq	_data@GOTPCREL(%rip), %rax
	movl	%edx, (%rax,%rcx,4)
## %bb.3:                               ##   in Loop: Header=BB2_1 Depth=1
	movl	-8(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8(%rbp)
	jmp	LBB2_1
LBB2_4:
	movq	_data@GOTPCREL(%rip), %rdi
	movl	$256, %esi                      ## imm = 0x100
	callq	_print_data
	movq	_data@GOTPCREL(%rip), %rdi
	movl	$256, %esi                      ## imm = 0x100
	callq	_bubblesort
	movq	_data@GOTPCREL(%rip), %rdi
	movl	$256, %esi                      ## imm = 0x100
	callq	_print_data
	movl	$0, -12(%rbp)
LBB2_5:                                 ## =>This Inner Loop Header: Depth=1
	cmpl	$255, -12(%rbp)
	jae	LBB2_10
## %bb.6:                               ##   in Loop: Header=BB2_5 Depth=1
	movl	-12(%rbp), %eax
	movl	%eax, %ecx
	movq	_data@GOTPCREL(%rip), %rax
	movl	(%rax,%rcx,4), %eax
	movl	-12(%rbp), %ecx
	addl	$1, %ecx
	movl	%ecx, %ecx
	movl	%ecx, %edx
	movq	_data@GOTPCREL(%rip), %rcx
	cmpl	(%rcx,%rdx,4), %eax
	jle	LBB2_8
## %bb.7:
	leaq	L_.str.2(%rip), %rdi
	movb	$0, %al
	callq	_libmin_printf
	movl	$-1, -4(%rbp)
	jmp	LBB2_11
LBB2_8:                                 ##   in Loop: Header=BB2_5 Depth=1
	jmp	LBB2_9
LBB2_9:                                 ##   in Loop: Header=BB2_5 Depth=1
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	LBB2_5
LBB2_10:
	movq	_swaps(%rip), %rsi
	leaq	L_.str.3(%rip), %rdi
	movb	$0, %al
	callq	_libmin_printf
	leaq	L_.str.4(%rip), %rdi
	movb	$0, %al
	callq	_libmin_printf
	callq	_libmin_success
	movl	$0, -4(%rbp)
LBB2_11:
	movl	-4(%rbp), %eax
	addq	$16, %rsp
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.globl	_swaps                          ## @swaps
.zerofill __DATA,__common,_swaps,8,3
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"DATA DUMP:\n"

L_.str.1:                               ## @.str.1
	.asciz	"  data[%u] = %d\n"

	.comm	_data,1024,4                    ## @data
L_.str.2:                               ## @.str.2
	.asciz	"ERROR: data is not properly sorted.\n"

L_.str.3:                               ## @.str.3
	.asciz	"INFO: %lu swaps executed.\n"

L_.str.4:                               ## @.str.4
	.asciz	"INFO: data is properly sorted.\n"

.subsections_via_symbols


ARM64 assembly:
	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_print_data                     ; -- Begin function print_data
	.p2align	2
_print_data:                            ; @print_data
	.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	w1, [x29, #-12]
	adrp	x0, l_.str@PAGE
	add	x0, x0, l_.str@PAGEOFF
	bl	_libmin_printf
	str	wzr, [sp, #16]
	b	LBB0_1
LBB0_1:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w8, [sp, #16]
	ldur	w9, [x29, #-12]
	subs	w8, w8, w9
	cset	w8, hs
	tbnz	w8, #0, LBB0_4
	b	LBB0_2
LBB0_2:                                 ;   in Loop: Header=BB0_1 Depth=1
	ldr	w8, [sp, #16]
                                        ; implicit-def: $x10
	mov	x10, x8
	ldur	x8, [x29, #-8]
	ldr	w9, [sp, #16]
                                        ; kill: def $x9 killed $w9
	ldr	w9, [x8, x9, lsl #2]
                                        ; implicit-def: $x8
	mov	x8, x9
	mov	x9, sp
	str	x10, [x9]
	str	x8, [x9, #8]
	adrp	x0, l_.str.1@PAGE
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_libmin_printf
	b	LBB0_3
LBB0_3:                                 ;   in Loop: Header=BB0_1 Depth=1
	ldr	w8, [sp, #16]
	add	w8, w8, #1
	str	w8, [sp, #16]
	b	LBB0_1
LBB0_4:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
	.cfi_endproc
                                        ; -- End function
	.globl	_bubblesort                     ; -- Begin function bubblesort
	.p2align	2
_bubblesort:                            ; @bubblesort
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #32
	.cfi_def_cfa_offset 32
	str	x0, [sp, #24]
	str	w1, [sp, #20]
	str	wzr, [sp, #16]
	b	LBB1_1
LBB1_1:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_3 Depth 2
	ldr	w8, [sp, #16]
	ldr	w9, [sp, #20]
	subs	w9, w9, #1
	subs	w8, w8, w9
	cset	w8, hs
	tbnz	w8, #0, LBB1_12
	b	LBB1_2
LBB1_2:                                 ;   in Loop: Header=BB1_1 Depth=1
	str	wzr, [sp, #12]
	str	wzr, [sp, #8]
	b	LBB1_3
LBB1_3:                                 ;   Parent Loop BB1_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ldr	w8, [sp, #8]
	ldr	w9, [sp, #20]
	subs	w9, w9, #1
	subs	w8, w8, w9
	cset	w8, hs
	tbnz	w8, #0, LBB1_8
	b	LBB1_4
LBB1_4:                                 ;   in Loop: Header=BB1_3 Depth=2
	ldr	x8, [sp, #24]
	ldr	w9, [sp, #8]
                                        ; kill: def $x9 killed $w9
	ldr	w8, [x8, x9, lsl #2]
	ldr	x9, [sp, #24]
	ldr	w10, [sp, #8]
	add	w10, w10, #1
	ldr	w9, [x9, w10, uxtw #2]
	subs	w8, w8, w9
	cset	w8, le
	tbnz	w8, #0, LBB1_6
	b	LBB1_5
LBB1_5:                                 ;   in Loop: Header=BB1_3 Depth=2
	ldr	x8, [sp, #24]
	ldr	w9, [sp, #8]
                                        ; kill: def $x9 killed $w9
	ldr	w8, [x8, x9, lsl #2]
	str	w8, [sp, #4]
	ldr	x9, [sp, #24]
	ldr	w10, [sp, #8]
	mov	w8, #1
	add	w10, w10, #1
	ldr	w9, [x9, w10, uxtw #2]
	ldr	x10, [sp, #24]
	ldr	w11, [sp, #8]
                                        ; kill: def $x11 killed $w11
	str	w9, [x10, x11, lsl #2]
	ldr	w9, [sp, #4]
	ldr	x10, [sp, #24]
	ldr	w11, [sp, #8]
	add	w11, w11, #1
	str	w9, [x10, w11, uxtw #2]
	str	w8, [sp, #12]
	adrp	x9, _swaps@PAGE
	ldr	x8, [x9, _swaps@PAGEOFF]
	add	x8, x8, #1
	str	x8, [x9, _swaps@PAGEOFF]
	b	LBB1_6
LBB1_6:                                 ;   in Loop: Header=BB1_3 Depth=2
	b	LBB1_7
LBB1_7:                                 ;   in Loop: Header=BB1_3 Depth=2
	ldr	w8, [sp, #8]
	add	w8, w8, #1
	str	w8, [sp, #8]
	b	LBB1_3
LBB1_8:                                 ;   in Loop: Header=BB1_1 Depth=1
	ldr	w8, [sp, #12]
	subs	w8, w8, #0
	cset	w8, ne
	tbnz	w8, #0, LBB1_10
	b	LBB1_9
LBB1_9:
	b	LBB1_12
LBB1_10:                                ;   in Loop: Header=BB1_1 Depth=1
	b	LBB1_11
LBB1_11:                                ;   in Loop: Header=BB1_1 Depth=1
	ldr	w8, [sp, #16]
	add	w8, w8, #1
	str	w8, [sp, #16]
	b	LBB1_1
LBB1_12:
	add	sp, sp, #32
	ret
	.cfi_endproc
                                        ; -- End function
	.globl	_main                           ; -- Begin function main
	.p2align	2
_main:                                  ; @main
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.cfi_def_cfa_offset 64
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	adrp	x8, _data@GOTPAGE
	ldr	x8, [x8, _data@GOTPAGEOFF]
	str	x8, [sp, #24]                   ; 8-byte Folded Spill
	stur	wzr, [x29, #-4]
	mov	w0, #42
	bl	_libmin_srand
	stur	wzr, [x29, #-8]
	b	LBB2_1
LBB2_1:                                 ; =>This Inner Loop Header: Depth=1
	ldur	w8, [x29, #-8]
	subs	w8, w8, #256
	cset	w8, hs
	tbnz	w8, #0, LBB2_4
	b	LBB2_2
LBB2_2:                                 ;   in Loop: Header=BB2_1 Depth=1
	bl	_libmin_rand
	ldr	x8, [sp, #24]                   ; 8-byte Folded Reload
	ldur	w9, [x29, #-8]
                                        ; kill: def $x9 killed $w9
	str	w0, [x8, x9, lsl #2]
	b	LBB2_3
LBB2_3:                                 ;   in Loop: Header=BB2_1 Depth=1
	ldur	w8, [x29, #-8]
	add	w8, w8, #1
	stur	w8, [x29, #-8]
	b	LBB2_1
LBB2_4:
	ldr	x0, [sp, #24]                   ; 8-byte Folded Reload
	mov	w1, #256
	str	w1, [sp, #20]                   ; 4-byte Folded Spill
	bl	_print_data
	ldr	x0, [sp, #24]                   ; 8-byte Folded Reload
	ldr	w1, [sp, #20]                   ; 4-byte Folded Reload
	bl	_bubblesort
	ldr	x0, [sp, #24]                   ; 8-byte Folded Reload
	ldr	w1, [sp, #20]                   ; 4-byte Folded Reload
	bl	_print_data
	stur	wzr, [x29, #-12]
	b	LBB2_5
LBB2_5:                                 ; =>This Inner Loop Header: Depth=1
	ldur	w8, [x29, #-12]
	subs	w8, w8, #255
	cset	w8, hs
	tbnz	w8, #0, LBB2_10
	b	LBB2_6
LBB2_6:                                 ;   in Loop: Header=BB2_5 Depth=1
	ldr	x9, [sp, #24]                   ; 8-byte Folded Reload
	ldur	w8, [x29, #-12]
                                        ; kill: def $x8 killed $w8
	ldr	w8, [x9, x8, lsl #2]
	ldur	w10, [x29, #-12]
	add	w10, w10, #1
	ldr	w9, [x9, w10, uxtw #2]
	subs	w8, w8, w9
	cset	w8, le
	tbnz	w8, #0, LBB2_8
	b	LBB2_7
LBB2_7:
	adrp	x0, l_.str.2@PAGE
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_libmin_printf
	mov	w8, #-1
	stur	w8, [x29, #-4]
	b	LBB2_11
LBB2_8:                                 ;   in Loop: Header=BB2_5 Depth=1
	b	LBB2_9
LBB2_9:                                 ;   in Loop: Header=BB2_5 Depth=1
	ldur	w8, [x29, #-12]
	add	w8, w8, #1
	stur	w8, [x29, #-12]
	b	LBB2_5
LBB2_10:
	adrp	x8, _swaps@PAGE
	ldr	x8, [x8, _swaps@PAGEOFF]
	mov	x9, sp
	str	x8, [x9]
	adrp	x0, l_.str.3@PAGE
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_libmin_printf
	adrp	x0, l_.str.4@PAGE
	add	x0, x0, l_.str.4@PAGEOFF
	bl	_libmin_printf
	bl	_libmin_success
	stur	wzr, [x29, #-4]
	b	LBB2_11
LBB2_11:
	ldur	w0, [x29, #-4]
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #64
	ret
	.cfi_endproc
                                        ; -- End function
	.globl	_swaps                          ; @swaps
.zerofill __DATA,__common,_swaps,8,3
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"DATA DUMP:\n"

l_.str.1:                               ; @.str.1
	.asciz	"  data[%u] = %d\n"

	.comm	_data,1024,2                    ; @data
l_.str.2:                               ; @.str.2
	.asciz	"ERROR: data is not properly sorted.\n"

l_.str.3:                               ; @.str.3
	.asciz	"INFO: %lu swaps executed.\n"

l_.str.4:                               ; @.str.4
	.asciz	"INFO: data is properly sorted.\n"

.subsections_via_symbols