#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_mul256(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_mul256() {
  unsigned char a[32], b[32], r[64];
  int i, n;
  for (n = 0; n < 60; n++) {
    randombytes(a, 32);
    randombytes(b, 32);
    bigint_mul256(r, a, b);
    bigint_print(a, 32);
    print("*");
    bigint_print(b, 32);
    print("-");
    bigint_print(r, 64);
    print("\r\n");
  }
  for (i = 0; i < 32; i++)
    a[i] = b[i] = 255;
  bigint_mul256(r, a, b);
  bigint_print(a, 32);
  print("*");
  bigint_print(b, 32);
  print("-");
  bigint_print(r, 64);
  print("\r\n");
}


x86 assembly (clang, -O0):
<test_bigint_mul256>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x88(%rbp)
cmpl   $0x3c,-0x88(%rbp)
jge    11f1 <test_bigint_mul256+0xb1>
lea    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1040 <randombytes@plt>
lea    -0x40(%rbp),%rdi
mov    $0x20,%esi
call   1040 <randombytes@plt>
lea    -0x80(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1060 <bigint_mul256@plt>
lea    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1030 <bigint_print@plt>
lea    0xe5c(%rip),%rdi
call   1050 <print@plt>
lea    -0x40(%rbp),%rdi
mov    $0x20,%esi
call   1030 <bigint_print@plt>
lea    0xe44(%rip),%rdi
call   1050 <print@plt>
lea    -0x80(%rbp),%rdi
mov    $0x40,%esi
call   1030 <bigint_print@plt>
lea    0xe2c(%rip),%rdi
call   1050 <print@plt>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1155 <test_bigint_mul256+0x15>
movl   $0x0,-0x84(%rbp)
cmpl   $0x20,-0x84(%rbp)
jge    1234 <test_bigint_mul256+0xf4>
movslq -0x84(%rbp),%rax
movb   $0xff,-0x40(%rbp,%rax,1)
movslq -0x84(%rbp),%rax
movb   $0xff,-0x20(%rbp,%rax,1)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11fb <test_bigint_mul256+0xbb>
lea    -0x80(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1060 <bigint_mul256@plt>
lea    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1030 <bigint_print@plt>
lea    0xda6(%rip),%rdi
call   1050 <print@plt>
lea    -0x40(%rbp),%rdi
mov    $0x20,%esi
call   1030 <bigint_print@plt>
lea    0xd8e(%rip),%rdi
call   1050 <print@plt>
lea    -0x80(%rbp),%rdi
mov    $0x40,%esi
call   1030 <bigint_print@plt>
lea    0xd76(%rip),%rdi
call   1050 <print@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_bigint_mul256>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    $0x3c,%r12d
lea    0x20(%rsp),%r14
mov    %rsp,%rbx
lea    0x40(%rsp),%r15
lea    0xe97(%rip),%r13
lea    0xe92(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x20,%esi
call   1040 <randombytes@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <randombytes@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <bigint_mul256@plt>
mov    %r14,%rdi
mov    $0x20,%esi
call   1030 <bigint_print@plt>
lea    0xe44(%rip),%rdi
call   1050 <print@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1030 <bigint_print@plt>
mov    %r13,%rdi
call   1050 <print@plt>
mov    %r15,%rdi
mov    $0x40,%esi
call   1030 <bigint_print@plt>
mov    %rbp,%rdi
call   1050 <print@plt>
add    $0xffffffff,%r12d
jne    1180 <test_bigint_mul256+0x40>
pcmpeqd %xmm0,%xmm0
movdqa %xmm0,0x10(%rsp)
movdqa %xmm0,(%rsp)
movdqa %xmm0,0x20(%rsp)
movdqa %xmm0,0x30(%rsp)
lea    0x40(%rsp),%r14
lea    0x20(%rsp),%rbp
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1060 <bigint_mul256@plt>
mov    %rbp,%rdi
mov    $0x20,%esi
call   1030 <bigint_print@plt>
lea    0xdc5(%rip),%rdi
call   1050 <print@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1030 <bigint_print@plt>
lea    0xdae(%rip),%rdi
call   1050 <print@plt>
mov    %r14,%rdi
mov    $0x40,%esi
call   1030 <bigint_print@plt>
lea    0xd97(%rip),%rdi
call   1050 <print@plt>
add    $0x88,%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_mul256() {
%1 = alloca [32 x i8]
%2 = alloca [32 x i8]
%3 = alloca [64 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 [32 x i8], [32 x i8]* %1, i64 0, i64 0
%11 = call i32 @randombytes(i8* %10, i32 32)
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%13 = call i32 @randombytes(i8* %12, i32 32)
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%17 = call i32 @bigint_mul256(i8* %14, i8* %15, i8* %16)
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%19 = call i32 @bigint_print(i8* %18, i32 32)
%20 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%22 = call i32 @bigint_print(i8* %21, i32 32)
%23 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%25 = call i32 @bigint_print(i8* %24, i32 64)
%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, 32
br i1 %33, label %34, label %44
34: ; preds = %31
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [32 x i8], [32 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 [32 x i8], [32 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 [64 x i8], [64 x i8]* %3, i64 0, i64 0
%46 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%47 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%48 = call i32 @bigint_mul256(i8* %45, i8* %46, i8* %47)
%49 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%50 = call i32 @bigint_print(i8* %49, i32 32)
%51 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%52 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%53 = call i32 @bigint_print(i8* %52, i32 32)
%54 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%55 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%56 = call i32 @bigint_print(i8* %55, i32 64)
%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_mul256() {
%1 = alloca [32 x i8]
%2 = alloca [32 x i8]
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [64 x i8], [64 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 32)
%10 = call i32 @randombytes(i8* %5, i32 32)
%11 = call i32 @bigint_mul256(i8* %6, i8* %4, i8* %5)
%12 = call i32 @bigint_print(i8* %4, i32 32)
%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 32)
%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 64)
%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 [32 x i8], [32 x i8]* %2, i64 0, i64 0
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%23 = call i32 @bigint_mul256(i8* %6, i8* %4, i8* %5)
%24 = call i32 @bigint_print(i8* %4, i32 32)
%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 32)
%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 64)
%29 = call i32 @print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}