#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*/ sscanf(char *, char *, int *, int *);
int strcspn(char *, char *);
char *strstr(char *, char *);
int read_a_float_value(char *buf, char *key, unsigned long long *ret, int type,
                       int len) {
  int k;
  int r, l;
  char *tmp;
  char *tmp2;
  if ((tmp = strstr(buf, key)) != NULL) {
    if (type == 0) {
      tmp = buf;
    }
    if ((tmp2 = strstr(tmp, "min")) != NULL)
      tmp = tmp2;
    k = strcspn(tmp, "0123456789");
    sscanf(tmp + k, "%d.%d", &r, &l);
    *ret = (unsigned long long)r * len + l;
    return 1;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<read_a_float_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     11f6 <read_a_float_value+0xc6>
cmpl   $0x0,-0x24(%rbp)
jne    1178 <read_a_float_value+0x48>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
je     119e <read_a_float_value+0x6e>
mov    -0x48(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1030 <strcspn@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x40(%rbp),%rdi
movslq -0x2c(%rbp),%rax
add    %rax,%rdi
lea    0xe4c(%rip),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x34(%rbp),%rcx
call   1040 <sscanf@plt>
movslq -0x30(%rbp),%rcx
movslq -0x28(%rbp),%rax
imul   %rax,%rcx
movslq -0x34(%rbp),%rax
add    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11fd <read_a_float_value+0xcd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_a_float_value>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %rdx,%r14
mov    %rdi,%rbp
call   1050 <strstr@plt>
test   %rax,%rax
je     11bb <read_a_float_value+0x8b>
mov    %rax,%rbx
test   %r12d,%r12d
cmove  %rbp,%rbx
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
cmovne %rax,%rbx
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcspn@plt>
movslq %eax,%rdi
add    %rbx,%rdi
lea    0xe81(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1040 <sscanf@plt>
movslq 0xc(%rsp),%rax
movslq %r15d,%rcx
imul   %rax,%rcx
movslq 0x8(%rsp),%rax
add    %rcx,%rax
mov    %rax,(%r14)
mov    $0x1,%eax
jmp    11bd <read_a_float_value+0x8d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"min\00"
@.str.1 = [11 x i8] c"0123456789\00"
@.str.2 = [6 x i8] c"%d.%d\00"
define i32 @read_a_float_value(i8* %0, i8* %1, i64* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i64* %2, i64** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%17 = load i8*, i8** %7
%18 = load i8*, i8** %8
%19 = call i8* @strstr(i8* %17, i8* %18)
store i8* %19, i8** %15
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %49
21: ; preds = %5
%22 = load i32, i32* %10
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = load i8*, i8** %7
store i8* %25, i8** %15
br label %26
26: ; preds = %24, %21
%27 = load i8*, i8** %15
%28 = call i8* @strstr(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %28, i8** %16
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = load i8*, i8** %16
store i8* %31, i8** %15
br label %32
32: ; preds = %30, %26
%33 = load i8*, i8** %15
%34 = call i32 @strcspn(i8* %33, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 %34, i32* %12
%35 = load i8*, i8** %15
%36 = load i32, i32* %12
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = call i32 @sscanf(i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %13, i32* %14)
%40 = load i32, i32* %13
%41 = sext i32 %40 to i64
%42 = load i32, i32* %11
%43 = sext i32 %42 to i64
%44 = mul i64 %41, %43
%45 = load i32, i32* %14
%46 = sext i32 %45 to i64
%47 = add i64 %44, %46
%48 = load i64*, i64** %9
store i64 %47, i64* %48
store i32 1, i32* %6
br label %50
49: ; preds = %5
store i32 0, i32* %6
br label %50
50: ; preds = %49, %32
%51 = load i32, i32* %6
ret i32 %51
}

LLVM IR (-O2):
@.str = [4 x i8] c"min\00"
@.str.1 = [11 x i8] c"0123456789\00"
@.str.2 = [6 x i8] c"%d.%d\00"
define i32 @read_a_float_value(i8* %0, i8* nocapture %1, i64* nocapture writeonly %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %6 to i8*
%9 = bitcast i32* %7 to i8*
%10 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%11 = icmp eq i8* %10, null
br i1 %11, label %29, label %12
12: ; preds = %5
%13 = icmp eq i32 %3, 0
%14 = select i1 %13, i8* %0, i8* %10
%15 = tail call i8* @strstr(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i8* %15, null
%17 = select i1 %16, i8* %14, i8* %15
%18 = tail call i32 @strcspn(i8* %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %6, i32* %7)
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = sext i32 %4 to i64
%25 = mul nsw i64 %23, %24
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = add nsw i64 %25, %27
store i64 %28, i64* %2
br label %29
29: ; preds = %5, %12
%30 = phi i32 [ 1, %12 ], [ 0, %5 ]
ret i32 %30
}