#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  scalar_t__ rm_so;
  scalar_t__ rm_eo;
};
typedef TYPE_1__ regmatch_t;
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int /*<<< orphan*/ REG_EXTENDED;
int REG_NOMATCH;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
char pow(int, int);
int regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ regerror(int, int /*<<< orphan*/ *, char *, int);
int regexec(int /*<<< orphan*/ *, char *, size_t, TYPE_1__ *,
            int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int slength(char *);
int /*<<< orphan*/ stderr;
char *substring(char *, scalar_t__, scalar_t__);
double str2num(char *numstring) {
  regex_t regex;
  char num_re[] = "^(-?)(0|[1-9][0-9]*)\\.?([0-9]*)$";
  size_t nmatch = 4;
  regmatch_t pmatch[nmatch];
  int re_err;
  char err_msg[1000];
  int e;
  char *s;
  int s_l;
  double value = 0.0;
  if ((re_err = regcomp(&regex, num_re, REG_EXTENDED))) {
    fprintf(stderr, "Could not compile regex\n");
    exit(1);
  }
  if (!(re_err = regexec(&regex, numstring, nmatch, pmatch, 0))) {
    s = substring(numstring, pmatch[2].rm_so, pmatch[2].rm_eo - 1);
    s_l = slength(s);
    for (e = 0; s[e] != '\0'; ++e) {
      value = value + (s[e] - '0') * pow(10, s_l - (e + 1));
    }
    if (pmatch[3].rm_eo - pmatch[3].rm_so > 0) {
      s = substring(numstring, pmatch[3].rm_so, pmatch[3].rm_eo - 1);
      s_l = slength(s);
      for (e = 0; s[e] != '\0'; ++e) {
        value = value + (s[e] - '0') * pow(10, -(e + 1));
      }
    }
    if (pmatch[1].rm_eo - pmatch[1].rm_so > 0) {
      value = value * -1;
    }
  } else if (re_err == REG_NOMATCH) {
    fprintf(stderr, "Source string does not have a good number format: %s\n",
            numstring);
    exit(1);
  } else {
    regerror(re_err, &regex, err_msg, sizeof(char) * 1000);
    fprintf(stderr, "Regex match failed: %s\n", err_msg);
    exit(1);
  }
  free(s);
  regfree(&regex);
  return value;
}


x86 assembly (clang, -O0):
<str2num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
mov    %rdi,-0x8(%rbp)
movaps 0xe6a(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movaps 0xe4f(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
movb   $0x0,-0x10(%rbp)
movq   $0x4,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rdx
shl    $0x4,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x468(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x460(%rbp)
ff
lea    -0x30(%rbp),%rsi
mov    0x2dc3(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rdi
call   1060 <regcomp@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
je     1245 <str2num+0xa5>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
lea    0xdfd(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x468(%rbp),%rcx
mov    -0x8(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    -0xc(%rbp),%rdi
xor    %r8d,%r8d
call   1090 <regexec@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
jne    1470 <str2num+0x2d0>
mov    -0x468(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    0x20(%rax),%rsi
mov    0x28(%rax),%rdx
sub    $0x1,%rdx
call   1050 <substring@plt>
mov    %rax,-0x450(%rbp)
mov    -0x450(%rbp),%rdi
call   10c0 <slength@plt>
mov    %eax,-0x454(%rbp)
movl   $0x0,-0x444(%rbp)
mov    -0x450(%rbp),%rax
movslq -0x444(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1346 <str2num+0x1a6>
movsd  -0x460(%rbp),%xmm0
ff
movsd  %xmm0,-0x478(%rbp)
ff
mov    -0x450(%rbp),%rax
movslq -0x444(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x46c(%rbp)
mov    -0x454(%rbp),%esi
mov    -0x444(%rbp),%eax
add    $0x1,%eax
sub    %eax,%esi
mov    $0xa,%edi
call   10a0 <pow@plt>
movsd  -0x478(%rbp),%xmm0
ff
mov    %al,%cl
mov    -0x46c(%rbp),%eax
movsbl %cl,%ecx
imul   %ecx,%eax
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x460(%rbp)
ff
mov    -0x444(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x444(%rbp)
jmp    12ab <str2num+0x10b>
mov    -0x468(%rbp),%rcx
mov    0x38(%rcx),%rax
sub    0x30(%rcx),%rax
cmp    $0x0,%rax
jle    143a <str2num+0x29a>
mov    -0x468(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    0x30(%rax),%rsi
mov    0x38(%rax),%rdx
sub    $0x1,%rdx
call   1050 <substring@plt>
mov    %rax,-0x450(%rbp)
mov    -0x450(%rbp),%rdi
call   10c0 <slength@plt>
mov    %eax,-0x454(%rbp)
movl   $0x0,-0x444(%rbp)
mov    -0x450(%rbp),%rax
movslq -0x444(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1435 <str2num+0x295>
movsd  -0x460(%rbp),%xmm0
ff
movsd  %xmm0,-0x488(%rbp)
ff
mov    -0x450(%rbp),%rax
movslq -0x444(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x47c(%rbp)
mov    -0x444(%rbp),%eax
add    $0x1,%eax
xor    %esi,%esi
sub    %eax,%esi
mov    $0xa,%edi
call   10a0 <pow@plt>
movsd  -0x488(%rbp),%xmm0
ff
mov    %al,%cl
mov    -0x47c(%rbp),%eax
movsbl %cl,%ecx
imul   %ecx,%eax
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x460(%rbp)
ff
mov    -0x444(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x444(%rbp)
jmp    139e <str2num+0x1fe>
jmp    143a <str2num+0x29a>
mov    -0x468(%rbp),%rcx
mov    0x18(%rcx),%rax
sub    0x10(%rcx),%rax
cmp    $0x0,%rax
jle    146b <str2num+0x2cb>
movsd  0xba5(%rip),%xmm0
mulsd  -0x460(%rbp),%xmm0
ff
movsd  %xmm0,-0x460(%rbp)
ff
jmp    14e7 <str2num+0x347>
mov    -0x4c(%rbp),%eax
mov    0x2b6e(%rip),%rcx
cmp    (%rcx),%eax
jne    14a7 <str2num+0x307>
mov    0x2b4f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xbb4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x4c(%rbp),%edi
lea    -0x440(%rbp),%rdx
lea    -0xc(%rbp),%rsi
mov    $0x3e8,%ecx
call   1080 <regerror@plt>
mov    0x2b12(%rip),%rax
mov    (%rax),%edi
lea    -0x440(%rbp),%rdx
lea    0xbaa(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x450(%rbp),%rdi
call   1030 <free@plt>
lea    -0xc(%rbp),%rdi
call   1040 <regfree@plt>
movsd  -0x460(%rbp),%xmm0
ff
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str2num>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x478,%rsp
mov    %rdi,%r14
mov    %rsp,%r15
movaps 0xe62(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe46(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movb   $0x0,0x40(%rsp)
mov    0x2df5(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rdi
lea    0x20(%rsp),%rsi
call   1060 <regcomp@plt>
test   %eax,%eax
jne    1385 <str2num+0x1e5>
lea    0xc(%rsp),%rdi
lea    0x50(%rsp),%rcx
mov    $0x4,%edx
mov    %r14,%rsi
xor    %r8d,%r8d
call   1090 <regexec@plt>
test   %eax,%eax
jne    13a6 <str2num+0x206>
mov    0x70(%rsp),%rsi
mov    0x78(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    %r14,%rdi
call   1050 <substring@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   10c0 <slength@plt>
mov    %eax,%r13d
mov    (%r12),%al
test   %al,%al
je     129b <str2num+0xfb>
lea    0x1(%r12),%rbx
add    $0xffffffff,%r13d
xorps  %xmm0,%xmm0
xchg   %ax,%ax
movaps %xmm0,0x10(%rsp)
movsbl %al,%ebp
add    $0xffffffd0,%ebp
mov    $0xa,%edi
mov    %r13d,%esi
call   10a0 <pow@plt>
movsbl %al,%eax
imul   %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movaps 0x10(%rsp),%xmm0
movzbl (%rbx),%eax
add    $0x1,%rbx
add    $0xffffffff,%r13d
test   %al,%al
jne    1250 <str2num+0xb0>
jmp    129e <str2num+0xfe>
xorps  %xmm0,%xmm0
mov    0x80(%rsp),%rsi
mov    0x88(%rsp),%rdx
cmp    %rsi,%rdx
jle    1341 <str2num+0x1a1>
movaps %xmm0,0x10(%rsp)
add    $0xffffffffffffffff,%rdx
mov    %r14,%rdi
call   1050 <substring@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   10c0 <slength@plt>
mov    (%r12),%al
test   %al,%al
je     133c <str2num+0x19c>
mov    %r12,%rbx
add    $0x1,%rbx
mov    $0xffffffff,%ebp
movaps 0x10(%rsp),%xmm0
nopl   0x0(%rax)
movaps %xmm0,0x10(%rsp)
movsbl %al,%r14d
add    $0xffffffd0,%r14d
mov    $0xa,%edi
mov    %ebp,%esi
call   10a0 <pow@plt>
movsbl %al,%eax
imul   %r14d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movaps 0x10(%rsp),%xmm0
movzbl (%rbx),%eax
add    $0xffffffff,%ebp
add    $0x1,%rbx
test   %al,%al
jne    12f0 <str2num+0x150>
jmp    1341 <str2num+0x1a1>
movaps 0x10(%rsp),%xmm0
mov    0x68(%rsp),%rax
cmp    0x60(%rsp),%rax
jle    1354 <str2num+0x1b4>
xorps  0xcac(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %r12,%rdi
call   1030 <free@plt>
lea    0xc(%rsp),%rdi
call   1040 <regfree@plt>
mov    %r15,%rsp
movaps 0x10(%rsp),%xmm0
add    $0x478,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c4c(%rip),%rax
mov    (%rax),%edi
lea    0xc9c(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2c3b(%rip),%rcx
cmp    (%rcx),%eax
jne    13c6 <str2num+0x226>
mov    0x2c20(%rip),%rax
mov    (%rax),%edi
lea    0xc89(%rip),%rsi
mov    %r14,%rdx
jmp    13f5 <str2num+0x255>
lea    0xc(%rsp),%rsi
lea    0x90(%rsp),%rbx
mov    %eax,%edi
mov    %rbx,%rdx
mov    $0x3e8,%ecx
call   1080 <regerror@plt>
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
lea    0xc8e(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i64 }
@__const.str2num.num_re = [33 x i8] c"^(-?)(0|[1-9][0-9]*)\\.?([0-9]*)$\00"
@REG_EXTENDED = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"Could not compile regex\0A\00"
@REG_NOMATCH = global i32 0
@.str.1 = [54 x i8] c"Source string does not have a good number format: %s\0A\00"
@.str.2 = [24 x i8] c"Regex match failed: %s\0A\00"
define double @str2num(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [33 x i8]
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca [1000 x i8]
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca double
store i8* %0, i8** %2
%14 = bitcast [33 x i8]* %4 to i8*
store i64 4, i64* %5
%15 = load i64, i64* %5
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %6
%17 = alloca %struct.TYPE_3__, i64 %15
store i64 %15, i64* %7
store double 0.000000e+00, double* %13
%18 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%19 = load i32, i32* @REG_EXTENDED
%20 = call i32 @regcomp(i32* %3, i8* %18, i32 %19)
store i32 %20, i32* %8
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %1
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %1
%27 = load i8*, i8** %2
%28 = load i64, i64* %5
%29 = call i32 @regexec(i32* %3, i8* %27, i64 %28, %struct.TYPE_3__* %17, i32 0)
store i32 %29, i32* %8
%30 = icmp ne i32 %29, 0
br i1 %30, label %135, label %31
31: ; preds = %26
%32 = load i8*, i8** %2
%33 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 2
%34 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %33, i32 0, i32 0
%35 = load i64, i64* %34
%36 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 2
%37 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %36, i32 0, i32 1
%38 = load i64, i64* %37
%39 = sub nsw i64 %38, 1
%40 = call i8* @substring(i8* %32, i64 %35, i64 %39)
store i8* %40, i8** %11
%41 = load i8*, i8** %11
%42 = call i32 @slength(i8* %41)
store i32 %42, i32* %12
store i32 0, i32* %10
br label %43
43: ; preds = %69, %31
%44 = load i8*, i8** %11
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %72
51: ; preds = %43
%52 = load double, double* %13
%53 = load i8*, i8** %11
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = sub nsw i32 %58, 48
%60 = load i32, i32* %12
%61 = load i32, i32* %10
%62 = add nsw i32 %61, 1
%63 = sub nsw i32 %60, %62
%64 = call signext i8 @pow(i32 10, i32 %63)
%65 = sext i8 %64 to i32
%66 = mul nsw i32 %59, %65
%67 = sitofp i32 %66 to double
%68 = fadd double %52, %67
store double %68, double* %13
br label %69
69: ; preds = %51
%70 = load i32, i32* %10
%71 = add nsw i32 %70, 1
store i32 %71, i32* %10
br label %43
72: ; preds = %43
%73 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 3
%74 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %73, i32 0, i32 1
%75 = load i64, i64* %74
%76 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 3
%77 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %76, i32 0, i32 0
%78 = load i64, i64* %77
%79 = sub nsw i64 %75, %78
%80 = icmp sgt i64 %79, 0
br i1 %80, label %81, label %122
81: ; preds = %72
%82 = load i8*, i8** %2
%83 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 3
%84 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %83, i32 0, i32 0
%85 = load i64, i64* %84
%86 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 3
%87 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %86, i32 0, i32 1
%88 = load i64, i64* %87
%89 = sub nsw i64 %88, 1
%90 = call i8* @substring(i8* %82, i64 %85, i64 %89)
store i8* %90, i8** %11
%91 = load i8*, i8** %11
%92 = call i32 @slength(i8* %91)
store i32 %92, i32* %12
store i32 0, i32* %10
br label %93
93: ; preds = %118, %81
%94 = load i8*, i8** %11
%95 = load i32, i32* %10
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %121
101: ; preds = %93
%102 = load double, double* %13
%103 = load i8*, i8** %11
%104 = load i32, i32* %10
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %103, i64 %105
%107 = load i8, i8* %106
%108 = sext i8 %107 to i32
%109 = sub nsw i32 %108, 48
%110 = load i32, i32* %10
%111 = add nsw i32 %110, 1
%112 = sub nsw i32 0, %111
%113 = call signext i8 @pow(i32 10, i32 %112)
%114 = sext i8 %113 to i32
%115 = mul nsw i32 %109, %114
%116 = sitofp i32 %115 to double
%117 = fadd double %102, %116
store double %117, double* %13
br label %118
118: ; preds = %101
%119 = load i32, i32* %10
%120 = add nsw i32 %119, 1
store i32 %120, i32* %10
br label %93
121: ; preds = %93
br label %122
122: ; preds = %121, %72
%123 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 1
%124 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %123, i32 0, i32 1
%125 = load i64, i64* %124
%126 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 1
%127 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %126, i32 0, i32 0
%128 = load i64, i64* %127
%129 = sub nsw i64 %125, %128
%130 = icmp sgt i64 %129, 0
br i1 %130, label %131, label %134
131: ; preds = %122
%132 = load double, double* %13
%133 = fmul double %132, -1.000000e+00
store double %133, double* %13
br label %134
134: ; preds = %131, %122
br label %152
135: ; preds = %26
%136 = load i32, i32* %8
%137 = load i32, i32* @REG_NOMATCH
%138 = icmp eq i32 %136, %137
br i1 %138, label %139, label %144
139: ; preds = %135
%140 = load i32, i32* @stderr
%141 = load i8*, i8** %2
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %141)
%143 = call i32 @exit(i32 1)
unreachable
144: ; preds = %135
%145 = load i32, i32* %8
%146 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%147 = call i32 @regerror(i32 %145, i32* %3, i8* %146, i32 1000)
%148 = load i32, i32* @stderr
%149 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%150 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %149)
%151 = call i32 @exit(i32 1)
unreachable
152: ; preds = %134
%153 = load i8*, i8** %11
%154 = call i32 @free(i8* %153)
%155 = call i32 @regfree(i32* %3)
%156 = load double, double* %13
%157 = load i8*, i8** %6
ret double %156
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i64 }
@__const.str2num.num_re = [33 x i8] c"^(-?)(0|[1-9][0-9]*)\\.?([0-9]*)$\00"
@REG_EXTENDED = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"Could not compile regex\0A\00"
@REG_NOMATCH = global i32 0
@.str.1 = [54 x i8] c"Source string does not have a good number format: %s\0A\00"
@.str.2 = [24 x i8] c"Regex match failed: %s\0A\00"
define double @str2num(i8* %0) {
%2 = alloca i32
%3 = alloca [33 x i8]
%4 = alloca [1000 x i8]
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%7 = tail call i8* @llvm.stacksave()
%8 = alloca [4 x %struct.TYPE_3__]
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%10 = load i32, i32* @REG_EXTENDED
%11 = call i32 @regcomp(i32* %2, i8* %6, i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %1
%18 = getelementptr inbounds [4 x %struct.TYPE_3__], [4 x %struct.TYPE_3__]* %8, i64 0, i64 0
%19 = call i32 @regexec(i32* %2, i8* %0, i64 4, %struct.TYPE_3__* %18, i32 0)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %90
21: ; preds = %17
%22 = getelementptr inbounds [4 x %struct.TYPE_3__], [4 x %struct.TYPE_3__]* %8, i64 0, i64 2, i32 0
%23 = load i64, i64* %22
%24 = getelementptr inbounds [4 x %struct.TYPE_3__], [4 x %struct.TYPE_3__]* %8, i64 0, i64 2, i32 1
%25 = load i64, i64* %24
%26 = add nsw i64 %25, -1
%27 = call i8* @substring(i8* %0, i64 %23, i64 %26)
%28 = call i32 @slength(i8* %27)
%29 = load i8, i8* %27
%30 = icmp eq i8 %29, 0
br i1 %30, label %48, label %31
31: ; preds = %21, %31
%32 = phi i64 [ %37, %31 ], [ 0, %21 ]
%33 = phi i8 [ %46, %31 ], [ %29, %21 ]
%34 = phi double [ %44, %31 ], [ 0.000000e+00, %21 ]
%35 = sext i8 %33 to i32
%36 = add nsw i32 %35, -48
%37 = add nuw nsw i64 %32, 1
%38 = trunc i64 %37 to i32
%39 = sub nsw i32 %28, %38
%40 = call signext i8 @pow(i32 10, i32 %39)
%41 = sext i8 %40 to i32
%42 = mul nsw i32 %36, %41
%43 = sitofp i32 %42 to double
%44 = fadd double %34, %43
%45 = getelementptr inbounds i8, i8* %27, i64 %37
%46 = load i8, i8* %45
%47 = icmp eq i8 %46, 0
br i1 %47, label %48, label %31
48: ; preds = %31, %21
%49 = phi double [ 0.000000e+00, %21 ], [ %44, %31 ]
%50 = getelementptr inbounds [4 x %struct.TYPE_3__], [4 x %struct.TYPE_3__]* %8, i64 0, i64 3, i32 1
%51 = load i64, i64* %50
%52 = getelementptr inbounds [4 x %struct.TYPE_3__], [4 x %struct.TYPE_3__]* %8, i64 0, i64 3, i32 0
%53 = load i64, i64* %52
%54 = icmp sgt i64 %51, %53
br i1 %54, label %55, label %78
55: ; preds = %48
%56 = add nsw i64 %51, -1
%57 = call i8* @substring(i8* %0, i64 %53, i64 %56)
%58 = call i32 @slength(i8* %57)
%59 = load i8, i8* %57
%60 = icmp eq i8 %59, 0
br i1 %60, label %78, label %61
61: ; preds = %55, %61
%62 = phi i64 [ %67, %61 ], [ 0, %55 ]
%63 = phi i8 [ %76, %61 ], [ %59, %55 ]
%64 = phi double [ %74, %61 ], [ %49, %55 ]
%65 = sext i8 %63 to i32
%66 = add nsw i32 %65, -48
%67 = add nuw i64 %62, 1
%68 = trunc i64 %62 to i32
%69 = xor i32 %68, -1
%70 = call signext i8 @pow(i32 10, i32 %69)
%71 = sext i8 %70 to i32
%72 = mul nsw i32 %66, %71
%73 = sitofp i32 %72 to double
%74 = fadd double %64, %73
%75 = getelementptr inbounds i8, i8* %57, i64 %67
%76 = load i8, i8* %75
%77 = icmp eq i8 %76, 0
br i1 %77, label %78, label %61
78: ; preds = %61, %55, %48
%79 = phi i8* [ %27, %48 ], [ %57, %55 ], [ %57, %61 ]
%80 = phi double [ %49, %48 ], [ %49, %55 ], [ %74, %61 ]
%81 = getelementptr inbounds [4 x %struct.TYPE_3__], [4 x %struct.TYPE_3__]* %8, i64 0, i64 1, i32 1
%82 = load i64, i64* %81
%83 = getelementptr inbounds [4 x %struct.TYPE_3__], [4 x %struct.TYPE_3__]* %8, i64 0, i64 1, i32 0
%84 = load i64, i64* %83
%85 = icmp sgt i64 %82, %84
%86 = fneg double %80
%87 = select i1 %85, double %86, double %80
%88 = call i32 @free(i8* %79)
%89 = call i32 @regfree(i32* %2)
ret double %87
90: ; preds = %17
%91 = load i32, i32* @REG_NOMATCH
%92 = icmp eq i32 %19, %91
br i1 %92, label %93, label %97
93: ; preds = %90
%94 = load i32, i32* @stderr
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%96 = call i32 @exit(i32 1)
unreachable
97: ; preds = %90
%98 = call i32 @regerror(i32 %19, i32* %2, i8* %9, i32 1000)
%99 = load i32, i32* @stderr
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%101 = call i32 @exit(i32 1)
unreachable
}