#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 /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
char *revstr(char *, char);
int /*<<< orphan*/ stderr;
double strtod(char *, char **);
double getWeight(char *szID) {
  char *szBreak = revstr(szID, '_');
  double dWeight = 0.0;
  char *pcError = NULL;
  if (szBreak != NULL) {
    dWeight = strtod(szBreak + 1, &pcError);
    if (*pcError != '\0') {
      fprintf(stderr, "Sequence weight format error %s %s\n", szID,
              szBreak + 1);
      fflush(stderr);
    }
  } else {
    dWeight = 1.0;
  }
  return dWeight;
}


x86 assembly (clang, -O0):
<getWeight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x5f,%esi
call   1030 <revstr@plt>
mov    %rax,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11d3 <getWeight+0x93>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    -0x20(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ce <getWeight+0x8e>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
lea    0xe4d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
jmp    11e0 <getWeight+0xa0>
movsd  0xe25(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getWeight>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    $0x5f,%esi
call   1030 <revstr@plt>
movq   $0x0,(%rsp)
test   %rax,%rax
je     11b0 <getWeight+0x70>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <strtod@plt>
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     11b8 <getWeight+0x78>
mov    0x2e5b(%rip),%r15
mov    (%r15),%edi
lea    0xe79(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
movsd  %xmm0,0x8(%rsp)
call   1050 <fprintf@plt>
mov    (%r15),%edi
call   1060 <fflush@plt>
movsd  0x8(%rsp),%xmm0
jmp    11b8 <getWeight+0x78>
movsd  0xe48(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Sequence weight format error %s %s\0A\00"
define double @getWeight(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca double
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @revstr(i8* %6, i8 signext 95)
store i8* %7, i8** %3
store double 0.000000e+00, double* %4
store i8* null, i8** %5
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %27
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = call double @strtod(i8* %12, i8** %5)
store double %13, double* %4
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %2
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %20, i8* %22)
%24 = load i32, i32* @stderr
%25 = call i32 @fflush(i32 %24)
br label %26
26: ; preds = %18, %10
br label %28
27: ; preds = %1
store double 1.000000e+00, double* %4
br label %28
28: ; preds = %27, %26
%29 = load double, double* %4
ret double %29
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Sequence weight format error %s %s\0A\00"
define double @getWeight(i8* %0) {
%2 = alloca i8*
%3 = tail call i8* @revstr(i8* %0, i8 signext 95)
%4 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%5 = icmp eq i8* %3, null
br i1 %5, label %17, label %6
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %3, i64 1
%8 = call double @strtod(i8* %7, i8** %2)
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %6
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %7)
%15 = load i32, i32* @stderr
%16 = tail call i32 @fflush(i32 %15)
br label %17
17: ; preds = %1, %6, %12
%18 = phi double [ %8, %12 ], [ %8, %6 ], [ 1.000000e+00, %1 ]
ret double %18
}