#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 */
double atof(char *);
int strspn(char *, char *);
double get_num_float(char *str) {
  int n;
  double num;
  char *tmp = str;
  if ((n = strspn(tmp, "0")) != 0 && tmp[n] != '\0')
    num = atof(&tmp[n]);
  else
    num = atof(tmp);
  return num;
}


x86 assembly (clang, -O0):
<get_num_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1040 <strspn@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     117f <get_num_float+0x5f>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     117f <get_num_float+0x5f>
mov    -0x20(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    118d <get_num_float+0x6d>
mov    -0x20(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_num_float>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rsi
call   1040 <strspn@plt>
test   %eax,%eax
je     113f <get_num_float+0x1f>
cltq
cmpb   $0x0,(%rbx,%rax,1)
je     113f <get_num_float+0x1f>
add    %rax,%rbx
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <atof@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"0\00"
define double @get_num_float(i8* nocapture %0) {
%2 = tail call i32 @strspn(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = tail call double @atof(i8* %6)
br label %13
11: ; preds = %4, %1
%12 = tail call double @atof(i8* %0)
br label %13
13: ; preds = %11, %9
%14 = phi double [ %10, %9 ], [ %12, %11 ]
ret double %14
}