#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__ ft_isspace(char const);
int /*<<< orphan*/ ft_strlowcase(char *);
scalar_t__ ft_strnequ(int /*<<< orphan*/, char *, int);
int ft_isnan(const char *s) {
  int index;
  index = 0;
  while (ft_isspace(s[index]))
    index++;
  if (ft_strnequ(ft_strlowcase((char *)&s[index]), "nan", 3))
    return (1);
  else
    return (0);
}


x86 assembly (clang, -O0):
<ft_isnan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <ft_isspace@plt>
cmp    $0x0,%rax
je     116c <ft_isnan+0x3c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1143 <ft_isnan+0x13>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
call   1050 <ft_strlowcase@plt>
mov    %eax,%edi
lea    0xe7b(%rip),%rsi
mov    $0x3,%edx
call   1030 <ft_strnequ@plt>
cmp    $0x0,%rax
je     11a5 <ft_isnan+0x75>
movl   $0x1,-0x4(%rbp)
jmp    11ac <ft_isnan+0x7c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_isnan>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0xffffffffffffffff,%rbx
xchg   %ax,%ax
movsbl 0x1(%r14,%rbx,1),%edi
call   1040 <ft_isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1140 <ft_isnan+0x10>
mov    %ebx,%eax
add    %rax,%r14
mov    %r14,%rdi
call   1050 <ft_strlowcase@plt>
lea    0xe98(%rip),%rsi
mov    %eax,%edi
mov    $0x3,%edx
call   1030 <ft_strnequ@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"nan\00"
define i32 @ft_isnan(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %13, %1
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = call i64 @ft_isspace(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %5
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
br label %5
16: ; preds = %5
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = call i32 @ft_strlowcase(i8* %20)
%22 = call i64 @ft_strnequ(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %16
store i32 1, i32* %2
br label %26
25: ; preds = %16
store i32 0, i32* %2
br label %26
26: ; preds = %25, %24
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@.str = [4 x i8] c"nan\00"
define i32 @ft_isnan(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ %8, %2 ], [ 0, %1 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = tail call i64 @ft_isspace(i8 signext %5)
%7 = icmp eq i64 %6, 0
%8 = add nuw i64 %3, 1
br i1 %7, label %9, label %2
9: ; preds = %2
%10 = and i64 %3, 4294967295
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = tail call i32 @ft_strlowcase(i8* %11)
%13 = tail call i64 @ft_strnequ(i32 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
ret i32 %15
}