#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, double *);
char *strpbrk(char *, char *);
float lire_reel_ascii(FILE *fichier) {
  float reel;
  double reeld;
  char string[256], *ptr;
  fscanf(fichier, "%s", string);
  if (ptr = strpbrk(string, "dD"))
    *ptr = 'e';
  sscanf(string, "%lf", &reeld);
  reel = reeld;
  return (reel);
}


x86 assembly (clang, -O0):
<lire_reel_ascii>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xeaf(%rip),%rsi
call   1030 <fscanf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1050 <strpbrk@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
je     1184 <lire_reel_ascii+0x54>
mov    -0x128(%rbp),%rax
movb   $0x65,(%rax)
lea    -0x120(%rbp),%rdi
lea    0xe74(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <sscanf@plt>
movsd  -0x18(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lire_reel_ascii>:
push   %rbx
sub    $0x110,%rsp
lea    0xec1(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdx
call   1030 <fscanf@plt>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strpbrk@plt>
test   %rax,%rax
je     1163 <lire_reel_ascii+0x33>
movb   $0x65,(%rax)
lea    0xe9c(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
call   1040 <sscanf@plt>
movsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x110,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"dD\00"
@.str.2 = [4 x i8] c"%lf\00"
define float @lire_reel_ascii(i32* %0) {
%2 = alloca i32*
%3 = alloca float
%4 = alloca double
%5 = alloca [256 x i8]
%6 = alloca i8*
store i32* %0, i32** %2
%7 = load i32*, i32** %2
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%9 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = call i8* @strpbrk(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %11, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = load i8*, i8** %6
store i8 101, i8* %14
br label %15
15: ; preds = %13, %1
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %4)
%18 = load double, double* %4
%19 = fptrunc double %18 to float
store float %19, float* %3
%20 = load float, float* %3
ret float %20
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"dD\00"
@.str.2 = [4 x i8] c"%lf\00"
define float @lire_reel_ascii(i32* nocapture %0) {
%2 = alloca double
%3 = alloca [256 x i8]
%4 = bitcast double* %2 to i8*
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = call i8* @strpbrk(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i8 101, i8* %7
br label %10
10: ; preds = %9, %1
%11 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%12 = load double, double* %2
%13 = fptrunc double %12 to float
ret float %13
}