Skip to content

Instantly share code, notes, and snippets.

@simonwhitaker
Created December 5, 2013 22:01
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 simonwhitaker/7814762 to your computer and use it in GitHub Desktop.
Save simonwhitaker/7814762 to your computer and use it in GitHub Desktop.
$ cat test.c
#import <stdio.h>
#define NYBBLE 4
int main(int argc, const char * argv[]) {
unsigned long t = (unsigned long)argc;
t = (t << NYBBLE) | (t >> (sizeof(t) * 8 - NYBBLE));
printf("t is now 0x%lx\n", t);
return 0;
}
$ clang -S -O1 -o - test.c
.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
movslq %edi, %rsi
rolq $4, %rsi
leaq L_.str(%rip), %rdi
xorb %al, %al
callq _printf
xorl %eax, %eax
popq %rbp
ret
.cfi_endproc
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "t is now 0x%lx\n"
.subsections_via_symbols
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment