Skip to content

Instantly share code, notes, and snippets.

@rf
Created October 24, 2013 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rf/7145044 to your computer and use it in GitHub Desktop.
Save rf/7145044 to your computer and use it in GitHub Desktop.
$ cat thing.s
.section __TEXT,__text,regular,pure_instructions
.globl _main
.align 4, 0x90
_main: ## @main
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp2:
.cfi_def_cfa_offset 16
Ltmp3:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp4:
.cfi_def_cfa_register %rbp
leaq L_.str(%rip), %rdi
movl $8, %esi
movl $8, %edx
xorb %al, %al
callq _printf
xorl %eax, %eax
popq %rbp
ret
.cfi_endproc
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "%d, %d\n"
.subsections_via_symbols
$ cat thing.c
#include <stdio.h>
#include <math.h>
int
main (void) {
int a, b, c = 4;
a = pow(c, 2) - (3*c) + 4;
b = (c * (c - 3)) + 4;
printf("%d, %d\n", a, b);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment