Skip to content

Instantly share code, notes, and snippets.

@blubberdiblub
Created February 14, 2018 14:35
Show Gist options
  • Save blubberdiblub/2e1424a1c59ca4baaf1dcaa9ae932fda to your computer and use it in GitHub Desktop.
Save blubberdiblub/2e1424a1c59ca4baaf1dcaa9ae932fda to your computer and use it in GitHub Desktop.
((struct dirent *)d)->d_name handling in a boolean context
# foobar.c:13: result = (d && d->d_name);
cmpq $0, -24(%rbp) #, d
je .L2 #,
# foobar.c:13: result = (d && d->d_name);
movq -24(%rbp), %rax # d, tmp91
addq $19, %rax #, _1
testq %rax, %rax # _1
je .L2 #,
# foobar.c:13: result = (d && d->d_name);
movl $1, %eax #, iftmp.0_2
jmp .L3 #
.L2:
# foobar.c:13: result = (d && d->d_name);
movl $0, %eax #, iftmp.0_2
.L3:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment