#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 sscanf(char *, char *, float *);
char *strstr(char const *, char const *);
gcode_parse_float(const char *line, const char *key, float *val) {
  char *find = strstr(line, key);
  int ret;
  if (find == NULL)
    return -1;
  find++;
  ret = sscanf(find, "%f", val);
  if (ret == 1)
    return 0;
  return -1;
}


x86 assembly (clang, -O0):
<gcode_parse_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    115c <gcode_parse_float+0x3c>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <gcode_parse_float+0x7c>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe89(%rip),%rsi
call   1030 <sscanf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x1,-0x2c(%rbp)
jne    1195 <gcode_parse_float+0x75>
movl   $0x0,-0x4(%rbp)
jmp    119c <gcode_parse_float+0x7c>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gcode_parse_float>:
push   %rbx
mov    %rdx,%rbx
call   1040 <strstr@plt>
test   %rax,%rax
je     1152 <gcode_parse_float+0x32>
add    $0x1,%rax
lea    0xec7(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1030 <sscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
setne  %al
neg    %eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
define i32 @gcode_parse_float(i8* %0, i8* nocapture %1, float* %2) {
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
%8 = tail call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %2)
%9 = icmp ne i32 %8, 1
%10 = sext i1 %9 to i32
br label %11
11: ; preds = %6, %3
%12 = phi i32 [ -1, %3 ], [ %10, %6 ]
ret i32 %12
}