__attribute__((no, noclone)) signed __int128 t122_5mul(signed __int128 x) {
  signed __int128 r;
  if (__builtin_mul_overflow(x, (signed __int128)(-1), &r))
    bar();
  return r;
}


x86 assembly (clang, -O0):
<t122_5mul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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)
mov    -0x30(%rbp),%r8
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    $0xffffffffffffffff,%rcx
mov    %rcx,-0x58(%rbp)
mov    %r8,%rax
mul    %rcx
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
mov    %rcx,-0x48(%rbp)
mov    %rdx,%rdi
mov    -0x58(%rbp),%rdx
mul    %rdx
mov    %rax,%r10
mov    -0x60(%rbp),%rax
mov    %rdx,%rsi
mov    -0x58(%rbp),%rdx
mov    %r10,%r9
add    %rdi,%r9
mov    %rsi,%r11
adc    $0x0,%r11
add    %r9,%rcx
adc    %rdi,%r11
setb   %r9b
movzbl %r9b,%r9d
add    %r11,%r10
mov    %r10,-0x50(%rbp)
adc    %r9,%rsi
sub    %r8,%rdi
sub    %rax,%rdi
sar    $0x3f,%rax
imul   %rdx
mov    %rax,%r10
mov    -0x50(%rbp),%rax
mov    %rdx,%r9
mov    -0x48(%rbp),%rdx
mov    %rdx,%r8
add    %r10,%r8
adc    %r9,%rdi
add    %r8,%rax
adc    %rdi,%rsi
mov    %rcx,%rdi
sar    $0x3f,%rdi
xor    %rdi,%rsi
xor    %rdi,%rax
or     %rsi,%rax
setne  %al
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x38(%rbp)
test   $0x1,%al
jne    11e7 <t122_5mul+0xd7>
jmp    11ee <t122_5mul+0xde>
mov    $0x0,%al
call   1030 <bar@plt>
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rdx
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t122_5mul>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r9
mov    $0xffffffffffffffff,%r8
mov    %rdi,%rax
mul    %r8
mov    %rdx,%rcx
mov    %rax,%r14
mov    %rsi,%rax
mul    %r8
mov    %rax,%r15
add    %rcx,%r15
mov    %rdx,%rdi
adc    $0x0,%rdi
add    %r14,%r15
adc    %rcx,%rdi
setb   %bl
movzbl %bl,%ebx
add    %rax,%rdi
adc    %rdx,%rbx
sub    %r9,%rcx
sub    %rsi,%rcx
sar    $0x3f,%rsi
mov    %rsi,%rax
imul   %r8
add    %r14,%rax
adc    %rcx,%rdx
add    %rdi,%rax
adc    %rbx,%rdx
mov    %r15,%rcx
sar    $0x3f,%rcx
xor    %rcx,%rdx
xor    %rax,%rcx
or     %rdx,%rcx
je     1185 <t122_5mul+0x75>
xor    %eax,%eax
call   1030 <bar@plt>
mov    %r14,%rax
mov    %r15,%rdx
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define { i64, i64 } @t122_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 = call { i128, i1 } @llvm.smul.with.overflow.i128(i128 %11, i128 -1)
%13 = extractvalue { i128, i1 } %12, 1
%14 = extractvalue { i128, i1 } %12, 0
store i128 %14, i128* %6
br i1 %13, label %15, label %17
15: ; preds = %2
%16 = call i32 (...) @bar()
br label %17
17: ; preds = %15, %2
%18 = load i128, i128* %6
store i128 %18, i128* %3
%19 = bitcast i128* %3 to { i64, i64 }*
%20 = load { i64, i64 }, { i64, i64 }* %19
ret { i64, i64 } %20
}

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