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


x86 assembly (clang, -O0):
<make_exp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
movb   $0x24,-0x40(%rbp)
movb   $0x1,-0x41(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    -0x48(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11d9 <make_exp+0x89>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    -0x48(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x48(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1193 <make_exp+0x43>
movsbl -0x40(%rbp),%eax
cmp    $0x2d,%eax
jne    11ea <make_exp+0x9a>
movb   $0xff,-0x41(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1060 <strtok@plt>
movsbl -0x41(%rbp),%eax
mov    %eax,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
call   1070 <atoi@plt>
mov    -0x50(%rbp),%esi
movsbl %al,%eax
imul   %eax,%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x41(%rbp),%eax
mov    %eax,-0x4c(%rbp)
lea    -0x40(%rbp),%rdi
call   1070 <atoi@plt>
mov    %al,%cl
mov    -0x4c(%rbp),%eax
movsbl %cl,%ecx
imul   %ecx,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_exp>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xeae(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
movb   $0x24,(%rsp)
movslq %ebp,%rbp
movsbl (%rbx,%rbp,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11cb <make_exp+0x8b>
add    %rbp,%rbx
add    $0x1,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%rbx,%rbp,1),%eax
mov    %al,(%rsp,%rbp,1)
movsbl (%rbx,%rbp,1),%edi
add    $0x1,%rbp
call   1030 <isdigit@plt>
test   %rax,%rax
jne    11a0 <make_exp+0x60>
xor    %eax,%eax
cmpb   $0x2d,(%rsp)
setne  %al
lea    (%rax,%rax,1),%ebp
add    $0xffffffff,%ebp
jmp    11d0 <make_exp+0x90>
mov    $0x1,%ebp
lea    0xe3e(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <strtok@plt>
mov    %rbx,%rdi
call   1060 <atoi@plt>
movsbl %al,%esi
imul   %ebp,%esi
lea    0xe20(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <atoi@plt>
movsbl %al,%eax
imul   %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

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