I ask this because Pharoah at first is not called by this title.
39:20 - Potiphar " gave [Joseph] over to ... the place where the prisoners of the KING were kept."
40:1 - " ...the cupbearer of the KING of Egypt and the baker sinned against their lord the KING of Egypt."
Only at 40:2 does the copyist start using the term Pharoah.
I also note that Joseph refers to his home as "the land of the Hebrews".I wonder if the original omitted 39:7 - 20 and continues at 39:21, as this portion at v23 chimes with 39:6.
If Potiphar, the chief officer of the bodyguard was also in charge of the prison, (and 40:3 says so) it may back up my question.
I also think 40:1 is added from another source. Unfortunately, my commentary does not discuss this use of the word "king" in this passage, and I don't know if it is a later word for ruler, as opposed to the petty tribal chiefs called "kings" that Abraham dealt with.
I suspect it is another nice moral tale the Jews discovered in Babylon, along with Susannah and the elders.
HB