#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 */
double rrd_set_to_DINF();
double rrd_set_to_DNAN();
scalar_t__ strncasecmp(char const *, char *, int);
int parse_special(const char *str, double *d) {
  if (strncasecmp(str, "-nan", 4) == 0)
    *d = rrd_set_to_DNAN();
  else if (strncasecmp(str, "nan", 3) == 0)
    *d = -rrd_set_to_DNAN();
  else if (strncasecmp(str, "inf", 3) == 0)
    *d = rrd_set_to_DINF();
  else if (strncasecmp(str, "-inf", 4) == 0)
    *d = -rrd_set_to_DINF();
  else
    return 0;
  return 2;
}


x86 assembly (clang, -O0):
<parse_special>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    1173 <parse_special+0x43>
mov    $0x0,%al
call   1030 <rrd_set_to_DNAN@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1255 <parse_special+0x125>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11bd <parse_special+0x8d>
mov    $0x0,%al
call   1030 <rrd_set_to_DNAN@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1250 <parse_special+0x120>
mov    -0x10(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11f0 <parse_special+0xc0>
mov    $0x0,%al
call   1050 <rrd_set_to_DINF@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    124b <parse_special+0x11b>
mov    -0x10(%rbp),%rdi
lea    0xe0a(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    123a <parse_special+0x10a>
mov    $0x0,%al
call   1050 <rrd_set_to_DINF@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1246 <parse_special+0x116>
movl   $0x0,-0x4(%rbp)
jmp    125c <parse_special+0x12c>
jmp    124b <parse_special+0x11b>
jmp    1250 <parse_special+0x120>
jmp    1255 <parse_special+0x125>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_special>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecf(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     11a9 <parse_special+0x79>
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     11b2 <parse_special+0x82>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     11c2 <parse_special+0x92>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11d3 <parse_special+0xa3>
xor    %eax,%eax
call   1050 <rrd_set_to_DINF@plt>
jmp    11b9 <parse_special+0x89>
xor    %eax,%eax
call   1030 <rrd_set_to_DNAN@plt>
jmp    11c9 <parse_special+0x99>
xor    %eax,%eax
call   1030 <rrd_set_to_DNAN@plt>
xorps  0xe40(%rip),%xmm0
jmp    11c9 <parse_special+0x99>
xor    %eax,%eax
call   1050 <rrd_set_to_DINF@plt>
movsd  %xmm0,(%r14)
mov    $0x2,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"-nan\00"
@.str.1 = [4 x i8] c"nan\00"
@.str.2 = [4 x i8] c"inf\00"
@.str.3 = [5 x i8] c"-inf\00"
define i32 @parse_special(i8* %0, double* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca double*
store i8* %0, i8** %4
store double* %1, double** %5
%6 = load i8*, i8** %4
%7 = call i64 @strncasecmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call double (...) @rrd_set_to_DNAN()
%11 = load double*, double** %5
store double %10, double* %11
br label %39
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i64 @strncasecmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = call double (...) @rrd_set_to_DNAN()
%18 = fneg double %17
%19 = load double*, double** %5
store double %18, double* %19
br label %38
20: ; preds = %12
%21 = load i8*, i8** %4
%22 = call i64 @strncasecmp(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = call double (...) @rrd_set_to_DINF()
%26 = load double*, double** %5
store double %25, double* %26
br label %37
27: ; preds = %20
%28 = load i8*, i8** %4
%29 = call i64 @strncasecmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = call double (...) @rrd_set_to_DINF()
%33 = fneg double %32
%34 = load double*, double** %5
store double %33, double* %34
br label %36
35: ; preds = %27
store i32 0, i32* %3
br label %40
36: ; preds = %31
br label %37
37: ; preds = %36, %24
br label %38
38: ; preds = %37, %16
br label %39
39: ; preds = %38, %9
store i32 2, i32* %3
br label %40
40: ; preds = %39, %35
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [5 x i8] c"-nan\00"
@.str.1 = [4 x i8] c"nan\00"
@.str.2 = [4 x i8] c"inf\00"
@.str.3 = [5 x i8] c"-inf\00"
define i32 @parse_special(i8* nocapture %0, double* nocapture writeonly %1) {
%3 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call double (...) @rrd_set_to_DNAN()
br label %24
7: ; preds = %2
%8 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = tail call double (...) @rrd_set_to_DNAN()
%12 = fneg double %11
br label %24
13: ; preds = %7
%14 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call double (...) @rrd_set_to_DINF()
br label %24
18: ; preds = %13
%19 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = tail call double (...) @rrd_set_to_DINF()
%23 = fneg double %22
br label %24
24: ; preds = %10, %21, %16, %5
%25 = phi double [ %6, %5 ], [ %17, %16 ], [ %23, %21 ], [ %12, %10 ]
store double %25, double* %1
br label %26
26: ; preds = %24, %18
%27 = phi i32 [ 0, %18 ], [ 2, %24 ]
ret i32 %27
}