#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 */
scalar_t__ calloc(scalar_t__, size_t);
int /*<<< orphan*/ check_alloc(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ free(char *);
int sscanf(char *, char *, double *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char *);
void check_float(char *tocheck, int which) {
  double dummy;
  int found;
  char *rest;
  check_alloc(rest = (char *)calloc(strlen(tocheck) + 1, (size_t)1));
  found = sscanf(tocheck, "%lf%s", &dummy, rest);
  if (found != 1) {
    fprintf(stderr,
            "Wrong type of parameter for flag -%c. Has to be a "
            "float\n",
            which);
    exit(3);
  }
  free(rest);
}


x86 assembly (clang, -O0):
<check_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rdi
mov    %rdi,-0x28(%rbp)
call   1090 <check_alloc@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rcx
lea    0xe4c(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <sscanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
je     11ec <check_float+0x7c>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xe29(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x3,%edi
call   1080 <exit@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_float>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %rdi,%rbp
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <check_alloc@plt>
lea    0xe5d(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
jne    11c9 <check_float+0x59>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
mov    %r14d,%edx
call   1060 <fprintf@plt>
mov    $0x3,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%lf%s\00"
@stderr = global i32 0
@.str.1 = [57 x i8] c"Wrong type of parameter for flag -%c. Has to be a float\0A\00"
define void @check_float(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i8*, i8** %3
%9 = call i64 @strlen(i8* %8)
%10 = add nsw i64 %9, 1
%11 = call i64 @calloc(i64 %10, i64 1)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %7
%13 = call i32 @check_alloc(i8* %12)
%14 = load i8*, i8** %3
%15 = load i8*, i8** %7
%16 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double* %5, i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 1
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i32, i32* %4
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = call i32 @exit(i32 3)
unreachable
24: ; preds = %2
%25 = load i8*, i8** %7
%26 = call i32 @free(i8* %25)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%lf%s\00"
@stderr = global i32 0
@.str.1 = [57 x i8] c"Wrong type of parameter for flag -%c. Has to be a float\0A\00"
define void @check_float(i8* nocapture %0, i32 %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = add nsw i64 %5, 1
%7 = tail call i64 @calloc(i64 %6, i64 1)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @check_alloc(i8* %8)
%10 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double* %3, i8* %8)
%11 = icmp eq i32 %10, 1
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%15 = call i32 @exit(i32 3)
unreachable
16: ; preds = %2
%17 = call i32 @free(i8* %8)
ret void
}