#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ bigint_mul128(unsigned char *, unsigned char *,
                                 unsigned char *);
int /*<<< orphan*/ bigint_print(unsigned char *, int);
int /*<<< orphan*/ print(char *);
int /*<<< orphan*/ randombytes(unsigned char *, int);
void test_bigint_mul128() {
  unsigned char a[16], b[16], r[32];
  int i, n;
  for (n = 0; n < 60; n++) {
    randombytes(a, 16);
    randombytes(b, 16);
    bigint_mul128(r, a, b);
    bigint_print(a, 16);
    print("*");
    bigint_print(b, 16);
    print("-");
    bigint_print(r, 32);
    print("\r\n");
  }
  for (i = 0; i < 16; i++)
    a[i] = b[i] = 255;
  bigint_mul128(r, a, b);
  bigint_print(a, 16);
  print("*");
  bigint_print(b, 16);
  print("-");
  bigint_print(r, 32);
  print("\r\n");
}


x86 assembly (clang, -O0):
<test_bigint_mul128>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x48(%rbp)
cmpl   $0x3c,-0x48(%rbp)
jge    11e2 <test_bigint_mul128+0xa2>
lea    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1040 <randombytes@plt>
lea    -0x20(%rbp),%rdi
mov    $0x10,%esi
call   1040 <randombytes@plt>
lea    -0x40(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <bigint_mul128@plt>
lea    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1030 <bigint_print@plt>
lea    0xe65(%rip),%rdi
call   1050 <print@plt>
lea    -0x20(%rbp),%rdi
mov    $0x10,%esi
call   1030 <bigint_print@plt>
lea    0xe4d(%rip),%rdi
call   1050 <print@plt>
lea    -0x40(%rbp),%rdi
mov    $0x20,%esi
call   1030 <bigint_print@plt>
lea    0xe35(%rip),%rdi
call   1050 <print@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    114f <test_bigint_mul128+0xf>
movl   $0x0,-0x44(%rbp)
cmpl   $0x10,-0x44(%rbp)
jge    1213 <test_bigint_mul128+0xd3>
movslq -0x44(%rbp),%rax
movb   $0xff,-0x20(%rbp,%rax,1)
movslq -0x44(%rbp),%rax
movb   $0xff,-0x10(%rbp,%rax,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11e9 <test_bigint_mul128+0xa9>
lea    -0x40(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <bigint_mul128@plt>
lea    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1030 <bigint_print@plt>
lea    0xdc7(%rip),%rdi
call   1050 <print@plt>
lea    -0x20(%rbp),%rdi
mov    $0x10,%esi
call   1030 <bigint_print@plt>
lea    0xdaf(%rip),%rdi
call   1050 <print@plt>
lea    -0x40(%rbp),%rdi
mov    $0x20,%esi
call   1030 <bigint_print@plt>
lea    0xd97(%rip),%rdi
call   1050 <print@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_bigint_mul128>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    $0x3c,%r12d
lea    0x10(%rsp),%r14
mov    %rsp,%rbx
lea    0x20(%rsp),%r15
lea    0xe9a(%rip),%r13
lea    0xe95(%rip),%rbp
nop
mov    %r14,%rdi
mov    $0x10,%esi
call   1040 <randombytes@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
call   1040 <randombytes@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <bigint_mul128@plt>
mov    %r14,%rdi
mov    $0x10,%esi
call   1030 <bigint_print@plt>
lea    0xe54(%rip),%rdi
call   1050 <print@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
call   1030 <bigint_print@plt>
mov    %r13,%rdi
call   1050 <print@plt>
mov    %r15,%rdi
mov    $0x20,%esi
call   1030 <bigint_print@plt>
mov    %rbp,%rdi
call   1050 <print@plt>
add    $0xffffffff,%r12d
jne    1170 <test_bigint_mul128+0x30>
pcmpeqd %xmm0,%xmm0
movdqa %xmm0,(%rsp)
movdqa %xmm0,0x10(%rsp)
lea    0x20(%rsp),%r14
lea    0x10(%rsp),%rbp
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1060 <bigint_mul128@plt>
mov    %rbp,%rdi
mov    $0x10,%esi
call   1030 <bigint_print@plt>
lea    0xde1(%rip),%rdi
call   1050 <print@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
call   1030 <bigint_print@plt>
lea    0xdca(%rip),%rdi
call   1050 <print@plt>
mov    %r14,%rdi
mov    $0x20,%esi
call   1030 <bigint_print@plt>
lea    0xdb3(%rip),%rdi
call   1050 <print@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"*\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
define void @test_bigint_mul128() {
%1 = alloca [16 x i8]
%2 = alloca [16 x i8]
%3 = alloca [32 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %5
br label %6
6: ; preds = %27, %0
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 60
br i1 %8, label %9, label %30
9: ; preds = %6
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%11 = call i32 @randombytes(i8* %10, i32 16)
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%13 = call i32 @randombytes(i8* %12, i32 16)
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%17 = call i32 @bigint_mul128(i8* %14, i8* %15, i8* %16)
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%19 = call i32 @bigint_print(i8* %18, i32 16)
%20 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%22 = call i32 @bigint_print(i8* %21, i32 16)
%23 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%25 = call i32 @bigint_print(i8* %24, i32 32)
%26 = call i32 @print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %9
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %6
30: ; preds = %6
store i32 0, i32* %4
br label %31
31: ; preds = %41, %30
%32 = load i32, i32* %4
%33 = icmp slt i32 %32, 16
br i1 %33, label %34, label %44
34: ; preds = %31
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %36
store i8 -1, i8* %37
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 %39
store i8 -1, i8* %40
br label %41
41: ; preds = %34
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %31
44: ; preds = %31
%45 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%46 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%47 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%48 = call i32 @bigint_mul128(i8* %45, i8* %46, i8* %47)
%49 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%50 = call i32 @bigint_print(i8* %49, i32 16)
%51 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%52 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%53 = call i32 @bigint_print(i8* %52, i32 16)
%54 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%55 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%56 = call i32 @bigint_print(i8* %55, i32 32)
%57 = call i32 @print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"*\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
define void @test_bigint_mul128() {
%1 = alloca [16 x i8]
%2 = alloca [16 x i8]
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ 0, %0 ], [ %18, %7 ]
%9 = call i32 @randombytes(i8* %4, i32 16)
%10 = call i32 @randombytes(i8* %5, i32 16)
%11 = call i32 @bigint_mul128(i8* %6, i8* %4, i8* %5)
%12 = call i32 @bigint_print(i8* %4, i32 16)
%13 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @bigint_print(i8* %5, i32 16)
%15 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @bigint_print(i8* %6, i32 32)
%17 = call i32 @print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = add nuw nsw i32 %8, 1
%19 = icmp eq i32 %18, 60
br i1 %19, label %20, label %7
20: ; preds = %7
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%23 = call i32 @bigint_mul128(i8* %6, i8* %4, i8* %5)
%24 = call i32 @bigint_print(i8* %4, i32 16)
%25 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @bigint_print(i8* %5, i32 16)
%27 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @bigint_print(i8* %6, i32 32)
%29 = call i32 @print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}