#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_division(char *, char *, char *, int, int);
int test_polynomial_division() {
  int ret = 0;
  ret += check_polynomial_division("x^2+5x-6", "x-1", "x+6.00", 2, 0);
  ret += check_polynomial_division("x^2+5x-6", "x-1", "x+6.00", 2, 10);
  ret += check_polynomial_division("x^2+5x-6", "x-1.5", "x+6.50+3.75x^-1.00", 2,
                                   0);
  ret += check_polynomial_division(
      "x^2+5x-6", "x-1.5",
      "x+6.5000+3.7500x^-1.0000+5.6250x^-2.0000+8.4375x^-3.0000", 4, 2);
  return ret;
}


x86 assembly (clang, -O0):
<test_polynomial_division>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
lea    0xedc(%rip),%rsi
lea    0xed9(%rip),%rdx
mov    $0x2,%ecx
xor    %r8d,%r8d
call   1030 <check_polynomial_division@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xeab(%rip),%rdi
lea    0xead(%rip),%rsi
lea    0xeaa(%rip),%rdx
mov    $0x2,%ecx
mov    $0xa,%r8d
call   1030 <check_polynomial_division@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xe79(%rip),%rdi
lea    0xe86(%rip),%rsi
lea    0xe85(%rip),%rdx
mov    $0x2,%ecx
xor    %r8d,%r8d
call   1030 <check_polynomial_division@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
lea    0xe4a(%rip),%rdi
lea    0xe57(%rip),%rsi
lea    0xe69(%rip),%rdx
mov    $0x4,%ecx
mov    $0x2,%r8d
call   1030 <check_polynomial_division@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_division>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xee0(%rip),%r14
lea    0xee2(%rip),%r12
lea    0xedf(%rip),%r15
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    $0x2,%ecx
xor    %r8d,%r8d
call   1030 <check_polynomial_division@plt>
mov    %rax,%r13
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    $0x2,%ecx
mov    $0xa,%r8d
call   1030 <check_polynomial_division@plt>
mov    %rax,%r12
add    %r13d,%r12d
lea    0xea7(%rip),%r15
lea    0xea6(%rip),%rdx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x2,%ecx
xor    %r8d,%r8d
call   1030 <check_polynomial_division@plt>
mov    %rax,%rbx
add    %r12d,%ebx
lea    0xe99(%rip),%rdx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%ecx
mov    $0x2,%r8d
call   1030 <check_polynomial_division@plt>
add    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r13
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 = [7 x i8] c"x+6.00\00"
@.str.3 = [6 x i8] c"x-1.5\00"
@.str.4 = [19 x i8] c"x+6.50+3.75x^-1.00\00"
@.str.5 = [57 x i8] c"x+6.5000+3.7500x^-1.0000+5.6250x^-2.0000+8.4375x^-3.0000\00"
define i32 @test_polynomial_division() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 @check_polynomial_division(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 ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 2, 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_division(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 ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 10)
%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_division(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 2, 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_division(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i32 4, i32 2)
%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 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [9 x i8] c"x^2+5x-6\00"
@.str.1 = [4 x i8] c"x-1\00"
@.str.2 = [7 x i8] c"x+6.00\00"
@.str.3 = [6 x i8] c"x-1.5\00"
@.str.4 = [19 x i8] c"x+6.50+3.75x^-1.00\00"
@.str.5 = [57 x i8] c"x+6.5000+3.7500x^-1.0000+5.6250x^-2.0000+8.4375x^-3.0000\00"
define i32 @test_polynomial_division() {
%1 = tail call i64 @check_polynomial_division(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 ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 0)
%2 = tail call i64 @check_polynomial_division(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 ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 10)
%3 = add i64 %2, %1
%4 = tail call i64 @check_polynomial_division(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 2, i32 0)
%5 = add i64 %3, %4
%6 = tail call i64 @check_polynomial_division(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i32 4, i32 2)
%7 = add i64 %5, %6
%8 = trunc i64 %7 to i32
ret i32 %8
}