#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*/ fmin_withindex(float *, size_t, float *, size_t *);
void maskfarray(float *in, unsigned char *mask, size_t size,
                unsigned char f1_b0) {
  size_t index;
  float min, *fpt = in, *ffpt;
  unsigned char *mpt = mask;
  fmin_withindex(in, size, &min, &index);
  ffpt = fpt + size;
  for (; fpt < ffpt; fpt++, mpt++)
    if (*mpt == f1_b0)
      *fpt = min;
}


x86 assembly (clang, -O0):
<maskfarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %cl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1030 <fmin_withindex@plt>
mov    -0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x40(%rbp),%rax
jae    11b1 <maskfarray+0xa1>
mov    -0x48(%rbp),%rax
movzbl (%rax),%eax
movzbl -0x19(%rbp),%ecx
cmp    %ecx,%eax
jne    118f <maskfarray+0x7f>
movss  -0x2c(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1194 <maskfarray+0x84>
mov    -0x38(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1161 <maskfarray+0x51>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maskfarray>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %r15,%rsi
call   1030 <fmin_withindex@plt>
test   %r15,%r15
jle    1169 <maskfarray+0x59>
lea    0x0(,%r15,4),%rax
add    %rbp,%rax
movss  0xc(%rsp),%xmm0
jmp    115d <maskfarray+0x4d>
add    $0x4,%rbp
add    $0x1,%rbx
cmp    %rax,%rbp
jae    1169 <maskfarray+0x59>
cmp    %r14b,(%rbx)
jne    1150 <maskfarray+0x40>
movss  %xmm0,0x0(%rbp)
jmp    1150 <maskfarray+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @maskfarray(float* %0, i8* %1, i64 %2, i8 zeroext %3) {
%5 = alloca float*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8
%9 = alloca i64
%10 = alloca float
%11 = alloca float*
%12 = alloca float*
%13 = alloca i8*
store float* %0, float** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i8 %3, i8* %8
%14 = load float*, float** %5
store float* %14, float** %11
%15 = load i8*, i8** %6
store i8* %15, i8** %13
%16 = load float*, float** %5
%17 = load i64, i64* %7
%18 = call i32 @fmin_withindex(float* %16, i64 %17, float* %10, i64* %9)
%19 = load float*, float** %11
%20 = load i64, i64* %7
%21 = getelementptr inbounds float, float* %19, i64 %20
store float* %21, float** %12
br label %22
22: ; preds = %37, %4
%23 = load float*, float** %11
%24 = load float*, float** %12
%25 = icmp ult float* %23, %24
br i1 %25, label %26, label %42
26: ; preds = %22
%27 = load i8*, i8** %13
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = load i8, i8* %8
%31 = zext i8 %30 to i32
%32 = icmp eq i32 %29, %31
br i1 %32, label %33, label %36
33: ; preds = %26
%34 = load float, float* %10
%35 = load float*, float** %11
store float %34, float* %35
br label %36
36: ; preds = %33, %26
br label %37
37: ; preds = %36
%38 = load float*, float** %11
%39 = getelementptr inbounds float, float* %38, i32 1
store float* %39, float** %11
%40 = load i8*, i8** %13
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %13
br label %22
42: ; preds = %22
ret void
}

LLVM IR (-O2):
define void @maskfarray(float* %0, i8* nocapture %1, i64 %2, i8 zeroext %3) {
%5 = alloca i64
%6 = alloca float
%7 = bitcast i64* %5 to i8*
%8 = bitcast float* %6 to i8*
%9 = call i32 @fmin_withindex(float* %0, i64 %2, float* %6, i64* %5)
%10 = getelementptr inbounds float, float* %0, i64 %2
%11 = icmp sgt i64 %2, 0
br i1 %11, label %12, label %24
12: ; preds = %4
%13 = load float, float* %6
br label %14
14: ; preds = %12, %20
%15 = phi i8* [ %1, %12 ], [ %22, %20 ]
%16 = phi float* [ %0, %12 ], [ %21, %20 ]
%17 = load i8, i8* %15
%18 = icmp eq i8 %17, %3
br i1 %18, label %19, label %20
19: ; preds = %14
store float %13, float* %16
br label %20
20: ; preds = %14, %19
%21 = getelementptr inbounds float, float* %16, i64 1
%22 = getelementptr inbounds i8, i8* %15, i64 1
%23 = icmp ult float* %21, %10
br i1 %23, label %14, label %24
24: ; preds = %20, %4
ret void
}