#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 fabs(double const);
double floor(double const);
int mir_ineq(const int n, const double a[], const double b, double alpha[],
             double *beta, double *gamma) {
  int j;
  double f, t;
  if (fabs(b - floor(b + .5)) < 0.01)
    return 1;
  f = b - floor(b);
  for (j = 1; j <= n; j++) {
    t = (a[j] - floor(a[j])) - f;
    if (t <= 0.0)
      alpha[j] = floor(a[j]);
    else
      alpha[j] = floor(a[j]) + t / (1.0 - f);
  }
  *beta = floor(b);
  *gamma = 1.0 / (1.0 - f);
  return 0;
}


x86 assembly (clang, -O0):
<mir_ineq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xec6(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
call   1030 <floor@plt>
movsd  -0x50(%rbp),%xmm1
subsd  %xmm0,%xmm1
movaps 0xec4(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe98(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    117e <mir_ineq+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    12a8 <mir_ineq+0x198>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     126e <mir_ineq+0x15e>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
subsd  %xmm1,%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jb     1222 <mir_ineq+0x112>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <floor@plt>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    125b <mir_ineq+0x14b>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <floor@plt>
movsd  -0x48(%rbp),%xmm1
movsd  0xdcf(%rip),%xmm2
subsd  -0x40(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1260 <mir_ineq+0x150>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11aa <mir_ineq+0x9a>
movsd  -0x18(%rbp),%xmm0
call   1030 <floor@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xd88(%rip),%xmm1
subsd  -0x40(%rbp),%xmm1
movsd  0xd7b(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mir_ineq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
movapd %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%r13
mov    %edi,%ebx
movsd  0xec2(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1030 <floor@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm1
subsd  %xmm0,%xmm1
andpd  0xec3(%rip),%xmm1
mov    $0x1,%eax
movsd  0xe9e(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     122b <mir_ineq+0x11b>
movapd %xmm2,%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0xe7b(%rip),%xmm0
movsd  %xmm1,0x8(%rsp)
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
test   %ebx,%ebx
jle    120b <mir_ineq+0xfb>
add    $0x1,%ebx
mov    $0x1,%ebp
jmp    11cf <mir_ineq+0xbf>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm0,(%r12,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     120b <mir_ineq+0xfb>
movsd  0x0(%r13,%rbp,8),%xmm0
movsd  %xmm0,0x20(%rsp)
call   1030 <floor@plt>
movsd  0x20(%rsp),%xmm2
subsd  %xmm0,%xmm2
subsd  0x8(%rsp),%xmm2
xorpd  %xmm1,%xmm1
ucomisd %xmm2,%xmm1
jae    11c0 <mir_ineq+0xb0>
movapd %xmm2,%xmm1
divsd  0x10(%rsp),%xmm1
addsd  %xmm1,%xmm0
jmp    11c0 <mir_ineq+0xb0>
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%r15)
movsd  0xdf2(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mir_ineq(i32 %0, double* %1, double %2, double* %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca double
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca i32
%15 = alloca double
%16 = alloca double
store i32 %0, i32* %8
store double* %1, double** %9
store double %2, double* %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
%17 = load double, double* %10
%18 = load double, double* %10
%19 = fadd double %18, 5.000000e-01
%20 = call double @llvm.floor.f64(double %19)
%21 = fsub double %17, %20
%22 = call double @llvm.fabs.f64(double %21)
%23 = fcmp olt double %22, 1.000000e-02
br i1 %23, label %24, label %25
24: ; preds = %6
store i32 1, i32* %7
br label %90
25: ; preds = %6
%26 = load double, double* %10
%27 = load double, double* %10
%28 = call double @llvm.floor.f64(double %27)
%29 = fsub double %26, %28
store double %29, double* %15
store i32 1, i32* %14
br label %30
30: ; preds = %79, %25
%31 = load i32, i32* %14
%32 = load i32, i32* %8
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %82
34: ; preds = %30
%35 = load double*, double** %9
%36 = load i32, i32* %14
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = load double*, double** %9
%41 = load i32, i32* %14
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load double, double* %43
%45 = call double @llvm.floor.f64(double %44)
%46 = fsub double %39, %45
%47 = load double, double* %15
%48 = fsub double %46, %47
store double %48, double* %16
%49 = load double, double* %16
%50 = fcmp ole double %49, 0.000000e+00
br i1 %50, label %51, label %62
51: ; preds = %34
%52 = load double*, double** %9
%53 = load i32, i32* %14
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load double, double* %55
%57 = call double @llvm.floor.f64(double %56)
%58 = load double*, double** %11
%59 = load i32, i32* %14
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
store double %57, double* %61
br label %78
62: ; preds = %34
%63 = load double*, double** %9
%64 = load i32, i32* %14
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = call double @llvm.floor.f64(double %67)
%69 = load double, double* %16
%70 = load double, double* %15
%71 = fsub double 1.000000e+00, %70
%72 = fdiv double %69, %71
%73 = fadd double %68, %72
%74 = load double*, double** %11
%75 = load i32, i32* %14
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %74, i64 %76
store double %73, double* %77
br label %78
78: ; preds = %62, %51
br label %79
79: ; preds = %78
%80 = load i32, i32* %14
%81 = add nsw i32 %80, 1
store i32 %81, i32* %14
br label %30
82: ; preds = %30
%83 = load double, double* %10
%84 = call double @llvm.floor.f64(double %83)
%85 = load double*, double** %12
store double %84, double* %85
%86 = load double, double* %15
%87 = fsub double 1.000000e+00, %86
%88 = fdiv double 1.000000e+00, %87
%89 = load double*, double** %13
store double %88, double* %89
store i32 0, i32* %7
br label %90
90: ; preds = %82, %24
%91 = load i32, i32* %7
ret i32 %91
}

LLVM IR (-O2):
define i32 @mir_ineq(i32 %0, double* nocapture %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = fadd double %2, 5.000000e-01
%8 = tail call double @llvm.floor.f64(double %7)
%9 = fsub double %2, %8
%10 = tail call double @llvm.fabs.f64(double %9)
%11 = fcmp olt double %10, 1.000000e-02
br i1 %11, label %38, label %12
12: ; preds = %6
%13 = tail call double @llvm.floor.f64(double %2)
%14 = fsub double %2, %13
%15 = icmp slt i32 %0, 1
%16 = fsub double 1.000000e+00, %14
br i1 %15, label %36, label %17
17: ; preds = %12
%18 = add nuw i32 %0, 1
%19 = zext i32 %18 to i64
br label %20
20: ; preds = %17, %31
%21 = phi i64 [ 1, %17 ], [ %34, %31 ]
%22 = getelementptr inbounds double, double* %1, i64 %21
%23 = load double, double* %22
%24 = tail call double @llvm.floor.f64(double %23)
%25 = fsub double %23, %24
%26 = fsub double %25, %14
%27 = fcmp ugt double %26, 0.000000e+00
br i1 %27, label %28, label %31
28: ; preds = %20
%29 = fdiv double %26, %16
%30 = fadd double %24, %29
br label %31
31: ; preds = %20, %28
%32 = phi double [ %30, %28 ], [ %24, %20 ]
%33 = getelementptr inbounds double, double* %3, i64 %21
store double %32, double* %33
%34 = add nuw nsw i64 %21, 1
%35 = icmp eq i64 %34, %19
br i1 %35, label %36, label %20
36: ; preds = %31, %12
store double %13, double* %4
%37 = fdiv double 1.000000e+00, %16
store double %37, double* %5
br label %38
38: ; preds = %6, %36
%39 = phi i32 [ 0, %36 ], [ 1, %6 ]
ret i32 %39
}