__attribute__((no, noclone)) signed __int128 t116_4mul(signed __int128 x) {
  unsigned __int128 y =
      ((unsigned __int128)((
           signed __int128)(((unsigned __int128)1 << (16 * 8 - 1)) - 1)) +
       2);
  signed __int128 r;
  if (__builtin_mul_overflow(x, y, &r))
    bar();
  return r;
}


x86 assembly (clang, -O0):
<t116_4mul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
movabs $0x8000000000000000,%rax
mov    %rax,-0x38(%rbp)
movq   $0x1,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%r8
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%rdx
mov    %rdx,-0x70(%rbp)
mov    %r8,%rsi
sar    $0x3f,%rsi
add    %rsi,%rdi
mov    %r8,%rax
adc    %rsi,%rax
xor    %rsi,%rdi
mov    %rdi,-0x68(%rbp)
xor    %rsi,%rax
test   %rax,%rax
setne  %dil
test   %rdx,%rdx
setne  %dl
and    %dl,%dil
mul    %rcx
mov    -0x68(%rbp),%rdx
mov    %rax,%rsi
mov    -0x70(%rbp),%rax
seto   %r9b
or     %r9b,%dil
mul    %rdx
mov    %rax,%rdx
mov    -0x68(%rbp),%rax
seto   %r9b
or     %r9b,%dil
mov    %dil,-0x59(%rbp)
add    %rdx,%rsi
mul    %rcx
mov    %rax,%rcx
mov    -0x59(%rbp),%al
mov    %rcx,-0x58(%rbp)
mov    %rdx,%rcx
mov    -0x58(%rbp),%rdx
add    %rsi,%rcx
setb   %sil
or     %sil,%al
mov    %r8,%r9
shr    $0x3f,%r9
xor    %esi,%esi
add    $0xffffffffffffffff,%r9
mov    %esi,%edi
movabs $0x7fffffffffffffff,%r10
ff ff 7f
mov    %rdi,%rsi
adc    %r10,%rsi
sub    %rdx,%r9
sbb    %rcx,%rsi
setb   %sil
or     %sil,%al
mov    %rdx,%rsi
neg    %rsi
sbb    %rcx,%rdi
test   %r8,%r8
cmovs  %rdi,%rcx
cmovs  %rsi,%rdx
mov    %rdx,-0x50(%rbp)
mov    %rcx,-0x48(%rbp)
test   $0x1,%al
jne    1224 <t116_4mul+0x114>
jmp    122b <t116_4mul+0x11b>
mov    $0x0,%al
call   1030 <bar@plt>
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rdx
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t116_4mul>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rax
sar    $0x3f,%rax
add    %rax,%rdi
mov    %rsi,%rcx
adc    %rax,%rcx
xor    %rax,%rcx
xor    %rax,%rdi
movabs $0x8000000000000000,%rdx
mov    %rdi,%rax
mul    %rdx
seto   %dl
test   %rcx,%rcx
setne  %r8b
or     %dl,%r8b
add    %rcx,%rax
mov    %rsi,%rcx
shr    $0x3f,%rcx
xor    %ebx,%ebx
add    $0xffffffffffffffff,%rcx
movabs $0x7fffffffffffffff,%rdx
ff ff 7f
adc    %rbx,%rdx
mov    %rdi,%r14
neg    %r14
sbb    %rax,%rbx
test   %rsi,%rsi
cmovns %rax,%rbx
cmovns %rdi,%r14
test   %r8b,%r8b
jne    1185 <t116_4mul+0x75>
cmp    %rdi,%rcx
sbb    %rax,%rdx
jae    118c <t116_4mul+0x7c>
xor    %eax,%eax
call   1030 <bar@plt>
mov    %r14,%rax
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define { i64, i64 } @t116_4mul(i64 %0, i64 %1) {
%3 = alloca i128
%4 = alloca i128
%5 = alloca i128
%6 = alloca i128
%7 = alloca i128
%8 = bitcast i128* %4 to { i64, i64 }*
%9 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %8, i32 0, i32 0
store i64 %0, i64* %9
%10 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %8, i32 0, i32 1
store i64 %1, i64* %10
%11 = load i128, i128* %4
store i128 %11, i128* %5
store i128 -170141183460469231731687303715884105727, i128* %6
%12 = load i128, i128* %5
%13 = load i128, i128* %6
%14 = icmp slt i128 %12, 0
%15 = sub i128 0, %12
%16 = select i1 %14, i128 %15, i128 %12
%17 = call { i128, i1 } @llvm.umul.with.overflow.i128(i128 %16, i128 %13)
%18 = extractvalue { i128, i1 } %17, 1
%19 = extractvalue { i128, i1 } %17, 0
%20 = zext i1 %14 to i128
%21 = add i128 170141183460469231731687303715884105727, %20
%22 = icmp ugt i128 %19, %21
%23 = or i1 %18, %22
%24 = sub i128 0, %19
%25 = select i1 %14, i128 %24, i128 %19
store i128 %25, i128* %7
br i1 %23, label %26, label %28
26: ; preds = %2
%27 = call i32 (...) @bar()
br label %28
28: ; preds = %26, %2
%29 = load i128, i128* %7
store i128 %29, i128* %3
%30 = bitcast i128* %3 to { i64, i64 }*
%31 = load { i64, i64 }, { i64, i64 }* %30
ret { i64, i64 } %31
}

LLVM IR (-O2):
define { i64, i64 } @t116_4mul(i64 %0, i64 %1) {
%3 = zext i64 %1 to i128
%4 = shl nuw i128 %3, 64
%5 = zext i64 %0 to i128
%6 = or i128 %4, %5
%7 = icmp slt i128 %6, 0
%8 = sub i128 0, %6
%9 = select i1 %7, i128 %8, i128 %6
%10 = tail call { i128, i1 } @llvm.umul.with.overflow.i128(i128 %9, i128 -170141183460469231731687303715884105727)
%11 = extractvalue { i128, i1 } %10, 1
%12 = extractvalue { i128, i1 } %10, 0
%13 = lshr i128 %3, 63
%14 = add nuw i128 %13, 170141183460469231731687303715884105727
%15 = icmp ugt i128 %12, %14
%16 = or i1 %11, %15
%17 = sub i128 0, %12
%18 = select i1 %7, i128 %17, i128 %12
br i1 %16, label %19, label %21
19: ; preds = %2
%20 = tail call i32 (...) @bar()
br label %21
21: ; preds = %19, %2
%22 = trunc i128 %18 to i64
%23 = lshr i128 %18, 64
%24 = trunc i128 %23 to i64
%25 = insertvalue { i64, i64 } poison, i64 %22, 0
%26 = insertvalue { i64, i64 } %25, i64 %24, 1
ret { i64, i64 } %26
}