3.72

/*
 * 3.72.c
 */

#include <alloca.h>

long aframe(long n, long idx, long *q) {
  long i;
  long **p = alloca(n * sizeof(long*));
  p[0] = &i;
  for (i = 1; i < n; i++) {
    p[i] = q;
  }
  return *p[idx];
}
# long aframe(long n, long idx, long *q)
# n in %rdi, idx in %rsi, q in %rdx
aframe:
  pushq %rbp
  movq %rsp, %rbp
  subq $16, %rsp
  leaq 30(,%rdi,8), %rax
  andq $-16, %rax
  subq %rax, %rsp
  leaq 15(%rsp), %r8
  andq $-16, %r8

A.

when n is odd

when n is even

B.

the least multiple of 16 that greater than s2

C.

whiche1ns1
least1evenn%16==1
greatest24oddn%16==0

least:

e1 can’t be 0, if e1 == 0, p should equal to s2

when n is even, e1 + e2 == 16, if e2 is 15, e1 will be least that can reach, so s1 == n that n%16==1

greatest:

when n is odd, e1 + e2 == 24. if p == s2, e2 == 0, so e1 will be the greatest value 24 that can reach. s1 == n that n%16 == 0

D.

p is aligned by 16

s2 is the least multiple of 16 that preserve 8*n size space

comments powered by Disqus