#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*/ _helper_end_get_params();
char *_helper_get_first_param(char const *);
char *_helper_get_next_param();
int /*<<< orphan*/ _helper_insert_polynome_table_node(char, double *, int);
scalar_t__ isalpha(char);
double *malloc(int);
int /*<<< orphan*/ printf(char *);
int strlen(char const *);
double strtod(char *, int /*<<< orphan*/ *);
void define_polynome(const char *params) {
  char *ptr, name;
  double *cparams;
  int pcount;
  ptr = _helper_get_first_param(params);
  if (isalpha((name = *ptr))) {
    pcount = 0;
    cparams = malloc(sizeof(*cparams) * (strlen(params)));
    while ((ptr = _helper_get_next_param())) {
      cparams[pcount++] = strtod(ptr, NULL);
    }
    _helper_insert_polynome_table_node(name, cparams, pcount - 1);
  } else
    printf("Syntax error!");
  _helper_end_get_params();
}


x86 assembly (clang, -O0):
<define_polynome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <_helper_get_first_param@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl %al,%edi
call   1090 <isalpha@plt>
cmp    $0x0,%rax
je     123d <define_polynome+0xad>
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   10b0 <_helper_get_next_param@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1223 <define_polynome+0x93>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11e5 <define_polynome+0x55>
mov    -0x11(%rbp),%al
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
movsbl %al,%edi
call   10a0 <_helper_insert_polynome_table_node@plt>
jmp    1249 <define_polynome+0xb9>
lea    0xdbc(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <_helper_end_get_params@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<define_polynome>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbp
call   1060 <_helper_get_first_param@plt>
movsbl (%rax),%r15d
mov    %r15d,%edi
call   1090 <isalpha@plt>
test   %rax,%rax
je     1210 <define_polynome+0x80>
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    0x0(,%rax,8),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
xor    %eax,%eax
call   10b0 <_helper_get_next_param@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     1201 <define_polynome+0x71>
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
movsd  %xmm0,(%rbx)
xor    %eax,%eax
call   10b0 <_helper_get_next_param@plt>
add    $0x8,%rbx
add    $0x1,%ebp
test   %rax,%rax
jne    11e0 <define_polynome+0x50>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   10a0 <_helper_insert_polynome_table_node@plt>
jmp    121c <define_polynome+0x8c>
lea    0xde9(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <_helper_end_get_params@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"Syntax error!\00"
define void @define_polynome(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
%5 = alloca double*
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i8* @_helper_get_first_param(i8* %7)
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
store i8 %10, i8* %4
%11 = call i64 @isalpha(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %37
13: ; preds = %1
store i32 0, i32* %6
%14 = load i8*, i8** %2
%15 = call i32 @strlen(i8* %14)
%16 = sext i32 %15 to i64
%17 = mul i64 8, %16
%18 = trunc i64 %17 to i32
%19 = call double* @malloc(i32 %18)
store double* %19, double** %5
br label %20
20: ; preds = %23, %13
%21 = call i8* (...) @_helper_get_next_param()
store i8* %21, i8** %3
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = load i8*, i8** %3
%25 = call double @strtod(i8* %24, i32* null)
%26 = load double*, double** %5
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds double, double* %26, i64 %29
store double %25, double* %30
br label %20
31: ; preds = %20
%32 = load i8, i8* %4
%33 = load double*, double** %5
%34 = load i32, i32* %6
%35 = sub nsw i32 %34, 1
%36 = call i32 @_helper_insert_polynome_table_node(i8 signext %32, double* %33, i32 %35)
br label %39
37: ; preds = %1
%38 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %39
39: ; preds = %37, %31
%40 = call i32 (...) @_helper_end_get_params()
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"Syntax error!\00"
define void @define_polynome(i8* %0) {
%2 = tail call i8* @_helper_get_first_param(i8* %0)
%3 = load i8, i8* %2
%4 = tail call i64 @isalpha(i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %26, label %6
6: ; preds = %1
%7 = tail call i32 @strlen(i8* %0)
%8 = shl i32 %7, 3
%9 = tail call double* @malloc(i32 %8)
%10 = tail call i8* (...) @_helper_get_next_param()
%11 = icmp eq i8* %10, null
br i1 %11, label %23, label %12
12: ; preds = %6, %12
%13 = phi i64 [ %16, %12 ], [ 0, %6 ]
%14 = phi i8* [ %18, %12 ], [ %10, %6 ]
%15 = tail call double @strtod(i8* nocapture %14, i32* null)
%16 = add nuw i64 %13, 1
%17 = getelementptr inbounds double, double* %9, i64 %13
store double %15, double* %17
%18 = tail call i8* (...) @_helper_get_next_param()
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %12
20: ; preds = %12
%21 = trunc i64 %16 to i32
%22 = add i32 %21, -1
br label %23
23: ; preds = %20, %6
%24 = phi i32 [ -1, %6 ], [ %22, %20 ]
%25 = tail call i32 @_helper_insert_polynome_table_node(i8 signext %3, double* %9, i32 %24)
br label %28
26: ; preds = %1
%27 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
%29 = tail call i32 (...) @_helper_end_get_params()
ret void
}