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


x86 assembly (clang, -O0):
<t108_2mul>:
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 $0x421084210842108,%rax
08 21 04
mov    %rax,-0x38(%rbp)
movabs $0x4210842108421084,%rax
84 10 42
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rdx
mov    %rdx,-0x68(%rbp)
test   %rdx,%rdx
setne  %dl
test   %rax,%rax
setne  %dil
and    %dl,%dil
mul    %rcx
mov    -0x60(%rbp),%rdx
mov    %rax,%rsi
mov    -0x68(%rbp),%rax
seto   %r8b
or     %r8b,%dil
mul    %rdx
mov    %rax,%rdx
mov    -0x60(%rbp),%rax
seto   %r8b
or     %r8b,%dil
mov    %dil,-0x51(%rbp)
add    %rdx,%rsi
mul    %rcx
mov    %rax,%rcx
mov    -0x51(%rbp),%al
add    %rsi,%rdx
setb   %sil
or     %sil,%al
test   %rdx,%rdx
sets   %sil
or     %sil,%al
mov    %rcx,-0x50(%rbp)
mov    %rdx,-0x48(%rbp)
test   $0x1,%al
jne    11d3 <t108_2mul+0xc3>
jmp    11da <t108_2mul+0xca>
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):
<t108_2mul>:
push   %r14
push   %rbx
push   %rax
movabs $0x4210842108421084,%r8
84 10 42
mov    %rsi,%rax
mul    %r8
mov    %rax,%r9
seto   %al
test   %rsi,%rsi
setne  %bl
or     %al,%bl
movabs $0x421084210842108,%rdx
08 21 04
mov    %rdi,%rax
mul    %rdx
mov    %rax,%rsi
seto   %cl
or     %bl,%cl
mov    %rdi,%rax
mul    %r8
mov    %rax,%r14
mov    %rdx,%rbx
add    %r9,%rsi
add    %rsi,%rbx
setb   %al
or     %cl,%al
jne    1168 <t108_2mul+0x58>
test   %rbx,%rbx
jns    116f <t108_2mul+0x5f>
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 } @t108_2mul(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 5488425272918362313925396894060777604, i128* %6
%12 = load i128, i128* %6
%13 = load i128, i128* %5
%14 = call { i128, i1 } @llvm.umul.with.overflow.i128(i128 %12, i128 %13)
%15 = extractvalue { i128, i1 } %14, 1
%16 = extractvalue { i128, i1 } %14, 0
%17 = icmp ugt i128 %16, 170141183460469231731687303715884105727
%18 = or i1 %15, %17
store i128 %16, i128* %7
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 (...) @bar()
br label %21
21: ; preds = %19, %2
%22 = load i128, i128* %7
store i128 %22, i128* %3
%23 = bitcast i128* %3 to { i64, i64 }*
%24 = load { i64, i64 }, { i64, i64 }* %23
ret { i64, i64 } %24
}

LLVM IR (-O2):
define { i64, i64 } @t108_2mul(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 = tail call { i128, i1 } @llvm.umul.with.overflow.i128(i128 %6, i128 5488425272918362313925396894060777604)
%8 = extractvalue { i128, i1 } %7, 1
%9 = extractvalue { i128, i1 } %7, 0
%10 = icmp slt i128 %9, 0
%11 = or i1 %8, %10
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 (...) @bar()
br label %14
14: ; preds = %12, %2
%15 = trunc i128 %9 to i64
%16 = lshr i128 %9, 64
%17 = trunc i128 %16 to i64
%18 = insertvalue { i64, i64 } poison, i64 %15, 0
%19 = insertvalue { i64, i64 } %18, i64 %17, 1
ret { i64, i64 } %19
}