class B {
public: 
  int b1;
  int b2;
};

class F {
public: 
  int f1;
  int f2;
};

class D : public B, public F {
public: 
  int d1;
  int d2;
};

D *d = new D ();
d->d1 = 1419;
d->d2 = 7292;
d->f1 = 9032;
d->f2 = 3293;
d->b1 = 2948;
d->b2 = 8432;
B *b = d;
int x1 = b->b1;
int x2 = b->b2;
F *f = d;
int y1 = f->f1;
int y2 = f->f2;
              

; d->d1 = 1419;
movq	-8(%rbp), %rax  ; load d into rax
movl	$1419, 16(%rax) ; write 1419 into d1, 16 bytes off of rax
; d->d2 = 7292;
movq	-8(%rbp), %rax
movl	$7292, 20(%rax)
; d->f1 = 9032;
movq	-8(%rbp), %rax
movl	$9032, 8(%rax)
; d->f2 = 3293;
movq	-8(%rbp), %rax
movl	$3293, 12(%rax)
; d->b1 = 2948;
movq	-8(%rbp), %rax
movl	$2948, (%rax)
; d->b2 = 8432;
movq	-8(%rbp), %rax
movl	$8432, 4(%rax)

; B *b = (B*) d
movq	-8(%rbp), %rax  ; load d into rax
movq	%rax, -16(%rbp) ; copy rax into b

; int x1 = b->b1
movq	-16(%rbp), %rax ; load b into rax
movl	(%rax), %eax    ; copy b1, at 0 bytes off of rax, into eax
movl	%eax, -20(%rbp) ; copy eax into x1, at -20 bytes off of rbp

; int x2 = b->b2
movq	-16(%rbp), %rax
movl	4(%rax), %eax
movl	%eax, -24(%rbp)

; F *f = (F*) d
; null handling omitted 
movq	-8(%rbp), %rax  ; load d into rax
addq	$8, %rax        ; shift rax to start of F
movq	%rax, -32(%rbp) ; copy rax into f, at -32 bytes off of rbp

; int y1 = f->f1
movq	-32(%rbp), %rax ; load f into rax
movl	(%rax), %eax    ; copy f1, at 0 bytes off of f, into eax
movl	%eax, -36(%rbp) ; copy eax into y1, at -36 bytes off of rbp

; int y2 = f->f2
movq	-32(%rbp), %rax
movl	4(%rax), %eax
movl	%eax, -40(%rbp)
              
Layout of Stack
Offset Contents
-8(%rbp) local variable D *d
-16(%rbp) local variable B *b
-20(%rbp) local variable int x1
-24(%rbp) local variable int x2
-32(%rbp) local variable F *f
-36(%rbp) local variable int y1
-40(%rbp) local variable int y2

Layout of Instance of D
Offset Name Contents
20 d2 7292
16 d1 1419
12 f2 3293
8 f1 9032
4 b2 8432
0 b1 2948