As always, **compiler options matter**. That source code with `gcc -Og` (optimize for debugging) [produces very similar asm to your listing][1] (the cast sign-extends both operands to 128-bit before doing a full 128x128 => 128-bit multiply). This is a naive implementation of exactly what the C standard says should happen (integer precedence rules for converting both operands to the same type).
If you're going to talk about compiler output, you should always say which version of which compiler with what options. Or just post a link to it on [godbolt][2], like the one above. (Edit: oops, source and asm were from a book that didn't give that info. And if that's the global edition of CS:APP 3e, beware that [the practice problems are filled with errors][3] in the global edition.)
With `gcc -O3` or `-O2`, GCC takes advantage of the fact that both operands are still really only 64bit, [so a single `imul` is enough][4]. (This still produces the same result for every input, and thus still implements the C logic, per the as-if rule. C doesn't have widening operations so you're forced to write the source in an "inefficient" way that depends on the compiler to transform it into efficient asm.)
---
The `sar $63, %rcx` is part of sign-extending `rsi` into `rcx:rsi`, just like `cqto` sign-extends `rax` into `rdx:rax`. It replaces every bit of RCX with a copy of the original sign bit.
---
Most of this answer was already given by other people in comments, but I don't think anyone else noticed that `gcc -Og` / `-O1` gives almost exactly that asm output.
[1]:
[To see links please register here]
:'0',j:1,lang:c%2B%2B,source:'%23include+%3Cstdint.h%3E%0A%0Avoid+store_prod(__int128+*dest,+int64_t+x,+int64_t+y)+%7B%0A++++*dest+%3D+x+*+(__int128)y%3B%0A%7D'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:g520,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'1',libraryCode:'0',trim:'1'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-Wall+-Og+-fverbose-asm+-march%3Dhaswell',selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'x86-64+gcc+5.2+(Editor+%231,+Compiler+%231)+C%2B%2B',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4
[2]:
[To see links please register here]
[3]:
[To see links please register here]
[4]:
[To see links please register here]
:'0',j:1,lang:c%2B%2B,source:'%23include+%3Cstdint.h%3E%0A%0Avoid+store_prod(__int128+*dest,+int64_t+x,+int64_t+y)+%7B%0A++++*dest+%3D+x+*+(__int128)y%3B%0A%7D'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:g520,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'1',libraryCode:'0',trim:'1'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-Wall+-O3+-fverbose-asm+-march%3Dhaswell',selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'x86-64+gcc+5.2+(Editor+%231,+Compiler+%231)+C%2B%2B',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4