#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 NAN;
int sscanf(char *, char *, char *, double *);
int /*<<< orphan*/ strcpy(char *, char *);
double get_tagged_number(char *tag, char *line) {
  char buf[0x100];
  double x;
  int r = sscanf(line, "%[^:]: %lf", buf, &x);
  strcpy(tag, buf);
  if (r == 2) {
    return x;
  } else
    return NAN;
}


x86 assembly (clang, -O0):
<get_tagged_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xebb(%rip),%rsi
lea    -0x128(%rbp),%rcx
call   1040 <sscanf@plt>
mov    %eax,-0x12c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1030 <strcpy@plt>
cmpl   $0x2,-0x12c(%rbp)
jne    1186 <get_tagged_number+0x66>
movsd  -0x128(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    1196 <get_tagged_number+0x76>
mov    0x2e6b(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tagged_number>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xec6(%rip),%rsi
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%rbx
mov    %rax,%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1040 <sscanf@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
cmp    $0x2,%ebp
je     116b <get_tagged_number+0x4b>
mov    0x2e8d(%rip),%rbx
movsd  (%rbx),%xmm0
add    $0x118,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%[^:]: %lf\00"
@NAN = global double 0.000000e+00
define double @get_tagged_number(i8* %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [256 x i8]
%7 = alloca double
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%11 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %10, double* %7)
store i32 %11, i32* %8
%12 = load i8*, i8** %4
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = load i32, i32* %8
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = load double, double* %7
store double %18, double* %3
br label %21
19: ; preds = %2
%20 = load double, double* @NAN
store double %20, double* %3
br label %21
21: ; preds = %19, %17
%22 = load double, double* %3
ret double %22
}

LLVM IR (-O2):
@.str = [11 x i8] c"%[^:]: %lf\00"
@NAN = global double 0.000000e+00
define double @get_tagged_number(i8* %0, i8* nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca double
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast double* %4 to i8*
%7 = call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %5, double* %4)
%8 = call i32 @strcpy(i8* %0, i8* %5)
%9 = icmp eq i32 %7, 2
%10 = load double, double* %4
%11 = load double, double* @NAN
%12 = select i1 %9, double %10, double %11
ret double %12
}