#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 *);
unsigned long long cpucycles();
int /*<<< orphan*/ print_bench(char *, unsigned long long *, int);
void speed_bigint_mul128() {
  unsigned long long t[10];
  int i;
  unsigned char r[32];
  for (i = 0; i < 10; i++) {
    t[i] = cpucycles();
    bigint_mul128(r, r, r);
  }
  print_bench("bigint_mul128", t, 10);
}


x86 assembly (clang, -O0):
<speed_bigint_mul128>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x54(%rbp)
cmpl   $0xa,-0x54(%rbp)
jge    117e <speed_bigint_mul128+0x4e>
mov    $0x0,%al
call   1040 <cpucycles@plt>
mov    %rax,%rcx
movslq -0x54(%rbp),%rax
mov    %rcx,-0x50(%rbp,%rax,8)
lea    -0x80(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1050 <bigint_mul128@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1142 <speed_bigint_mul128+0x12>
lea    -0x50(%rbp),%rsi
lea    0xe77(%rip),%rdi
mov    $0xa,%edx
call   1030 <print_bench@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<speed_bigint_mul128>:
push   %rbx
sub    $0x70,%rsp
xor    %eax,%eax
call   1040 <cpucycles@plt>
mov    %rax,(%rsp)
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <bigint_mul128@plt>
xor    %eax,%eax
call   1040 <cpucycles@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <bigint_mul128@plt>
xor    %eax,%eax
call   1040 <cpucycles@plt>
mov    %rax,0x10(%rsp)
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <bigint_mul128@plt>
xor    %eax,%eax
call   1040 <cpucycles@plt>
mov    %rax,0x18(%rsp)
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <bigint_mul128@plt>
xor    %eax,%eax
call   1040 <cpucycles@plt>
mov    %rax,0x20(%rsp)
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <bigint_mul128@plt>
xor    %eax,%eax
call   1040 <cpucycles@plt>
mov    %rax,0x28(%rsp)
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <bigint_mul128@plt>
xor    %eax,%eax
call   1040 <cpucycles@plt>
mov    %rax,0x30(%rsp)
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <bigint_mul128@plt>
xor    %eax,%eax
call   1040 <cpucycles@plt>
mov    %rax,0x38(%rsp)
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <bigint_mul128@plt>
xor    %eax,%eax
call   1040 <cpucycles@plt>
mov    %rax,0x40(%rsp)
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <bigint_mul128@plt>
xor    %eax,%eax
call   1040 <cpucycles@plt>
mov    %rax,0x48(%rsp)
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <bigint_mul128@plt>
lea    0xdbc(%rip),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1030 <print_bench@plt>
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"bigint_mul128\00"
define void @speed_bigint_mul128() {
%1 = alloca [10 x i64]
%2 = alloca i32
%3 = alloca [32 x i8]
store i32 0, i32* %2
br label %4
4: ; preds = %16, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = call i64 (...) @cpucycles()
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 %10
store i64 %8, i64* %11
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%15 = call i32 @bigint_mul128(i8* %12, i8* %13, i8* %14)
br label %16
16: ; preds = %7
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %4
19: ; preds = %4
%20 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 0
%21 = call i32 @print_bench(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64* %20, i32 10)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"bigint_mul128\00"
define void @speed_bigint_mul128() {
%1 = alloca [10 x i64]
%2 = alloca [32 x i8]
%3 = bitcast [10 x i64]* %1 to i8*
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%5 = call i64 (...) @cpucycles()
%6 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 0
store i64 %5, i64* %6
%7 = call i32 @bigint_mul128(i8* %4, i8* %4, i8* %4)
%8 = call i64 (...) @cpucycles()
%9 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 1
store i64 %8, i64* %9
%10 = call i32 @bigint_mul128(i8* %4, i8* %4, i8* %4)
%11 = call i64 (...) @cpucycles()
%12 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 2
store i64 %11, i64* %12
%13 = call i32 @bigint_mul128(i8* %4, i8* %4, i8* %4)
%14 = call i64 (...) @cpucycles()
%15 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 3
store i64 %14, i64* %15
%16 = call i32 @bigint_mul128(i8* %4, i8* %4, i8* %4)
%17 = call i64 (...) @cpucycles()
%18 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 4
store i64 %17, i64* %18
%19 = call i32 @bigint_mul128(i8* %4, i8* %4, i8* %4)
%20 = call i64 (...) @cpucycles()
%21 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 5
store i64 %20, i64* %21
%22 = call i32 @bigint_mul128(i8* %4, i8* %4, i8* %4)
%23 = call i64 (...) @cpucycles()
%24 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 6
store i64 %23, i64* %24
%25 = call i32 @bigint_mul128(i8* %4, i8* %4, i8* %4)
%26 = call i64 (...) @cpucycles()
%27 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 7
store i64 %26, i64* %27
%28 = call i32 @bigint_mul128(i8* %4, i8* %4, i8* %4)
%29 = call i64 (...) @cpucycles()
%30 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 8
store i64 %29, i64* %30
%31 = call i32 @bigint_mul128(i8* %4, i8* %4, i8* %4)
%32 = call i64 (...) @cpucycles()
%33 = getelementptr inbounds [10 x i64], [10 x i64]* %1, i64 0, i64 9
store i64 %32, i64* %33
%34 = call i32 @bigint_mul128(i8* %4, i8* %4, i8* %4)
%35 = call i32 @print_bench(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64* %6, i32 10)
ret void
}