package amd64

import (
	
	
	

	
)

func stackView(,  uintptr) []byte {
	 := int( - )
	var  []byte
	{
		//nolint:staticcheck
		 := (*reflect.SliceHeader)(unsafe.Pointer(&))
		.Data = 
		.Len = 
		.Cap = 
	}
	return 
}

// UnwindStack implements wazevo.unwindStack.
func (, ,  uintptr,  []uintptr) []uintptr {
	 := stackView(, )

	for  := uint64(0);  < uint64(len()); {
		//       (high address)
		//    +-----------------+
		//    |     .......     |
		//    |      ret Y      |
		//    |     .......     |
		//    |      ret 0      |
		//    |      arg X      |
		//    |     .......     |
		//    |      arg 1      |
		//    |      arg 0      |
		//    |  ReturnAddress  |
		//    |   Caller_RBP    |
		//    +-----------------+ <---- Caller_RBP
		//    |   ...........   |
		//    |   clobbered  M  |
		//    |   ............  |
		//    |   clobbered  0  |
		//    |   spill slot N  |
		//    |   ............  |
		//    |   spill slot 0  |
		//    |  ReturnAddress  |
		//    |   Caller_RBP    |
		//    +-----------------+ <---- RBP
		//       (low address)

		 := binary.LittleEndian.Uint64([:])
		 := binary.LittleEndian.Uint64([+8:])
		 = append(, uintptr())
		 =  - uint64()
		if len() == wasmdebug.MaxFrames {
			break
		}
	}
	return 
}

// GoCallStackView implements wazevo.goCallStackView.
func ( *uint64) []uint64 {
	//                  (high address)
	//              +-----------------+ <----+
	//              |   xxxxxxxxxxx   |      | ;; optional unused space to make it 16-byte aligned.
	//           ^  |  arg[N]/ret[M]  |      |
	// sliceSize |  |  ............   |      | SizeInBytes/8
	//           |  |  arg[1]/ret[1]  |      |
	//           v  |  arg[0]/ret[0]  | <----+
	//              |   SizeInBytes   |
	//              +-----------------+ <---- stackPointerBeforeGoCall
	//                 (low address)
	 := unsafe.Add(unsafe.Pointer(), 8)
	 := * / 8
	return unsafe.Slice((*uint64)(), )
}

func (, , , ,  uintptr) {
	 := uint64( - )

	 := stackView(, )
	for  := uint64(0);  < uint64(len()); {
		//       (high address)
		//    +-----------------+
		//    |     .......     |
		//    |      ret Y      |
		//    |     .......     |
		//    |      ret 0      |
		//    |      arg X      |
		//    |     .......     |
		//    |      arg 1      |
		//    |      arg 0      |
		//    |  ReturnAddress  |
		//    |   Caller_RBP    |
		//    +-----------------+ <---- Caller_RBP
		//    |   ...........   |
		//    |   clobbered  M  |
		//    |   ............  |
		//    |   clobbered  0  |
		//    |   spill slot N  |
		//    |   ............  |
		//    |   spill slot 0  |
		//    |  ReturnAddress  |
		//    |   Caller_RBP    |
		//    +-----------------+ <---- RBP
		//       (low address)

		 := binary.LittleEndian.Uint64([:])
		if  == 0 {
			// End of stack.
			break
		}
		if  := int64();  < int64() ||  >= int64() {
			panic("BUG: callerRBP is out of range")
		}
		if int() < 0 {
			panic("BUG: callerRBP is negative")
		}
		 :=  + 
		if int() < 0 {
			panic("BUG: adjustedCallerRBP is negative")
		}
		binary.LittleEndian.PutUint64([:], )
		 =  - uint64()
	}
}