// File: archit-p[P]bulletproofs-demo/src/inner_product_arg.cpp
// Function: InnerProdArg::generate_argument()
void InnerProdArg::generate_argument()
{
    vector <int> a_l, a_r, b_l, b_r, a_prime, b_prime, to_send;
    int x_inv = modInverse(x, order);
    cout << "x_inv value is :" << x_inv << endl;
    int c_prime; 
    while(a.size() > 1) {
        get_half(a, a_l, a_r);
        get_half(b, b_l, b_r);

        a_prime = vector_sum(k_product_vector(a_l, x, order), k_product_vector(a_r, x_inv, order), order);
        b_prime = vector_sum(k_product_vector(b_l, x_inv), k_product_vector(b_r, x), order);
        c_prime = inner_product(a_prime, b_prime, order);
        
        a.clear();
        b.clear();

        a = a_prime;
        b = b_prime;

        to_send.push_back(c_prime);
    }

    to_send.push_back(a[0]);
    to_send.push_back(b[0]);
    
    final_arg = serialize(to_send);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1b70
leaq -0x38(%rbp), %rdi
callq 0x1b70
leaq -0x50(%rbp), %rdi
callq 0x1b70
leaq -0x68(%rbp), %rdi
callq 0x1b70
leaq -0x80(%rbp), %rdi
callq 0x1b70
leaq -0x98(%rbp), %rdi
callq 0x1b70
leaq -0xb0(%rbp), %rdi
callq 0x1b70
movq -0x210(%rbp), %rax
movl 0x38(%rax), %esi
movl 0x40(%rax), %edi
callq 0x1a80
movl %eax, -0x204(%rbp)
jmp 0x60d9
movl -0x204(%rbp), %eax
movl %eax, -0xb4(%rbp)
movq 0x5eec(%rip), %rdi      # 0xbfd8
leaq 0x1f8f(%rip), %rsi      # 0x8082
callq 0x10c0
movq %rax, -0x218(%rbp)
jmp 0x6101
movq -0x218(%rbp), %rdi
movl -0xb4(%rbp), %esi
callq 0x1150
movq %rax, -0x220(%rbp)
jmp 0x611c
movq -0x220(%rbp), %rdi
movq 0x5e9e(%rip), %rsi      # 0xbfc8
callq 0x10f0
jmp 0x6131
jmp 0x6133
movq -0x210(%rbp), %rdi
callq 0x2450
cmpq $0x1, %rax
jbe 0x656a
movq -0x210(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x2790
jmp 0x615f
movq -0x210(%rbp), %rdi
addq $0x18, %rdi
leaq -0x50(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x2790
jmp 0x6179
leaq -0x110(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x52c0
jmp 0x618b
movq -0x210(%rbp), %rax
movl 0x38(%rax), %ecx
movl 0x40(%rax), %edx
leaq -0xf8(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x2b50
jmp 0x61ad
leaq -0x140(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x52c0
jmp 0x61bf
movq -0x210(%rbp), %rax
movl -0xb4(%rbp), %edx
movl 0x38(%rax), %ecx
leaq -0x128(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x2b50
jmp 0x61e4
movq -0x210(%rbp), %rax
movl 0x38(%rax), %ecx
leaq -0xe0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
leaq -0x128(%rbp), %rdx
callq 0x2dc0
jmp 0x620a
leaq -0x80(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
movq %rsi, -0x228(%rbp)
callq 0x5290
movq -0x228(%rbp), %rdi
callq 0x1cc0
leaq -0x128(%rbp), %rdi
callq 0x1cc0
leaq -0x140(%rbp), %rdi
callq 0x1cc0
leaq -0xf8(%rbp), %rdi
callq 0x1cc0
leaq -0x110(%rbp), %rdi
callq 0x1cc0
leaq -0x188(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x52c0
jmp 0x626f
movl -0xb4(%rbp), %edx
leaq -0x170(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x2ac0
jmp 0x628a
leaq -0x1b8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x52c0
jmp 0x629c
movq -0x210(%rbp), %rax
movl 0x40(%rax), %edx
leaq -0x1a0(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x2ac0
jmp 0x62bb
movq -0x210(%rbp), %rax
movl 0x38(%rax), %ecx
leaq -0x158(%rbp), %rdi
leaq -0x170(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
callq 0x2dc0
jmp 0x62e1
leaq -0x98(%rbp), %rdi
leaq -0x158(%rbp), %rsi
movq %rsi, -0x230(%rbp)
callq 0x5290
movq -0x230(%rbp), %rdi
callq 0x1cc0
leaq -0x1a0(%rbp), %rdi
callq 0x1cc0
leaq -0x1b8(%rbp), %rdi
callq 0x1cc0
leaq -0x170(%rbp), %rdi
callq 0x1cc0
leaq -0x188(%rbp), %rdi
callq 0x1cc0
leaq -0x1d0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x52c0
jmp 0x6349
leaq -0x1e8(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x52c0
jmp 0x635e
movq -0x210(%rbp), %rax
movl 0x38(%rax), %edx
leaq -0x1d0(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x1740
movq %rax, -0x238(%rbp)
jmp 0x6384
movq -0x238(%rbp), %rax
movl %eax, -0xc8(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x1cc0
leaq -0x1d0(%rbp), %rdi
callq 0x1cc0
movq -0x210(%rbp), %rdi
callq 0x2f90
movq -0x210(%rbp), %rdi
addq $0x18, %rdi
callq 0x2f90
movq -0x210(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x6850
jmp 0x63d7
movq -0x210(%rbp), %rdi
addq $0x18, %rdi
leaq -0x98(%rbp), %rsi
callq 0x6850
jmp 0x63f0
leaq -0xb0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x2fb0
jmp 0x6405
jmp 0x6133
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x6664
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x6493
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x6487
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x647b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x1cc0
leaq -0x140(%rbp), %rdi
callq 0x1cc0
leaq -0xf8(%rbp), %rdi
callq 0x1cc0
leaq -0x110(%rbp), %rdi
callq 0x1cc0
jmp 0x6664
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x6516
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x650a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x64fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x1cc0
leaq -0x1b8(%rbp), %rdi
callq 0x1cc0
leaq -0x170(%rbp), %rdi
callq 0x1cc0
leaq -0x188(%rbp), %rdi
callq 0x1cc0
jmp 0x6664
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x6559
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x1cc0
leaq -0x1d0(%rbp), %rdi
callq 0x1cc0
jmp 0x6664
movq -0x210(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3090
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
callq 0x2fb0
jmp 0x658b
movq -0x210(%rbp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3090
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
callq 0x2fb0
jmp 0x65b0
leaq -0x200(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x52c0
jmp 0x65c5
leaq -0x200(%rbp), %rdi
callq 0x5e20
movq %rax, -0x240(%rbp)
jmp 0x65da
movq -0x210(%rbp), %rax
movq -0x240(%rbp), %rcx
movq %rcx, 0x30(%rax)
leaq -0x200(%rbp), %rdi
callq 0x1cc0
leaq -0xb0(%rbp), %rdi
callq 0x1cc0
leaq -0x98(%rbp), %rdi
callq 0x1cc0
leaq -0x80(%rbp), %rdi
callq 0x1cc0
leaq -0x68(%rbp), %rdi
callq 0x1cc0
leaq -0x50(%rbp), %rdi
callq 0x1cc0
leaq -0x38(%rbp), %rdi
callq 0x1cc0
leaq -0x20(%rbp), %rdi
callq 0x1cc0
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x1cc0
leaq -0xb0(%rbp), %rdi
callq 0x1cc0
leaq -0x98(%rbp), %rdi
callq 0x1cc0
leaq -0x80(%rbp), %rdi
callq 0x1cc0
leaq -0x68(%rbp), %rdi
callq 0x1cc0
leaq -0x50(%rbp), %rdi
callq 0x1cc0
leaq -0x38(%rbp), %rdi
callq 0x1cc0
leaq -0x20(%rbp), %rdi
callq 0x1cc0
movq -0xc0(%rbp), %rdi
callq 0x1170
nopw %cs:(%rax,%rax)