#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 ImfpLength(unsigned char *, int, int, int, unsigned char, long *, int);
void MP_ImfpMeasure(unsigned char *data, int step, int width, int height,
                    unsigned char barrier, int nclass, unsigned int freq[],
                    double dpix, int nsample, long *seed, int dflag) {
  int n = 0;
  int cl;
  double len;
  while (n < nsample) {
    len = ImfpLength(data, step, width, height, barrier, seed, dflag);
    if (len >= 0.0) {
      cl = (int)((len + 0.5) / dpix);
      if (cl < nclass)
        (freq[cl])++;
      n++;
    }
  }
}


x86 assembly (clang, -O0):
<MP_ImfpMeasure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %r8b,%al
mov    0x28(%rbp),%r8d
mov    0x20(%rbp),%r8
mov    0x18(%rbp),%r8d
mov    0x10(%rbp),%r8
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %al,-0x15(%rbp)
mov    %r9d,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    11d6 <MP_ImfpMeasure+0xc6>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x15(%rbp),%r8b
mov    0x20(%rbp),%r9
mov    0x28(%rbp),%eax
movzbl %r8b,%r8d
mov    %eax,(%rsp)
call   1030 <ImfpLength@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11d1 <MP_ImfpMeasure+0xc1>
movsd  0xe66(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c8 <MP_ImfpMeasure+0xb8>
mov    0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    114b <MP_ImfpMeasure+0x3b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MP_ImfpMeasure>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %r9d,0xc(%rsp)
cmpl   $0x0,0x58(%rsp)
jle    11a9 <MP_ImfpMeasure+0x99>
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %r13d,%r13d
movzbl %r8b,%r14d
jmp    115b <MP_ImfpMeasure+0x4b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r13d
cmp    0x58(%rsp),%r13d
jge    11a9 <MP_ImfpMeasure+0x99>
mov    0x68(%rsp),%eax
mov    %eax,(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
mov    0x60(%rsp),%r9
call   1030 <ImfpLength@plt>
ucomisd 0xe86(%rip),%xmm0
jb     1154 <MP_ImfpMeasure+0x44>
addsd  0xe74(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%eax
cmp    0xc(%rsp),%eax
jge    1150 <MP_ImfpMeasure+0x40>
cltq
mov    0x50(%rsp),%rcx
addl   $0x1,(%rcx,%rax,4)
jmp    1150 <MP_ImfpMeasure+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @MP_ImfpMeasure(i8* %0, i32 %1, i32 %2, i32 %3, i8 zeroext %4, i32 %5, i32* %6, double %7, i32 %8, i64* %9, i32 %10) {
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8
%17 = alloca i32
%18 = alloca i32*
%19 = alloca double
%20 = alloca i32
%21 = alloca i64*
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca double
store i8* %0, i8** %12
store i32 %1, i32* %13
store i32 %2, i32* %14
store i32 %3, i32* %15
store i8 %4, i8* %16
store i32 %5, i32* %17
store i32* %6, i32** %18
store double %7, double* %19
store i32 %8, i32* %20
store i64* %9, i64** %21
store i32 %10, i32* %22
store i32 0, i32* %23
br label %26
26: ; preds = %60, %11
%27 = load i32, i32* %23
%28 = load i32, i32* %20
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %61
30: ; preds = %26
%31 = load i8*, i8** %12
%32 = load i32, i32* %13
%33 = load i32, i32* %14
%34 = load i32, i32* %15
%35 = load i8, i8* %16
%36 = load i64*, i64** %21
%37 = load i32, i32* %22
%38 = call double @ImfpLength(i8* %31, i32 %32, i32 %33, i32 %34, i8 zeroext %35, i64* %36, i32 %37)
store double %38, double* %25
%39 = load double, double* %25
%40 = fcmp oge double %39, 0.000000e+00
br i1 %40, label %41, label %60
41: ; preds = %30
%42 = load double, double* %25
%43 = fadd double %42, 5.000000e-01
%44 = load double, double* %19
%45 = fdiv double %43, %44
%46 = fptosi double %45 to i32
store i32 %46, i32* %24
%47 = load i32, i32* %24
%48 = load i32, i32* %17
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %57
50: ; preds = %41
%51 = load i32*, i32** %18
%52 = load i32, i32* %24
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
%55 = load i32, i32* %54
%56 = add i32 %55, 1
store i32 %56, i32* %54
br label %57
57: ; preds = %50, %41
%58 = load i32, i32* %23
%59 = add nsw i32 %58, 1
store i32 %59, i32* %23
br label %60
60: ; preds = %57, %30
br label %26
61: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @MP_ImfpMeasure(i8* %0, i32 %1, i32 %2, i32 %3, i8 zeroext %4, i32 %5, i32* nocapture %6, double %7, i32 %8, i64* %9, i32 %10) {
%12 = icmp sgt i32 %8, 0
br i1 %12, label %13, label %32
13: ; preds = %11, %29
%14 = phi i32 [ %30, %29 ], [ 0, %11 ]
%15 = tail call double @ImfpLength(i8* %0, i32 %1, i32 %2, i32 %3, i8 zeroext %4, i64* %9, i32 %10)
%16 = fcmp ult double %15, 0.000000e+00
br i1 %16, label %29, label %17
17: ; preds = %13
%18 = fadd double %15, 5.000000e-01
%19 = fdiv double %18, %7
%20 = fptosi double %19 to i32
%21 = icmp slt i32 %20, %5
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = sext i32 %20 to i64
%24 = getelementptr inbounds i32, i32* %6, i64 %23
%25 = load i32, i32* %24
%26 = add i32 %25, 1
store i32 %26, i32* %24
br label %27
27: ; preds = %22, %17
%28 = add nsw i32 %14, 1
br label %29
29: ; preds = %27, %13
%30 = phi i32 [ %28, %27 ], [ %14, %13 ]
%31 = icmp slt i32 %30, %8
br i1 %31, label %13, label %32
32: ; preds = %29, %11
ret void
}