#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 */
scalar_t__ check_polynomial_multiplication(char *, char *, char *, int);
int test_polynomial_multiplication() {
  int ret = 0;
  ret += check_polynomial_multiplication("3x^2+2x+1", "x+1",
                                         "3.00x^3.00+5.00x^2.00+3.00x+1.00", 2);
  ret += check_polynomial_multiplication(
      "5x^2+2x^3+x", "3x^4+x^3+2x^2+1",
      "6.00x^7.00+17.00x^6.00+12.00x^5.00+11.00x^4.00+4.00x^3.00+5.00x^2.00+x",
      2);
  ret += check_polynomial_multiplication("5.5x^2.2+x", "3.3x^4.4",
                                         "18.15x^6.60+3.30x^5.40", 2);
  ret += check_polynomial_multiplication("x", "x", "x^2", 0);
  ret += check_polynomial_multiplication("x+x", "x+x", "4x^2", 0);
  ret += check_polynomial_multiplication("x", "0", "0", 0);
  ret += check_polynomial_multiplication("x", "1", "x", 0);
  ret += check_polynomial_multiplication("0", "0", "0", 0);
  return ret;
}


x86 assembly (clang, -O0):
<test_polynomial_multiplication>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
lea    0xed9(%rip),%rsi
lea    0xed6(%rip),%rdx
mov    $0x2,%ecx
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xed9(%rip),%rdi
lea    0xede(%rip),%rsi
lea    0xee7(%rip),%rdx
mov    $0x2,%ecx
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xf10(%rip),%rdi
lea    0xf14(%rip),%rsi
lea    0xf16(%rip),%rdx
mov    $0x2,%ecx
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xee2(%rip),%rsi
lea    0xf0d(%rip),%rdx
xor    %ecx,%ecx
mov    %rsi,%rdi
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xeea(%rip),%rsi
lea    0xee7(%rip),%rdx
xor    %ecx,%ecx
mov    %rsi,%rdi
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xe98(%rip),%rdi
lea    0xe2e(%rip),%rdx
xor    %ecx,%ecx
mov    %rdx,%rsi
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xe73(%rip),%rdx
lea    0xe25(%rip),%rsi
xor    %ecx,%ecx
mov    %rdx,%rdi
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xdeb(%rip),%rdx
xor    %ecx,%ecx
mov    %rdx,%rdi
mov    %rdx,%rsi
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_polynomial_multiplication>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xee1(%rip),%rdi
lea    0xee0(%rip),%rsi
lea    0xedd(%rip),%rdx
mov    $0x2,%ecx
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%r14
lea    0xeea(%rip),%rdi
lea    0xeef(%rip),%rsi
lea    0xef8(%rip),%rdx
mov    $0x2,%ecx
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%r15
add    %r14d,%r15d
lea    0xf28(%rip),%rdi
lea    0xf2c(%rip),%rsi
lea    0xf2e(%rip),%rdx
mov    $0x2,%ecx
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%r12
add    %r15d,%r12d
lea    0xf01(%rip),%r14
lea    0xf2c(%rip),%rdx
mov    %r14,%rdi
mov    %r14,%rsi
xor    %ecx,%ecx
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%r15
add    %r12d,%r15d
lea    0xf0d(%rip),%rdi
lea    0xf0a(%rip),%rdx
mov    %rdi,%rsi
xor    %ecx,%ecx
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%rbx
add    %r15d,%ebx
lea    0xe5f(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%r12
add    %ebx,%r12d
lea    0xe5e(%rip),%rsi
mov    %r14,%rdi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1030 <check_polynomial_multiplication@plt>
mov    %rax,%rbx
add    %r12d,%ebx
mov    %r15,%rdi
mov    %r15,%rsi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1030 <check_polynomial_multiplication@plt>
add    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"3x^2+2x+1\00"
@.str.1 = [4 x i8] c"x+1\00"
@.str.2 = [33 x i8] c"3.00x^3.00+5.00x^2.00+3.00x+1.00\00"
@.str.3 = [12 x i8] c"5x^2+2x^3+x\00"
@.str.4 = [16 x i8] c"3x^4+x^3+2x^2+1\00"
@.str.5 = [71 x i8] c"6.00x^7.00+17.00x^6.00+12.00x^5.00+11.00x^4.00+4.00x^3.00+5.00x^2.00+x\00"
@.str.6 = [11 x i8] c"5.5x^2.2+x\00"
@.str.7 = [9 x i8] c"3.3x^4.4\00"
@.str.8 = [23 x i8] c"18.15x^6.60+3.30x^5.40\00"
@.str.9 = [2 x i8] c"x\00"
@.str.10 = [4 x i8] c"x^2\00"
@.str.11 = [4 x i8] c"x+x\00"
@.str.12 = [5 x i8] c"4x^2\00"
@.str.13 = [2 x i8] c"0\00"
@.str.14 = [2 x i8] c"1\00"
define i32 @test_polynomial_multiplication() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 2)
%3 = load i32, i32* %1
%4 = sext i32 %3 to i64
%5 = add nsw i64 %4, %2
%6 = trunc i64 %5 to i32
store i32 %6, i32* %1
%7 = call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0), i32 2)
%8 = load i32, i32* %1
%9 = sext i32 %8 to i64
%10 = add nsw i64 %9, %7
%11 = trunc i64 %10 to i32
store i32 %11, i32* %1
%12 = call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 2)
%13 = load i32, i32* %1
%14 = sext i32 %13 to i64
%15 = add nsw i64 %14, %12
%16 = trunc i64 %15 to i32
store i32 %16, i32* %1
%17 = call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 0)
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = add nsw i64 %19, %17
%21 = trunc i64 %20 to i32
store i32 %21, i32* %1
%22 = call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 0)
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = add nsw i64 %24, %22
%26 = trunc i64 %25 to i32
store i32 %26, i32* %1
%27 = call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i32 0)
%28 = load i32, i32* %1
%29 = sext i32 %28 to i64
%30 = add nsw i64 %29, %27
%31 = trunc i64 %30 to i32
store i32 %31, i32* %1
%32 = call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 0)
%33 = load i32, i32* %1
%34 = sext i32 %33 to i64
%35 = add nsw i64 %34, %32
%36 = trunc i64 %35 to i32
store i32 %36, i32* %1
%37 = call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i32 0)
%38 = load i32, i32* %1
%39 = sext i32 %38 to i64
%40 = add nsw i64 %39, %37
%41 = trunc i64 %40 to i32
store i32 %41, i32* %1
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@.str = [10 x i8] c"3x^2+2x+1\00"
@.str.1 = [4 x i8] c"x+1\00"
@.str.2 = [33 x i8] c"3.00x^3.00+5.00x^2.00+3.00x+1.00\00"
@.str.3 = [12 x i8] c"5x^2+2x^3+x\00"
@.str.4 = [16 x i8] c"3x^4+x^3+2x^2+1\00"
@.str.5 = [71 x i8] c"6.00x^7.00+17.00x^6.00+12.00x^5.00+11.00x^4.00+4.00x^3.00+5.00x^2.00+x\00"
@.str.6 = [11 x i8] c"5.5x^2.2+x\00"
@.str.7 = [9 x i8] c"3.3x^4.4\00"
@.str.8 = [23 x i8] c"18.15x^6.60+3.30x^5.40\00"
@.str.9 = [2 x i8] c"x\00"
@.str.10 = [4 x i8] c"x^2\00"
@.str.11 = [4 x i8] c"x+x\00"
@.str.12 = [5 x i8] c"4x^2\00"
@.str.13 = [2 x i8] c"0\00"
@.str.14 = [2 x i8] c"1\00"
define i32 @test_polynomial_multiplication() {
%1 = tail call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 2)
%2 = tail call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0), i32 2)
%3 = add i64 %2, %1
%4 = tail call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 2)
%5 = add i64 %3, %4
%6 = tail call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 0)
%7 = add i64 %5, %6
%8 = tail call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 0)
%9 = add i64 %7, %8
%10 = tail call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i32 0)
%11 = add i64 %9, %10
%12 = tail call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 0)
%13 = add i64 %11, %12
%14 = tail call i64 @check_polynomial_multiplication(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i32 0)
%15 = add i64 %13, %14
%16 = trunc i64 %15 to i32
ret i32 %16
}