#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_addition(char *, char *, char *, int);
int test_polynomial_addition() {
  int ret = 0;
  ret += check_polynomial_addition("x^2+5x+6", "x-1", "x^2+6x+5", 0);
  ret +=
      check_polynomial_addition("x^2.3+5.6x+6.6", "x-1.1", "x^2.3+6.6x+5.5", 1);
  ret += check_polynomial_addition("x^2", "x^-2", "x^2+x^-2", 0);
  ret += check_polynomial_addition("x^-2", "x^-2", "2x^-2", 0);
  ret += check_polynomial_addition("3.14x^-2.22-333", "93.3x^-2333+333",
                                   "3.140x^-2.220+93.300x^-2333.000", 3);
  return ret;
}


x86 assembly (clang, -O0):
<test_polynomial_addition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
lea    0xedc(%rip),%rsi
lea    0xed9(%rip),%rdx
xor    %ecx,%ecx
call   1030 <check_polynomial_addition@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xec7(%rip),%rdi
lea    0xecf(%rip),%rsi
lea    0xece(%rip),%rdx
mov    $0x1,%ecx
call   1030 <check_polynomial_addition@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xebf(%rip),%rdi
lea    0xec0(%rip),%rsi
lea    0xeb5(%rip),%rdx
xor    %ecx,%ecx
call   1030 <check_polynomial_addition@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xe9e(%rip),%rsi
lea    0xe9c(%rip),%rdx
xor    %ecx,%ecx
mov    %rsi,%rdi
call   1030 <check_polynomial_addition@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xe84(%rip),%rdi
lea    0xe8d(%rip),%rsi
lea    0xe96(%rip),%rdx
mov    $0x3,%ecx
call   1030 <check_polynomial_addition@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_addition>:
push   %r15
push   %r14
push   %rbx
lea    0xee4(%rip),%rdi
lea    0xee6(%rip),%rsi
lea    0xee3(%rip),%rdx
xor    %ecx,%ecx
call   1030 <check_polynomial_addition@plt>
mov    %rax,%r14
lea    0xedb(%rip),%rdi
lea    0xee3(%rip),%rsi
lea    0xee2(%rip),%rdx
mov    $0x1,%ecx
call   1030 <check_polynomial_addition@plt>
mov    %rax,%r15
add    %r14d,%r15d
lea    0xeda(%rip),%rdi
lea    0xedb(%rip),%r14
lea    0xed0(%rip),%rdx
mov    %r14,%rsi
xor    %ecx,%ecx
call   1030 <check_polynomial_addition@plt>
mov    %rax,%rbx
add    %r15d,%ebx
lea    0xec2(%rip),%rdx
mov    %r14,%rdi
mov    %r14,%rsi
xor    %ecx,%ecx
call   1030 <check_polynomial_addition@plt>
mov    %rax,%r14
add    %ebx,%r14d
lea    0xeae(%rip),%rdi
lea    0xeb7(%rip),%rsi
lea    0xec0(%rip),%rdx
mov    $0x3,%ecx
call   1030 <check_polynomial_addition@plt>
add    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"x^2+5x+6\00"
@.str.1 = [4 x i8] c"x-1\00"
@.str.2 = [9 x i8] c"x^2+6x+5\00"
@.str.3 = [15 x i8] c"x^2.3+5.6x+6.6\00"
@.str.4 = [6 x i8] c"x-1.1\00"
@.str.5 = [15 x i8] c"x^2.3+6.6x+5.5\00"
@.str.6 = [4 x i8] c"x^2\00"
@.str.7 = [5 x i8] c"x^-2\00"
@.str.8 = [9 x i8] c"x^2+x^-2\00"
@.str.9 = [6 x i8] c"2x^-2\00"
@.str.10 = [16 x i8] c"3.14x^-2.22-333\00"
@.str.11 = [16 x i8] c"93.3x^-2333+333\00"
@.str.12 = [32 x i8] c"3.140x^-2.220+93.300x^-2333.000\00"
define i32 @test_polynomial_addition() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 @check_polynomial_addition(i8* getelementptr inbounds ([9 x i8], [9 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 ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 0)
%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_addition(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 1)
%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_addition(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 0)
%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_addition(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, 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_addition(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0), i32 3)
%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 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [9 x i8] c"x^2+5x+6\00"
@.str.1 = [4 x i8] c"x-1\00"
@.str.2 = [9 x i8] c"x^2+6x+5\00"
@.str.3 = [15 x i8] c"x^2.3+5.6x+6.6\00"
@.str.4 = [6 x i8] c"x-1.1\00"
@.str.5 = [15 x i8] c"x^2.3+6.6x+5.5\00"
@.str.6 = [4 x i8] c"x^2\00"
@.str.7 = [5 x i8] c"x^-2\00"
@.str.8 = [9 x i8] c"x^2+x^-2\00"
@.str.9 = [6 x i8] c"2x^-2\00"
@.str.10 = [16 x i8] c"3.14x^-2.22-333\00"
@.str.11 = [16 x i8] c"93.3x^-2333+333\00"
@.str.12 = [32 x i8] c"3.140x^-2.220+93.300x^-2333.000\00"
define i32 @test_polynomial_addition() {
%1 = tail call i64 @check_polynomial_addition(i8* getelementptr inbounds ([9 x i8], [9 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 ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 0)
%2 = tail call i64 @check_polynomial_addition(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 1)
%3 = add i64 %2, %1
%4 = tail call i64 @check_polynomial_addition(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 0)
%5 = add i64 %3, %4
%6 = tail call i64 @check_polynomial_addition(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 0)
%7 = add i64 %5, %6
%8 = tail call i64 @check_polynomial_addition(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0), i32 3)
%9 = add i64 %7, %8
%10 = trunc i64 %9 to i32
ret i32 %10
}