#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__ calc(char *, int /*<<< orphan*/);
int fabs(scalar_t__);
int /*<<< orphan*/ replace_minus(char *);
int main(void) {
  char formula1[64] = "12+3*4";
  double result1 = 24;
  if (1e-10 < fabs(calc(formula1, 0) - result1)) {
    return (-1);
  }
  char formula2[64] = "3*-2";
  double result2 = -6;
  replace_minus(formula2);
  if (1e-10 < fabs(calc(formula2, 0) - result2)) {
    return (-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
movb   $0x31,-0x50(%rbp)
movb   $0x32,-0x4f(%rbp)
movb   $0x2b,-0x4e(%rbp)
movb   $0x33,-0x4d(%rbp)
movb   $0x2a,-0x4c(%rbp)
movb   $0x34,-0x4b(%rbp)
movsd  0xe86(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
call   1030 <calc@plt>
cvtsi2sd %rax,%xmm0
subsd  -0x58(%rbp),%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe4e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c8 <main+0x88>
movl   $0xffffffff,-0x4(%rbp)
jmp    1261 <main+0x121>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
movb   $0x33,-0xa0(%rbp)
movb   $0x2a,-0x9f(%rbp)
movb   $0x2d,-0x9e(%rbp)
movb   $0x32,-0x9d(%rbp)
movsd  0xe11(%rip),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
lea    -0xa0(%rbp),%rdi
call   1060 <replace_minus@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
call   1030 <calc@plt>
cvtsi2sd %rax,%xmm0
subsd  -0xa8(%rbp),%xmm0
ff
cvttsd2si %xmm0,%rdi
call   1050 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xdbc(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    125a <main+0x11a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1261 <main+0x121>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x332b3231,(%rsp)
movw   $0x342a,0x4(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <calc@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xe8a(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <fabs@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
jg     11eb <main+0xbb>
xorpd  %xmm0,%xmm0
movapd %xmm0,0x40(%rsp)
movapd %xmm0,0x70(%rsp)
movapd %xmm0,0x60(%rsp)
movapd %xmm0,0x50(%rsp)
movl   $0x322d2a33,0x40(%rsp)
32
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <replace_minus@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <calc@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xe32(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <fabs@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
setg   %al
neg    %eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca double
%4 = alloca [64 x i8]
%5 = alloca double
store i32 0, i32* %1
%6 = bitcast [64 x i8]* %2 to i8*
%7 = bitcast i8* %6 to [64 x i8]*
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i32 0, i32 0
store i8 49, i8* %8
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i32 0, i32 1
store i8 50, i8* %9
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i32 0, i32 2
store i8 43, i8* %10
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i32 0, i32 3
store i8 51, i8* %11
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i32 0, i32 4
store i8 42, i8* %12
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i32 0, i32 5
store i8 52, i8* %13
store double 2.400000e+01, double* %3
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%15 = call i64 @calc(i8* %14, i32 0)
%16 = sitofp i64 %15 to double
%17 = load double, double* %3
%18 = fsub double %16, %17
%19 = fptosi double %18 to i64
%20 = call i32 @fabs(i64 %19)
%21 = sitofp i32 %20 to double
%22 = fcmp olt double 1.000000e-10, %21
br i1 %22, label %23, label %24
23: ; preds = %0
store i32 -1, i32* %1
br label %44
24: ; preds = %0
%25 = bitcast [64 x i8]* %4 to i8*
%26 = bitcast i8* %25 to [64 x i8]*
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %26, i32 0, i32 0
store i8 51, i8* %27
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %26, i32 0, i32 1
store i8 42, i8* %28
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %26, i32 0, i32 2
store i8 45, i8* %29
%30 = getelementptr inbounds [64 x i8], [64 x i8]* %26, i32 0, i32 3
store i8 50, i8* %30
store double -6.000000e+00, double* %5
%31 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%32 = call i32 @replace_minus(i8* %31)
%33 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%34 = call i64 @calc(i8* %33, i32 0)
%35 = sitofp i64 %34 to double
%36 = load double, double* %5
%37 = fsub double %35, %36
%38 = fptosi double %37 to i64
%39 = call i32 @fabs(i64 %38)
%40 = sitofp i32 %39 to double
%41 = fcmp olt double 1.000000e-10, %40
br i1 %41, label %42, label %43
42: ; preds = %24
store i32 -1, i32* %1
br label %44
43: ; preds = %24
store i32 0, i32* %1
br label %44
44: ; preds = %43, %42, %23
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [64 x i8]
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
store i8 49, i8* %3
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 1
store i8 50, i8* %4
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 2
store i8 43, i8* %5
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 3
store i8 51, i8* %6
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 4
store i8 42, i8* %7
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 5
store i8 52, i8* %8
%9 = call i64 @calc(i8* %3, i32 0)
%10 = sitofp i64 %9 to double
%11 = fadd double %10, -2.400000e+01
%12 = fptosi double %11 to i64
%13 = call i32 @fabs(i64 %12)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %28, label %15
15: ; preds = %0
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
store i8 51, i8* %16
%17 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 1
store i8 42, i8* %17
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 2
store i8 45, i8* %18
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 3
store i8 50, i8* %19
%20 = call i32 @replace_minus(i8* %16)
%21 = call i64 @calc(i8* %16, i32 0)
%22 = sitofp i64 %21 to double
%23 = fadd double %22, 6.000000e+00
%24 = fptosi double %23 to i64
%25 = call i32 @fabs(i64 %24)
%26 = icmp sgt i32 %25, 0
%27 = sext i1 %26 to i32
br label %28
28: ; preds = %0, %15
%29 = phi i32 [ %27, %15 ], [ -1, %0 ]
ret i32 %29
}