Skip to content

Instantly share code, notes, and snippets.

@purplejacket
Created June 16, 2023 23:33
Show Gist options
  • Save purplejacket/df7a119d7a067a2f64d5a1e791b52f9e to your computer and use it in GitHub Desktop.
Save purplejacket/df7a119d7a067a2f64d5a1e791b52f9e to your computer and use it in GitHub Desktop.
zig cc -S -g0 sort2.c -o sort2.g0.s
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 13, 1 sdk_version 13, 1
.globl _variable_sort_2 ## -- Begin function variable_sort_2
.p2align 4, 0x90
_variable_sort_2: ## @variable_sort_2
.cfi_startproc
## %bb.0:
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
movl %edi, -4(%rbp)
movq %rsi, -16(%rbp)
cmpl $2, -4(%rbp)
jne LBB0_28
## %bb.1:
movq -16(%rbp), %rax
movq %rax, -32(%rbp) ## 8-byte Spill
testq %rax, %rax
setne %al
movb $1, %cl
andb $-1, %cl
andb %cl, %al
testb $1, %al
jne LBB0_3
## %bb.2:
ud1l 19(%eax), %eax
LBB0_3:
movq -32(%rbp), %rcx ## 8-byte Reload
cmpq $0, %rcx
setne %al
andq $3, %rcx
cmpq $0, %rcx
sete %cl
andb %cl, %al
testb $1, %al
jne LBB0_5
## %bb.4:
ud1l 22(%eax), %eax
LBB0_5:
movq -32(%rbp), %rax ## 8-byte Reload
movl (%rax), %eax
movl %eax, -44(%rbp) ## 4-byte Spill
movq -16(%rbp), %rdx
testq %rdx, %rdx
setne %al
movq %rdx, %rcx
addq $4, %rcx
movq %rcx, -40(%rbp) ## 8-byte Spill
setne %sil
andb %sil, %al
subq %rdx, %rcx
setae %cl
andb $-1, %cl
andb %cl, %al
testb $1, %al
jne LBB0_7
## %bb.6:
ud1l 19(%eax), %eax
LBB0_7:
movq -40(%rbp), %rcx ## 8-byte Reload
cmpq $0, %rcx
setne %al
andq $3, %rcx
cmpq $0, %rcx
sete %cl
andb %cl, %al
testb $1, %al
jne LBB0_9
## %bb.8:
ud1l 22(%eax), %eax
LBB0_9:
movl -44(%rbp), %eax ## 4-byte Reload
movq -40(%rbp), %rcx ## 8-byte Reload
cmpl (%rcx), %eax
jle LBB0_27
## %bb.10:
movq -16(%rbp), %rax
movq %rax, -56(%rbp) ## 8-byte Spill
testq %rax, %rax
setne %al
movb $1, %cl
andb $-1, %cl
andb %cl, %al
testb $1, %al
jne LBB0_12
## %bb.11:
ud1l 19(%eax), %eax
LBB0_12:
movq -56(%rbp), %rcx ## 8-byte Reload
cmpq $0, %rcx
setne %al
andq $3, %rcx
cmpq $0, %rcx
sete %cl
andb %cl, %al
testb $1, %al
jne LBB0_14
## %bb.13:
ud1l 22(%eax), %eax
LBB0_14:
movq -56(%rbp), %rax ## 8-byte Reload
movl (%rax), %eax
movl %eax, -20(%rbp)
movq -16(%rbp), %rdx
testq %rdx, %rdx
setne %al
movq %rdx, %rcx
addq $4, %rcx
movq %rcx, -64(%rbp) ## 8-byte Spill
setne %sil
andb %sil, %al
subq %rdx, %rcx
setae %cl
andb $-1, %cl
andb %cl, %al
testb $1, %al
jne LBB0_16
## %bb.15:
ud1l 19(%eax), %eax
LBB0_16:
movq -64(%rbp), %rcx ## 8-byte Reload
cmpq $0, %rcx
setne %al
andq $3, %rcx
cmpq $0, %rcx
sete %cl
andb %cl, %al
testb $1, %al
jne LBB0_18
## %bb.17:
ud1l 22(%eax), %eax
LBB0_18:
movq -64(%rbp), %rax ## 8-byte Reload
movl (%rax), %eax
movl %eax, -76(%rbp) ## 4-byte Spill
movq -16(%rbp), %rax
movq %rax, -72(%rbp) ## 8-byte Spill
testq %rax, %rax
setne %al
movb $1, %cl
andb $-1, %cl
andb %cl, %al
testb $1, %al
jne LBB0_20
## %bb.19:
ud1l 19(%eax), %eax
LBB0_20:
movq -72(%rbp), %rcx ## 8-byte Reload
cmpq $0, %rcx
setne %al
andq $3, %rcx
cmpq $0, %rcx
sete %cl
andb %cl, %al
testb $1, %al
jne LBB0_22
## %bb.21:
ud1l 22(%eax), %eax
LBB0_22:
movq -72(%rbp), %rax ## 8-byte Reload
movl -76(%rbp), %ecx ## 4-byte Reload
movl %ecx, (%rax)
movl -20(%rbp), %eax
movl %eax, -92(%rbp) ## 4-byte Spill
movq -16(%rbp), %rdx
testq %rdx, %rdx
setne %al
movq %rdx, %rcx
addq $4, %rcx
movq %rcx, -88(%rbp) ## 8-byte Spill
setne %sil
andb %sil, %al
subq %rdx, %rcx
setae %cl
andb $-1, %cl
andb %cl, %al
testb $1, %al
jne LBB0_24
## %bb.23:
ud1l 19(%eax), %eax
LBB0_24:
movq -88(%rbp), %rcx ## 8-byte Reload
cmpq $0, %rcx
setne %al
andq $3, %rcx
cmpq $0, %rcx
sete %cl
andb %cl, %al
testb $1, %al
jne LBB0_26
## %bb.25:
ud1l 22(%eax), %eax
LBB0_26:
movq -88(%rbp), %rax ## 8-byte Reload
movl -92(%rbp), %ecx ## 4-byte Reload
movl %ecx, (%rax)
LBB0_27:
jmp LBB0_28
LBB0_28:
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)
xorl %edi, %edi
leaq _a0(%rip), %rsi
callq _variable_sort_2
xorl %eax, %eax
addq $16, %rsp
popq %rbp
retq
.cfi_endproc
## -- End function
.section __TEXT,__cstring,cstring_literals
L_.src: ## @.src
.asciz "sort2.c"
.section __TEXT,__const
.p2align 3 ## @0
l___unnamed_1:
.short 0 ## 0x0
.short 11 ## 0xb
.asciz "'int'"
.zerofill __DATA,__bss,_a0,1,2 ## @a0
.subsections_via_symbols
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment