Clarification on the script P2SH, how is executed to Bitcoin core? This question is a continuation of the my post yesterday.

Today I have a question on P2SH execution so, an example of the script should be this

OP_0 &lt;A Signature&gt; &lt;B Signature&gt; OP_2 &lt;Public key A&gt; &lt;Public key B&gt; 
&lt;Public key C&gt; OP_3 OP_CHECKMULTISIG
OP_HASH160 &lt;ScriptSig Hash&gt; OP_EQUAL


or if used the P2SH key should be is this (I think in this script left-hand something to convert the hash160 inside the P2SH key, right?)

OP_0 &lt;A Signature&gt; &lt;B Signature&gt; OP_2 &lt;Public key A&gt; &lt;Public key B&gt; 
&lt;Public key C&gt; OP_3 OP_CHECKMULTISIG
OP_HASH160 &lt;P2SH key&gt; OP_EQUAL


Now if I have understood well the simulation of the execution is divided into two phases


The hash scriptSig is equal to hash inside the scriptPubKey


Simulation


Put on the scriptSig on the stack, so the stack now is &lt;A sig&gt; &lt;B sig&gt; &lt;A pubkey&gt; &lt;B pubkey&gt; &lt;C pubkey&gt; 
Calculate the hash160 with the data inside the stack, so now the stack status is &lt;scriptSig hash&gt;
Put on the scriptSig hash expected, now the stack status is &lt;hash scriptsig&gt; &lt;hash scriptsigexpected&gt;
return the result of the operator OP_EQUAL (true or false)





the scriptSig will execute such as the script multi-signature


Simulation


put on the stack the scriptSig, the stack status is &lt;A Signature&gt; &lt;B Signature&gt;
push the public keys, that stack status is &lt;A Signature&gt; &lt;B Signature&gt; &lt;Public key A&gt; &lt;Public key B&gt; &lt;Public key C&gt;
apply the OP_CHECKMULTISIG operator and get the result


My questions are:


With the P2SH key, the execution is the same? if not, what is the form of the P2SH with the P2SH key?


Also, I read this post but I don't think contains this answer.

If my example script is wrong, I'm sorry to give me a corrections
Let's go over this step by step. Suppose say you want to lock some bitcoins in a 2-of-3 multi-sig.

Locking steps  


Create a multi-sig script: OP_2 &lt;pub_key 1&gt; &lt;pub_key2&gt; &lt;pub_key3&gt; OP_3 OP_CHECKMULTISIG.
Hash the multi-sig script with HASH160 which gives you multi-sig_scripthash.
Base58Check the multi-sig_scripthash with version 0x05 giving you an address starting with 3....
The scriptPubKey will be OP_HASH160 &lt;multi-sig_scripthash&gt; OP_EQUAL.


Unlocking Steps  


Your stack will start at &lt;signatures&gt;&lt;redeemScript&gt;. The signature is OP_0 &lt;sig_A&gt; &lt;sig_B&gt; and redeemScript is OP_2 &lt;pub_key 1&gt; &lt;pub_key2&gt; &lt;pub_key3&gt; OP_3 OP_CHECKMULTISIG.
Since v0.3.7, Bitcoin Core executes the unlocking script first and looks at the resulting stack. So your &lt;signatures&gt; and &lt;redeemScript&gt; are evaluated together first. This would result in a multi-signature evaluation.
In normal cases the above step should just return 1 as signatures satisfy the redeemScript. But with P2SH there is a caveat added by BIP-16. Whenever you have a OP_HASH160 &lt;hash&gt; OP_EQUAL locking script, it serves as a P2SH identifier. So before the evaluation of &lt;signatures&gt; with &lt;redeemScript&gt; the redeemScript is copied from the stack to another one. Then the evaluation is done with what is on stack (&lt;signatures&gt;&lt;redeemScript&gt; in our case). If successful, replace the current stack with the just redeemScript. Hence, instead of 1 you have &lt;redeemScript&gt; at the top of the stack.
You run OP_HASH160 on the redeemScript. Stack is now &lt;hash160_of_redeemScript&gt;
You push &lt;expectedredeemScripthash&gt;. Stack is now &lt;hash160_of_redeemScript&gt;&lt;expectedredeemScripthash&gt;
You run OP_EQUAL resulting in evaluation and returning 1 to the top of the stack.