#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 */
int /*<<< orphan*/ strcmp(char *, char *);
float uplim01(float *arr1, int idx, int sz, char *limtype) {
  float ret;
  if (idx == sz - 1)
    ret = 1.;
  else if (!strcmp("pt_as_mid", limtype))
    ret = arr1[idx] + (arr1[idx + 1] - arr1[idx]) / 2.;
  else if (!strcmp("pt_as_spl", limtype))
    ret = arr1[idx];
  return ret;
}


x86 assembly (clang, -O0):
<uplim01>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1149 <uplim01+0x39>
movss  0xec9(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11e9 <uplim01+0xd9>
mov    -0x18(%rbp),%rsi
lea    0xeb8(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11b4 <uplim01+0xa4>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm1
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
subss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe62(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11e4 <uplim01+0xd4>
mov    -0x18(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11df <uplim01+0xcf>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11e4 <uplim01+0xd4>
jmp    11e9 <uplim01+0xd9>
movss  -0x1c(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uplim01>:
push   %rbp
push   %r14
push   %rbx
add    $0xffffffff,%edx
cmp    %esi,%edx
jne    1125 <uplim01+0x15>
movss  0xedd(%rip),%xmm0
jmp    118d <uplim01+0x7d>
mov    %rcx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
lea    0xedc(%rip),%rdi
mov    %rcx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     115e <uplim01+0x4e>
lea    0xed3(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    118d <uplim01+0x7d>
movslq %ebp,%rax
movss  (%r14,%rax,4),%xmm0
jmp    118d <uplim01+0x7d>
movslq %ebp,%rax
movss  (%r14,%rax,4),%xmm0
movss  0x4(%r14,%rax,4),%xmm1
subss  %xmm0,%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  0xe8a(%rip),%xmm1
cvtss2sd %xmm0,%xmm0
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"pt_as_mid\00"
@.str.1 = [10 x i8] c"pt_as_spl\00"
define float @uplim01(float* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca float*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca float
store float* %0, float** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = sub nsw i32 %11, 1
%13 = icmp eq i32 %10, %12
br i1 %13, label %14, label %15
14: ; preds = %4
store float 1.000000e+00, float* %9
br label %54
15: ; preds = %4
%16 = load i8*, i8** %8
%17 = call i32 @strcmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %42, label %19
19: ; preds = %15
%20 = load float*, float** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds float, float* %20, i64 %22
%24 = load float, float* %23
%25 = fpext float %24 to double
%26 = load float*, float** %5
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float, float* %26, i64 %29
%31 = load float, float* %30
%32 = load float*, float** %5
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds float, float* %32, i64 %34
%36 = load float, float* %35
%37 = fsub float %31, %36
%38 = fpext float %37 to double
%39 = fdiv double %38, 2.000000e+00
%40 = fadd double %25, %39
%41 = fptrunc double %40 to float
store float %41, float* %9
br label %53
42: ; preds = %15
%43 = load i8*, i8** %8
%44 = call i32 @strcmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %43)
%45 = icmp ne i32 %44, 0
br i1 %45, label %52, label %46
46: ; preds = %42
%47 = load float*, float** %5
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds float, float* %47, i64 %49
%51 = load float, float* %50
store float %51, float* %9
br label %52
52: ; preds = %46, %42
br label %53
53: ; preds = %52, %19
br label %54
54: ; preds = %53, %14
%55 = load float, float* %9
ret float %55
}

LLVM IR (-O2):
@.str = [10 x i8] c"pt_as_mid\00"
@.str.1 = [10 x i8] c"pt_as_spl\00"
define float @uplim01(float* nocapture %0, i32 %1, i32 %2, i8* nocapture %3) {
%5 = add nsw i32 %2, -1
%6 = icmp eq i32 %5, %1
br i1 %6, label %31, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %3)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = sext i32 %1 to i64
%12 = getelementptr inbounds float, float* %0, i64 %11
%13 = load float, float* %12
%14 = fpext float %13 to double
%15 = add nsw i32 %1, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds float, float* %0, i64 %16
%18 = load float, float* %17
%19 = fsub float %18, %13
%20 = fpext float %19 to double
%21 = fmul double %20, 5.000000e-01
%22 = fadd double %21, %14
%23 = fptrunc double %22 to float
br label %31
24: ; preds = %7
%25 = tail call i32 @strcmp(i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %3)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = sext i32 %1 to i64
%29 = getelementptr inbounds float, float* %0, i64 %28
%30 = load float, float* %29
br label %31
31: ; preds = %4, %10, %27, %24
%32 = phi float [ undef, %24 ], [ %30, %27 ], [ %23, %10 ], [ 1.000000e+00, %4 ]
ret float %32
}