#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 */
char atoi(char *);
scalar_t__ isdigit(char const);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strtok(char *, char *);
int make_coef(const char *term_str) {
  printf("\t\t\tmake_coef(%s) ", term_str);
  char str[40] = {'$'};
  signed char sign = 1;
  int i = 0;
  while (isdigit(term_str[i]) || term_str[i] == '-') {
    str[i] = term_str[i];
    ++i;
  }
  if (str[0] == '-')
    sign = -1;
  strtok(str, "$");
  printf("\treturned %d\n", atoi(str));
  return (sign * atoi(str));
}


x86 assembly (clang, -O0):
<make_coef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
movb   $0x24,-0x30(%rbp)
movb   $0x1,-0x31(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x39(%rbp)
jne    11c5 <make_coef+0x75>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
sete   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11d5 <make_coef+0x85>
jmp    11f6 <make_coef+0xa6>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x38(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    118d <make_coef+0x3d>
movsbl -0x30(%rbp),%eax
cmp    $0x2d,%eax
jne    1207 <make_coef+0xb7>
movb   $0xff,-0x31(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe00(%rip),%rsi
call   1060 <strtok@plt>
lea    -0x30(%rbp),%rdi
call   1070 <atoi@plt>
movsbl %al,%esi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x31(%rbp),%eax
mov    %eax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
call   1070 <atoi@plt>
mov    %al,%cl
mov    -0x40(%rbp),%eax
movsbl %cl,%ecx
imul   %ecx,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_coef>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%r14
lea    0xeae(%rip),%rdi
xor    %ebx,%ebx
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
movb   $0x24,(%rsp)
jmp    1187 <make_coef+0x47>
nopl   0x0(%rax)
mov    %cl,(%rsp,%rbx,1)
add    $0x1,%rbx
movsbl (%r14,%rbx,1),%edi
call   1030 <isdigit@plt>
movzbl (%r14,%rbx,1),%ecx
test   %rax,%rax
jne    1180 <make_coef+0x40>
cmp    $0x2d,%cl
mov    $0x2d,%cl
je     1180 <make_coef+0x40>
mov    (%rsp),%bpl
lea    0xe65(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <strtok@plt>
mov    %rbx,%rdi
call   1060 <atoi@plt>
movsbl %al,%esi
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <atoi@plt>
movsbl %al,%ecx
mov    %ecx,%eax
neg    %eax
cmp    $0x2d,%bpl
cmovne %ecx,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"\09\09\09make_coef(%s) \00"
@.str.1 = [2 x i8] c"$\00"
@.str.2 = [14 x i8] c"\09returned %d\0A\00"
define i32 @make_coef(i8* %0) {
%2 = alloca i8*
%3 = alloca [40 x i8]
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = bitcast [40 x i8]* %3 to i8*
%9 = bitcast i8* %8 to <{ i8, [39 x i8] }>*
%10 = getelementptr inbounds <{ i8, [39 x i8] }>, <{ i8, [39 x i8] }>* %9, i32 0, i32 0
store i8 36, i8* %10
store i8 1, i8* %4
store i32 0, i32* %5
br label %11
11: ; preds = %29, %1
%12 = load i8*, i8** %2
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = call i64 @isdigit(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %11
%20 = load i8*, i8** %2
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 45
br label %27
27: ; preds = %19, %11
%28 = phi i1 [ true, %11 ], [ %26, %19 ]
br i1 %28, label %29, label %40
29: ; preds = %27
%30 = load i8*, i8** %2
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 %36
store i8 %34, i8* %37
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %11
40: ; preds = %27
%41 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 45
br i1 %44, label %45, label %46
45: ; preds = %40
store i8 -1, i8* %4
br label %46
46: ; preds = %45, %40
%47 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%48 = call i32 @strtok(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%49 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%50 = call signext i8 @atoi(i8* %49)
%51 = sext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = load i8, i8* %4
%54 = sext i8 %53 to i32
%55 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%56 = call signext i8 @atoi(i8* %55)
%57 = sext i8 %56 to i32
%58 = mul nsw i32 %54, %57
ret i32 %58
}

LLVM IR (-O2):
@.str = [18 x i8] c"\09\09\09make_coef(%s) \00"
@.str.1 = [2 x i8] c"$\00"
@.str.2 = [14 x i8] c"\09returned %d\0A\00"
define i32 @make_coef(i8* %0) {
%2 = alloca [40 x i8]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
store i8 36, i8* %4
br label %5
5: ; preds = %14, %1
%6 = phi i64 [ %17, %14 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = tail call i64 @isdigit(i8 signext %8)
%10 = icmp eq i64 %9, 0
%11 = load i8, i8* %7
br i1 %10, label %12, label %14
12: ; preds = %5
%13 = icmp eq i8 %11, 45
br i1 %13, label %14, label %18
14: ; preds = %5, %12
%15 = phi i8 [ 45, %12 ], [ %11, %5 ]
%16 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 %6
store i8 %15, i8* %16
%17 = add nuw i64 %6, 1
br label %5
18: ; preds = %12
%19 = load i8, i8* %4
%20 = icmp eq i8 %19, 45
%21 = call i32 @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = call signext i8 @atoi(i8* %4)
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = call signext i8 @atoi(i8* %4)
%26 = sext i8 %25 to i32
%27 = sub nsw i32 0, %26
%28 = select i1 %20, i32 %27, i32 %26
ret i32 %28
}