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


x86 assembly (clang, -O0):
<t128_5mul>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x28(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x38(%rbp),%r10
mov    %r10,-0x70(%rbp)
sar    $0x3f,%r10
movabs $0x2492492492492492,%rcx
49 92 24
mov    %rcx,-0x88(%rbp)
mov    %r10,%rax
mul    %rcx
mov    %rax,%rbx
mov    %rdx,%r9
mov    %rbx,%r14
add    %r9,%r14
mov    %r9,%r11
adc    $0x0,%r11
movabs $0x1249249249249249,%rcx
24 49 12
mov    %rcx,-0x68(%rbp)
mov    %r10,%rax
mul    %rcx
mov    %rax,%rdi
mov    -0x80(%rbp),%rax
mov    %rdx,%rsi
mov    -0x88(%rbp),%rdx
mov    %rdi,%r8
add    %r14,%r8
adc    %rsi,%r11
add    %r11,%rdi
adc    $0x0,%rsi
mov    %rsi,-0x60(%rbp)
mov    %r10,%r11
imul   %rcx,%r11
add    %r11,%r9
imul   %rdx,%r10
add    %r10,%r9
mov    %rdi,%r11
add    %rbx,%r11
adc    %r9,%rsi
mul    %rdx
mov    %rax,%r9
mov    -0x70(%rbp),%rax
mov    %r9,-0x58(%rbp)
mov    %rdx,%r9
mov    -0x88(%rbp),%rdx
mov    %r9,-0x78(%rbp)
mul    %rdx
mov    %rax,%r14
mov    -0x80(%rbp),%rax
mov    %rdx,%r9
mov    -0x78(%rbp),%rdx
add    %rdx,%r14
adc    $0x0,%r9
mul    %rcx
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
mov    %rdx,%r10
mov    -0x68(%rbp),%rdx
add    %r14,%rcx
adc    %r10,%r9
mul    %rdx
mov    %rax,%r10
mov    -0x60(%rbp),%rax
mov    %rdx,%r14
mov    -0x58(%rbp),%rdx
add    %r9,%r10
adc    $0x0,%r14
mov    %rbx,%r9
add    %r10,%r9
mov    %r8,%r10
adc    %r14,%r10
adc    $0x0,%rdi
adc    $0x0,%rax
add    %rbx,%rdi
adc    %r8,%rax
adc    $0x0,%r11
adc    $0x0,%rsi
mov    %r10,%r8
sar    $0x3f,%r8
xor    %r8,%rdi
xor    %r8,%r11
or     %r11,%rdi
xor    %r8,%rax
xor    %r8,%rsi
or     %rsi,%rax
or     %rax,%rdi
mov    %r9d,%eax
and    $0x1,%eax
mov    %eax,%esi
mov    %rsi,%rax
neg    %rax
mov    %rax,%r8
xor    %r10,%r8
xor    %r9,%rax
or     %r8,%rax
or     %rdi,%rax
or     %rsi,%rax
setne  %al
mov    %rdx,-0x50(%rbp)
mov    %rcx,-0x48(%rbp)
test   $0x1,%al
jne    12a0 <t128_5mul+0x190>
jmp    12a7 <t128_5mul+0x197>
mov    $0x0,%al
call   1030 <bar@plt>
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rdx
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<t128_5mul>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r8
mov    %rsi,%rcx
sar    $0x3f,%rcx
movabs $0x2492492492492492,%r15
49 92 24
mov    %rcx,%rax
mul    %r15
mov    %rdx,%r11
mov    %rax,%r9
mov    %rax,%r13
add    %rdx,%r13
mov    %rdx,%rbx
adc    $0x0,%rbx
movabs $0x1249249249249249,%r14
24 49 12
mov    %rcx,%rax
mul    %r14
mov    %rdx,%rsi
add    %rax,%r13
adc    %rdx,%rbx
add    %rax,%rbx
adc    $0x0,%rsi
mov    %rdi,%r10
mov    %rcx,%rax
imul   %r14,%rax
add    %r11,%rax
imul   %r15,%rcx
add    %rax,%rcx
mov    %rbx,%rbp
add    %r9,%rbp
adc    %rsi,%rcx
mov    %rdi,%rax
mul    %r15
mov    %rdx,%r11
mov    %rax,(%rsp)
mov    %r8,%rax
mul    %r15
mov    %rdx,%r12
mov    %rax,%rdi
add    %r11,%rdi
adc    $0x0,%r12
mov    %r10,%rax
mul    %r14
mov    %rdx,%r10
mov    %rax,%r15
add    %rdi,%r15
adc    %r12,%r10
mov    %r8,%rax
mul    %r14
add    %r10,%rax
adc    $0x0,%rdx
add    %r9,%rax
adc    %r13,%rdx
adc    $0x0,%rbx
adc    $0x0,%rsi
add    %r9,%rbx
adc    %r13,%rsi
adc    $0x0,%rbp
adc    $0x0,%rcx
mov    %rdx,%rdi
sar    $0x3f,%rdi
xor    %rdi,%rbx
xor    %rdi,%rbp
or     %rbx,%rbp
mov    (%rsp),%rbx
xor    %rdi,%rsi
xor    %rcx,%rdi
or     %rsi,%rdi
or     %rbp,%rdi
mov    %eax,%ecx
and    $0x1,%ecx
mov    %rcx,%rsi
neg    %rsi
xor    %rsi,%rdx
xor    %rax,%rsi
or     %rdx,%rsi
or     %rdi,%rsi
jne    122d <t128_5mul+0x11d>
mov    %r15,%rax
xor    %r15,%rax
mov    %rbx,%rdx
xor    %rbx,%rdx
or     %rcx,%rdx
or     %rax,%rdx
je     1234 <t128_5mul+0x124>
xor    %eax,%eax
call   1030 <bar@plt>
mov    %rbx,%rax
mov    %r15,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define { i64, i64 } @t128_5mul(i64 %0, i64 %1) {
%3 = alloca i128
%4 = alloca i128
%5 = alloca i128
%6 = alloca i128
%7 = bitcast i128* %4 to { i64, i64 }*
%8 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %7, i32 0, i32 0
store i64 %0, i64* %8
%9 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %7, i32 0, i32 1
store i64 %1, i64* %9
%10 = load i128, i128* %4
store i128 %10, i128* %5
%11 = load i128, i128* %5
%12 = sext i128 %11 to i129
%13 = call { i129, i1 } @llvm.smul.with.overflow.i129(i129 %12, i129 24305883351495604533098186245126300818)
%14 = extractvalue { i129, i1 } %13, 1
%15 = extractvalue { i129, i1 } %13, 0
%16 = trunc i129 %15 to i128
%17 = zext i128 %16 to i129
%18 = icmp ne i129 %15, %17
%19 = or i1 %14, %18
store i128 %16, i128* %6
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 (...) @bar()
br label %22
22: ; preds = %20, %2
%23 = load i128, i128* %6
store i128 %23, i128* %3
%24 = bitcast i128* %3 to { i64, i64 }*
%25 = load { i64, i64 }, { i64, i64 }* %24
ret { i64, i64 } %25
}

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