#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 sscanf(char const *, char *, double *);
double compute_new_value_from_arg(const char *arg, double current_value) {
  double delta;
  if (arg && sscanf(arg, "%lf", &delta) == 1) {
    if (arg[0] == '+' || arg[0] == '-')
      current_value += delta;
    else
      current_value = delta;
  }
  return current_value;
}


x86 assembly (clang, -O0):
<compute_new_value_from_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     118c <compute_new_value_from_arg+0x7c>
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <sscanf@plt>
cmp    $0x1,%eax
jne    118c <compute_new_value_from_arg+0x7c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
je     1169 <compute_new_value_from_arg+0x59>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    117d <compute_new_value_from_arg+0x6d>
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1187 <compute_new_value_from_arg+0x77>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    118c <compute_new_value_from_arg+0x7c>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_new_value_from_arg>:
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     115c <compute_new_value_from_arg+0x4c>
mov    %rdi,%rbx
movsd  %xmm0,(%rsp)
lea    0xed7(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1030 <sscanf@plt>
cmp    $0x1,%eax
jne    114f <compute_new_value_from_arg+0x3f>
mov    (%rbx),%al
cmp    $0x2d,%al
movsd  (%rsp),%xmm0
je     1147 <compute_new_value_from_arg+0x37>
cmp    $0x2b,%al
jne    1156 <compute_new_value_from_arg+0x46>
addsd  0x8(%rsp),%xmm0
jmp    115c <compute_new_value_from_arg+0x4c>
movsd  (%rsp),%xmm0
jmp    115c <compute_new_value_from_arg+0x4c>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
define double @compute_new_value_from_arg(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
%5 = alloca double
store i8* %0, i8** %3
store double %1, double* %4
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %31
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %5)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %31
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 43
br i1 %17, label %24, label %18
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 45
br i1 %23, label %24, label %28
24: ; preds = %18, %12
%25 = load double, double* %5
%26 = load double, double* %4
%27 = fadd double %26, %25
store double %27, double* %4
br label %30
28: ; preds = %18
%29 = load double, double* %5
store double %29, double* %4
br label %30
30: ; preds = %28, %24
br label %31
31: ; preds = %30, %8, %2
%32 = load double, double* %4
ret double %32
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
define double @compute_new_value_from_arg(i8* %0, double %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = icmp eq i8* %0, null
br i1 %5, label %16, label %6
6: ; preds = %2
%7 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %3)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i8, i8* %0
switch i8 %10, label %14 [
i8 43, label %11
i8 45, label %11
]
11: ; preds = %9, %9
%12 = load double, double* %3
%13 = fadd double %12, %1
br label %16
14: ; preds = %9
%15 = load double, double* %3
br label %16
16: ; preds = %11, %14, %6, %2
%17 = phi double [ %13, %11 ], [ %15, %14 ], [ %1, %6 ], [ %1, %2 ]
ret double %17
}