#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 atof(char const *);
double atoi(int /*<<< orphan*/);
int cinstr(char const *, char);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ indexn(char const *, char, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncasecmp(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ swap(double *, double *);
int /*<<< orphan*/ usage(int /*<<< orphan*/);
void parse_range(const char param, const char *_optarg, double list[]) {
  int elems = cinstr(_optarg, ',');
  list[3] = 0;
  switch (elems) {
  case 0:
    list[0] = list[1] = atof(_optarg);
    list[2] = 1;
    break;
  case 3:
    if (strncasecmp(indexn(_optarg, ',', 3) + 1, "log", 3) == 0)
      list[3] = 1;
  case 2:
    list[0] = atof(_optarg);
    list[1] = atof(indexn(_optarg, ',', 1) + 1);
    list[2] = atoi(indexn(_optarg, ',', 2) + 1);
    if (list[2] <= 0) {
      fprintf(stderr, "error parsing parameter -%c\n\n", param);
      usage(stderr);
      exit(1);
    }
    if (list[0] > list[1])
      swap(&list[0], &list[1]);
    break;
  default:
    fprintf(stderr, "Can't parse range %s.\n\n", _optarg);
    usage(stderr);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<parse_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2c,%esi
call   1060 <cinstr@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,0x18(%rax)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     11f8 <parse_range+0x68>
jmp    11d6 <parse_range+0x46>
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
je     1270 <parse_range+0xe0>
jmp    11e7 <parse_range+0x57>
mov    -0x20(%rbp),%eax
sub    $0x3,%eax
je     1228 <parse_range+0x98>
jmp    1340 <parse_range+0x1b0>
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0xde2(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
jmp    1373 <parse_range+0x1e3>
mov    -0x10(%rbp),%rdi
mov    $0x2c,%esi
mov    $0x3,%edx
call   1040 <indexn@plt>
mov    %eax,%edi
add    $0x1,%edi
lea    0xdc1(%rip),%rsi
mov    $0x3,%edx
call   1070 <strncasecmp@plt>
cmp    $0x0,%eax
jne    126b <parse_range+0xdb>
mov    -0x18(%rbp),%rax
movsd  0xd9a(%rip),%xmm0
movsd  %xmm0,0x18(%rax)
jmp    1270 <parse_range+0xe0>
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x2c,%esi
mov    $0x1,%edx
call   1040 <indexn@plt>
add    $0x1,%eax
movslq %eax,%rdi
call   1030 <atof@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x2c,%esi
mov    $0x2,%edx
call   1040 <indexn@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1090 <atoi@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd 0x10(%rax),%xmm0
jb     1313 <parse_range+0x183>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
movsbl -0x1(%rbp),%edx
lea    0xd18(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2cde(%rip),%rax
mov    (%rax),%edi
call   1080 <usage@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
ucomisd 0x8(%rax),%xmm0
jbe    133b <parse_range+0x1ab>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x8,%rsi
call   10b0 <swap@plt>
jmp    1373 <parse_range+0x1e3>
mov    0x2c99(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xcd6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c7e(%rip),%rax
mov    (%rax),%edi
call   1080 <usage@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_range>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %edi,%r14d
mov    %rsi,%rdi
mov    $0x2c,%esi
call   1060 <cinstr@plt>
movq   $0x0,0x18(%rbx)
cmp    $0x3,%eax
je     11e8 <parse_range+0x58>
cmp    $0x2,%eax
je     1220 <parse_range+0x90>
test   %eax,%eax
jne    12b4 <parse_range+0x124>
mov    %rbp,%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rbx)
movsd  %xmm0,(%rbx)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x10(%rbx)
jmp    1292 <parse_range+0x102>
mov    %rbp,%rdi
mov    $0x2c,%esi
mov    $0x3,%edx
call   1040 <indexn@plt>
lea    0x1(%rax),%edi
lea    0xdfc(%rip),%rsi
mov    $0x3,%edx
call   1070 <strncasecmp@plt>
test   %eax,%eax
jne    1220 <parse_range+0x90>
movabs $0x3ff0000000000000,%rax
mov    %rax,0x18(%rbx)
mov    %rbp,%rdi
call   1030 <atof@plt>
movsd  %xmm0,(%rbx)
mov    %rbp,%rdi
mov    $0x2c,%esi
mov    $0x1,%edx
call   1040 <indexn@plt>
add    $0x1,%eax
movslq %eax,%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rbx)
mov    %rbp,%rdi
mov    $0x2c,%esi
mov    $0x2,%edx
call   1040 <indexn@plt>
lea    0x1(%rax),%edi
call   1090 <atoi@plt>
movsd  %xmm0,0x10(%rbx)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    1297 <parse_range+0x107>
movsd  (%rbx),%xmm0
ucomisd 0x8(%rbx),%xmm0
jbe    1292 <parse_range+0x102>
lea    0x8(%rbx),%rsi
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    10b0 <swap@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2d42(%rip),%rbx
mov    (%rbx),%edi
movsbl %r14b,%edx
lea    0xd59(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    12ce <parse_range+0x13e>
mov    0x2d25(%rip),%rbx
mov    (%rbx),%edi
lea    0xd5e(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
call   1080 <usage@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"log\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"error parsing parameter -%c\0A\0A\00"
@.str.2 = [24 x i8] c"Can't parse range %s.\0A\0A\00"
define void @parse_range(i8 signext %0, i8* %1, double* %2) {
%4 = alloca i8
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i32
store i8 %0, i8* %4
store i8* %1, i8** %5
store double* %2, double** %6
%8 = load i8*, i8** %5
%9 = call i32 @cinstr(i8* %8, i8 signext 44)
store i32 %9, i32* %7
%10 = load double*, double** %6
%11 = getelementptr inbounds double, double* %10, i64 3
store double 0.000000e+00, double* %11
%12 = load i32, i32* %7
switch i32 %12, label %78 [
i32 0, label %13
i32 3, label %22
i32 2, label %32
]
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = call double @atof(i8* %14)
%16 = load double*, double** %6
%17 = getelementptr inbounds double, double* %16, i64 1
store double %15, double* %17
%18 = load double*, double** %6
%19 = getelementptr inbounds double, double* %18, i64 0
store double %15, double* %19
%20 = load double*, double** %6
%21 = getelementptr inbounds double, double* %20, i64 2
store double 1.000000e+00, double* %21
br label %85
22: ; preds = %3
%23 = load i8*, i8** %5
%24 = call i32 @indexn(i8* %23, i8 signext 44, i32 3)
%25 = add nsw i32 %24, 1
%26 = call i32 @strncasecmp(i32 %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load double*, double** %6
%30 = getelementptr inbounds double, double* %29, i64 3
store double 1.000000e+00, double* %30
br label %31
31: ; preds = %28, %22
br label %32
32: ; preds = %3, %31
%33 = load i8*, i8** %5
%34 = call double @atof(i8* %33)
%35 = load double*, double** %6
%36 = getelementptr inbounds double, double* %35, i64 0
store double %34, double* %36
%37 = load i8*, i8** %5
%38 = call i32 @indexn(i8* %37, i8 signext 44, i32 1)
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = inttoptr i64 %40 to i8*
%42 = call double @atof(i8* %41)
%43 = load double*, double** %6
%44 = getelementptr inbounds double, double* %43, i64 1
store double %42, double* %44
%45 = load i8*, i8** %5
%46 = call i32 @indexn(i8* %45, i8 signext 44, i32 2)
%47 = add nsw i32 %46, 1
%48 = call double @atoi(i32 %47)
%49 = load double*, double** %6
%50 = getelementptr inbounds double, double* %49, i64 2
store double %48, double* %50
%51 = load double*, double** %6
%52 = getelementptr inbounds double, double* %51, i64 2
%53 = load double, double* %52
%54 = fcmp ole double %53, 0.000000e+00
br i1 %54, label %55, label %63
55: ; preds = %32
%56 = load i32, i32* @stderr
%57 = load i8, i8* %4
%58 = sext i8 %57 to i32
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = load i32, i32* @stderr
%61 = call i32 @usage(i32 %60)
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %32
%64 = load double*, double** %6
%65 = getelementptr inbounds double, double* %64, i64 0
%66 = load double, double* %65
%67 = load double*, double** %6
%68 = getelementptr inbounds double, double* %67, i64 1
%69 = load double, double* %68
%70 = fcmp ogt double %66, %69
br i1 %70, label %71, label %77
71: ; preds = %63
%72 = load double*, double** %6
%73 = getelementptr inbounds double, double* %72, i64 0
%74 = load double*, double** %6
%75 = getelementptr inbounds double, double* %74, i64 1
%76 = call i32 @swap(double* %73, double* %75)
br label %77
77: ; preds = %71, %63
br label %85
78: ; preds = %3
%79 = load i32, i32* @stderr
%80 = load i8*, i8** %5
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %80)
%82 = load i32, i32* @stderr
%83 = call i32 @usage(i32 %82)
%84 = call i32 @exit(i32 1)
unreachable
85: ; preds = %77, %13
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"log\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"error parsing parameter -%c\0A\0A\00"
@.str.2 = [24 x i8] c"Can't parse range %s.\0A\0A\00"
define void @parse_range(i8 signext %0, i8* %1, double* %2) {
%4 = tail call i32 @cinstr(i8* %1, i8 signext 44)
%5 = getelementptr inbounds double, double* %2, i64 3
store double 0.000000e+00, double* %5
switch i32 %4, label %42 [
i32 0, label %6
i32 3, label %10
i32 2, label %16
]
6: ; preds = %3
%7 = tail call double @atof(i8* %1)
%8 = getelementptr inbounds double, double* %2, i64 1
store double %7, double* %8
store double %7, double* %2
%9 = getelementptr inbounds double, double* %2, i64 2
store double 1.000000e+00, double* %9
br label %48
10: ; preds = %3
%11 = tail call i32 @indexn(i8* %1, i8 signext 44, i32 3)
%12 = add nsw i32 %11, 1
%13 = tail call i32 @strncasecmp(i32 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
store double 1.000000e+00, double* %5
br label %16
16: ; preds = %10, %15, %3
%17 = tail call double @atof(i8* %1)
store double %17, double* %2
%18 = tail call i32 @indexn(i8* %1, i8 signext 44, i32 1)
%19 = add nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = inttoptr i64 %20 to i8*
%22 = tail call double @atof(i8* %21)
%23 = getelementptr inbounds double, double* %2, i64 1
store double %22, double* %23
%24 = tail call i32 @indexn(i8* %1, i8 signext 44, i32 2)
%25 = add nsw i32 %24, 1
%26 = tail call double @atoi(i32 %25)
%27 = getelementptr inbounds double, double* %2, i64 2
store double %26, double* %27
%28 = fcmp ugt double %26, 0.000000e+00
br i1 %28, label %36, label %29
29: ; preds = %16
%30 = load i32, i32* @stderr
%31 = sext i8 %0 to i32
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i32, i32* @stderr
%34 = tail call i32 @usage(i32 %33)
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %16
%37 = load double, double* %2
%38 = load double, double* %23
%39 = fcmp ogt double %37, %38
br i1 %39, label %40, label %48
40: ; preds = %36
%41 = tail call i32 @swap(double* %2, double* %23)
br label %48
42: ; preds = %3
%43 = load i32, i32* @stderr
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%45 = load i32, i32* @stderr
%46 = tail call i32 @usage(i32 %45)
%47 = tail call i32 @exit(i32 1)
unreachable
48: ; preds = %36, %40, %6
ret void
}