#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 fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fmemopen(char *, int /*<<< orphan*/, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, double *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strlen(char *);
int main(void) {
  FILE *f;
  int lost = 0;
  int c;
  double d;
  char s[] = "+.e";
  f = fmemopen(s, strlen(s), "r");
  lost |= (fscanf(f, "%lf", &d) != 0);
  c = fgetc(f);
  lost |= c != 'e';
  puts(lost ? "Test FAILED!" : "Test succeeded.");
  return lost;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xe94(%rip),%eax
mov    %eax,-0x24(%rbp)
lea    -0x24(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x24(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
lea    0xe77(%rip),%rdx
call   1030 <fmemopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe65(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <fscanf@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x65,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
lea    0xe33(%rip),%rdi
lea    0xe1f(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1040 <puts@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movl   $0x652e2b,0xc(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xe8e(%rip),%rdx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <fmemopen@plt>
mov    %rax,%rbx
lea    0xe7c(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
test   %rax,%rax
setne  %bpl
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    $0x65,%eax
setne  %al
or     %bpl,%al
movzbl %al,%ebx
lea    0xe51(%rip),%rax
lea    0xe57(%rip),%rdi
test   %bl,%bl
cmovne %rax,%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.s = [4 x i8] c"+.e\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [13 x i8] c"Test FAILED!\00"
@.str.3 = [16 x i8] c"Test succeeded.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca [4 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
%7 = bitcast [4 x i8]* %6 to i8*
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = call i32* @fmemopen(i8* %8, i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %2
%12 = load i32*, i32** %2
%13 = call i64 @fscanf(i32* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
%16 = load i32, i32* %3
%17 = or i32 %16, %15
store i32 %17, i32* %3
%18 = load i32*, i32** %2
%19 = call i32 @fgetc(i32* %18)
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 101
%22 = zext i1 %21 to i32
%23 = load i32, i32* %3
%24 = or i32 %23, %22
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0)
%29 = call i32 @puts(i8* %28)
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [13 x i8] c"Test FAILED!\00"
@.str.3 = [16 x i8] c"Test succeeded.\00"
define i32 @main() {
%1 = alloca double
%2 = alloca i32
%3 = bitcast double* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 6630955, i32* %2
%5 = call i32 @strlen(i8* %4)
%6 = call i32* @fmemopen(i8* %4, i32 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = call i64 @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%8 = icmp ne i64 %7, 0
%9 = call i32 @fgetc(i32* %6)
%10 = icmp ne i32 %9, 101
%11 = or i1 %8, %10
%12 = zext i1 %11 to i32
%13 = select i1 %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0)
%14 = call i32 @puts(i8* dereferenceable(1) %13)
ret i32 %12
}