#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 */
typedef scalar_t__ uint64_t;
typedef int /*<<< orphan*/ mpfr_t;

/* Variables and functions */
int /*<<< orphan*/ GMP_RNDN;
int /*<<< orphan*/ GMP_RNDU;
unsigned short _FPU_DEFAULT;
unsigned short _FPU_DOUBLE;
unsigned short _FPU_EXTENDED;
int /*<<< orphan*/ _FPU_GETCW(unsigned short);
int /*<<< orphan*/ _FPU_SETCW(unsigned short);
int /*<<< orphan*/ mpfr_add(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_clear(int /*<<< orphan*/);
scalar_t__ mpfr_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_div_si(int /*<<< orphan*/, int /*<<< orphan*/, int,
                               int /*<<< orphan*/);
int mpfr_get_prec(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_init2(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpfr_set(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int timefunc(int *timing, void **args) {
  unsigned short oldcw, cw;
  mpfr_t xMpfr;
  mpfr_t a, b;
  mpfr_t h;
  int steps, iterations, actualSteps;
  int i;
  uint64_t start, end;
  uint64_t usecs;
  double overalltime;
  mpfr_init2(xMpfr, 161);
  mpfr_init2(a, mpfr_get_prec(*((mpfr_t *)(args[0]))));
  mpfr_init2(b, mpfr_get_prec(*((mpfr_t *)(args[1]))));
  mpfr_set(a, *((mpfr_t *)(args[0])), GMP_RNDN);
  mpfr_set(b, *((mpfr_t *)(args[1])), GMP_RNDN);
  mpfr_init2(h, 161);
  mpfr_set(xMpfr, a, GMP_RNDU);
  steps = *((int *)(args[2]));
  iterations = *((int *)(args[3]));
  mpfr_sub(h, b, a, GMP_RNDU);
  mpfr_div_si(h, h, steps, GMP_RNDU);
  overalltime = 0;
  actualSteps = 0;
  while (mpfr_cmp(xMpfr, b) <= 0) {
    _FPU_GETCW(oldcw);
    cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
    _FPU_SETCW(cw);
    _FPU_SETCW(oldcw);
    mpfr_add(xMpfr, xMpfr, h, GMP_RNDU);
    if (end >= start) {
      usecs = end - start;
      actualSteps++;
    } else {
      usecs = 0;
    }
    overalltime += usecs;
  }
  if (actualSteps != 0)
    overalltime /= actualSteps;
  mpfr_clear(b);
  mpfr_clear(a);
  mpfr_clear(xMpfr);
  mpfr_clear(h);
  *timing = overalltime;
  return 1;
}


x86 assembly (clang, -O0):
<timefunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x18(%rbp),%edi
mov    $0xa1,%esi
call   10b0 <mpfr_init2@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%edi
call   10a0 <mpfr_get_prec@plt>
mov    -0x60(%rbp),%edi
mov    %eax,%esi
call   10b0 <mpfr_init2@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%edi
call   10a0 <mpfr_get_prec@plt>
mov    -0x5c(%rbp),%edi
mov    %eax,%esi
call   10b0 <mpfr_init2@plt>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%esi
mov    0x2dbb(%rip),%rax
mov    (%rax),%edx
call   1070 <mpfr_set@plt>
mov    -0x20(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%esi
mov    0x2da0(%rip),%rax
mov    (%rax),%edx
call   1070 <mpfr_set@plt>
mov    -0x24(%rbp),%edi
mov    $0xa1,%esi
call   10b0 <mpfr_init2@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    0x2d8f(%rip),%rax
mov    (%rax),%edx
call   1070 <mpfr_set@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    0x2d5e(%rip),%rax
mov    (%rax),%ecx
call   1030 <mpfr_sub@plt>
mov    -0x24(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    0x2d47(%rip),%rax
mov    (%rax),%ecx
call   1080 <mpfr_div_si@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1090 <mpfr_cmp@plt>
cmp    $0x0,%rax
jg     135c <timefunc+0x1bc>
movzwl -0x12(%rbp),%edi
call   1040 <_FPU_GETCW@plt>
mov    0x2d14(%rip),%rax
movzwl (%rax),%eax
mov    0x2cea(%rip),%rcx
movzwl (%rcx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    0x2d13(%rip),%rcx
movzwl (%rcx),%ecx
or     %ecx,%eax
mov    %ax,-0x14(%rbp)
movzwl -0x14(%rbp),%edi
call   10c0 <_FPU_SETCW@plt>
movzwl -0x12(%rbp),%edi
call   10c0 <_FPU_SETCW@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x2cc8(%rip),%rax
mov    (%rax),%ecx
call   1060 <mpfr_add@plt>
mov    -0x48(%rbp),%rax
cmp    -0x40(%rbp),%rax
jl     133f <timefunc+0x19f>
mov    -0x48(%rbp),%rax
sub    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1347 <timefunc+0x1a7>
movq   $0x0,-0x50(%rbp)
cvtsi2sdq -0x50(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    12a7 <timefunc+0x107>
cmpl   $0x0,-0x30(%rbp)
je     1379 <timefunc+0x1d9>
cvtsi2sdl -0x30(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%edi
call   1050 <mpfr_clear@plt>
mov    -0x1c(%rbp),%edi
call   1050 <mpfr_clear@plt>
mov    -0x18(%rbp),%edi
call   1050 <mpfr_clear@plt>
mov    -0x24(%rbp),%edi
call   1050 <mpfr_clear@plt>
cvttsd2si -0x58(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x1,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timefunc>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    $0xa1,%esi
call   10b0 <mpfr_init2@plt>
mov    (%r15),%rax
mov    (%rax),%edi
call   10a0 <mpfr_get_prec@plt>
mov    %eax,%esi
call   10b0 <mpfr_init2@plt>
mov    0x8(%r15),%rax
mov    (%rax),%edi
call   10a0 <mpfr_get_prec@plt>
mov    %eax,%esi
call   10b0 <mpfr_init2@plt>
mov    (%r15),%rax
mov    (%rax),%esi
mov    0x2de1(%rip),%rbx
mov    (%rbx),%edx
call   1070 <mpfr_set@plt>
mov    0x8(%r15),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
call   1070 <mpfr_set@plt>
mov    $0xa1,%esi
call   10b0 <mpfr_init2@plt>
mov    0x2dcc(%rip),%r12
mov    (%r12),%edx
call   1070 <mpfr_set@plt>
mov    0x10(%r15),%rax
mov    (%rax),%ebp
mov    (%r12),%ecx
call   1030 <mpfr_sub@plt>
mov    (%r12),%ecx
mov    %ebp,%edx
call   1080 <mpfr_div_si@plt>
call   1090 <mpfr_cmp@plt>
test   %rax,%rax
jg     1286 <timefunc+0xe6>
mov    0x2da0(%rip),%r15
mov    0x2d79(%rip),%rbx
mov    0x2daa(%rip),%rbp
xchg   %ax,%ax
xor    %edi,%edi
call   1040 <_FPU_GETCW@plt>
movzwl (%rbx),%eax
not    %eax
and    (%r15),%ax
or     0x0(%rbp),%ax
movzwl %ax,%edi
call   10c0 <_FPU_SETCW@plt>
xor    %edi,%edi
call   10c0 <_FPU_SETCW@plt>
mov    (%r12),%ecx
call   1060 <mpfr_add@plt>
call   1090 <mpfr_cmp@plt>
test   %rax,%rax
jle    1250 <timefunc+0xb0>
call   1050 <mpfr_clear@plt>
call   1050 <mpfr_clear@plt>
call   1050 <mpfr_clear@plt>
call   1050 <mpfr_clear@plt>
movl   $0x0,(%r14)
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GMP_RNDN = global i32 0
@GMP_RNDU = global i32 0
@_FPU_DEFAULT = global i16 0
@_FPU_EXTENDED = global i16 0
@_FPU_DOUBLE = global i16 0
define i32 @timefunc(i32* %0, i8** %1) {
%3 = alloca i32*
%4 = alloca i8**
%5 = alloca i16
%6 = alloca i16
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca double
store i32* %0, i32** %3
store i8** %1, i8*** %4
%19 = load i32, i32* %7
%20 = call i32 @mpfr_init2(i32 %19, i32 161)
%21 = load i32, i32* %8
%22 = load i8**, i8*** %4
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = bitcast i8* %24 to i32*
%26 = load i32, i32* %25
%27 = call i32 @mpfr_get_prec(i32 %26)
%28 = call i32 @mpfr_init2(i32 %21, i32 %27)
%29 = load i32, i32* %9
%30 = load i8**, i8*** %4
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = bitcast i8* %32 to i32*
%34 = load i32, i32* %33
%35 = call i32 @mpfr_get_prec(i32 %34)
%36 = call i32 @mpfr_init2(i32 %29, i32 %35)
%37 = load i32, i32* %8
%38 = load i8**, i8*** %4
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = bitcast i8* %40 to i32*
%42 = load i32, i32* %41
%43 = load i32, i32* @GMP_RNDN
%44 = call i32 @mpfr_set(i32 %37, i32 %42, i32 %43)
%45 = load i32, i32* %9
%46 = load i8**, i8*** %4
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
%49 = bitcast i8* %48 to i32*
%50 = load i32, i32* %49
%51 = load i32, i32* @GMP_RNDN
%52 = call i32 @mpfr_set(i32 %45, i32 %50, i32 %51)
%53 = load i32, i32* %10
%54 = call i32 @mpfr_init2(i32 %53, i32 161)
%55 = load i32, i32* %7
%56 = load i32, i32* %8
%57 = load i32, i32* @GMP_RNDU
%58 = call i32 @mpfr_set(i32 %55, i32 %56, i32 %57)
%59 = load i8**, i8*** %4
%60 = getelementptr inbounds i8*, i8** %59, i64 2
%61 = load i8*, i8** %60
%62 = bitcast i8* %61 to i32*
%63 = load i32, i32* %62
store i32 %63, i32* %11
%64 = load i8**, i8*** %4
%65 = getelementptr inbounds i8*, i8** %64, i64 3
%66 = load i8*, i8** %65
%67 = bitcast i8* %66 to i32*
%68 = load i32, i32* %67
store i32 %68, i32* %12
%69 = load i32, i32* %10
%70 = load i32, i32* %9
%71 = load i32, i32* %8
%72 = load i32, i32* @GMP_RNDU
%73 = call i32 @mpfr_sub(i32 %69, i32 %70, i32 %71, i32 %72)
%74 = load i32, i32* %10
%75 = load i32, i32* %10
%76 = load i32, i32* %11
%77 = load i32, i32* @GMP_RNDU
%78 = call i32 @mpfr_div_si(i32 %74, i32 %75, i32 %76, i32 %77)
store double 0.000000e+00, double* %18
store i32 0, i32* %13
br label %79
79: ; preds = %116, %2
%80 = load i32, i32* %7
%81 = load i32, i32* %9
%82 = call i64 @mpfr_cmp(i32 %80, i32 %81)
%83 = icmp sle i64 %82, 0
br i1 %83, label %84, label %121
84: ; preds = %79
%85 = load i16, i16* %5
%86 = call i32 @_FPU_GETCW(i16 zeroext %85)
%87 = load i16, i16* @_FPU_DEFAULT
%88 = zext i16 %87 to i32
%89 = load i16, i16* @_FPU_EXTENDED
%90 = zext i16 %89 to i32
%91 = xor i32 %90, -1
%92 = and i32 %88, %91
%93 = load i16, i16* @_FPU_DOUBLE
%94 = zext i16 %93 to i32
%95 = or i32 %92, %94
%96 = trunc i32 %95 to i16
store i16 %96, i16* %6
%97 = load i16, i16* %6
%98 = call i32 @_FPU_SETCW(i16 zeroext %97)
%99 = load i16, i16* %5
%100 = call i32 @_FPU_SETCW(i16 zeroext %99)
%101 = load i32, i32* %7
%102 = load i32, i32* %7
%103 = load i32, i32* %10
%104 = load i32, i32* @GMP_RNDU
%105 = call i32 @mpfr_add(i32 %101, i32 %102, i32 %103, i32 %104)
%106 = load i64, i64* %16
%107 = load i64, i64* %15
%108 = icmp sge i64 %106, %107
br i1 %108, label %109, label %115
109: ; preds = %84
%110 = load i64, i64* %16
%111 = load i64, i64* %15
%112 = sub nsw i64 %110, %111
store i64 %112, i64* %17
%113 = load i32, i32* %13
%114 = add nsw i32 %113, 1
store i32 %114, i32* %13
br label %116
115: ; preds = %84
store i64 0, i64* %17
br label %116
116: ; preds = %115, %109
%117 = load i64, i64* %17
%118 = sitofp i64 %117 to double
%119 = load double, double* %18
%120 = fadd double %119, %118
store double %120, double* %18
br label %79
121: ; preds = %79
%122 = load i32, i32* %13
%123 = icmp ne i32 %122, 0
br i1 %123, label %124, label %129
124: ; preds = %121
%125 = load i32, i32* %13
%126 = sitofp i32 %125 to double
%127 = load double, double* %18
%128 = fdiv double %127, %126
store double %128, double* %18
br label %129
129: ; preds = %124, %121
%130 = load i32, i32* %9
%131 = call i32 @mpfr_clear(i32 %130)
%132 = load i32, i32* %8
%133 = call i32 @mpfr_clear(i32 %132)
%134 = load i32, i32* %7
%135 = call i32 @mpfr_clear(i32 %134)
%136 = load i32, i32* %10
%137 = call i32 @mpfr_clear(i32 %136)
%138 = load double, double* %18
%139 = fptosi double %138 to i32
%140 = load i32*, i32** %3
store i32 %139, i32* %140
ret i32 1
}

LLVM IR (-O2):
@GMP_RNDN = global i32 0
@GMP_RNDU = global i32 0
@_FPU_DEFAULT = global i16 0
@_FPU_EXTENDED = global i16 0
@_FPU_DOUBLE = global i16 0
define i32 @timefunc(i32* nocapture writeonly %0, i8** nocapture %1) {
%3 = tail call i32 @mpfr_init2(i32 undef, i32 161)
%4 = bitcast i8** %1 to i32**
%5 = load i32*, i32** %4
%6 = load i32, i32* %5
%7 = tail call i32 @mpfr_get_prec(i32 %6)
%8 = tail call i32 @mpfr_init2(i32 undef, i32 %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = bitcast i8** %9 to i32**
%11 = load i32*, i32** %10
%12 = load i32, i32* %11
%13 = tail call i32 @mpfr_get_prec(i32 %12)
%14 = tail call i32 @mpfr_init2(i32 undef, i32 %13)
%15 = load i32*, i32** %4
%16 = load i32, i32* %15
%17 = load i32, i32* @GMP_RNDN
%18 = tail call i32 @mpfr_set(i32 undef, i32 %16, i32 %17)
%19 = load i32*, i32** %10
%20 = load i32, i32* %19
%21 = load i32, i32* @GMP_RNDN
%22 = tail call i32 @mpfr_set(i32 undef, i32 %20, i32 %21)
%23 = tail call i32 @mpfr_init2(i32 undef, i32 161)
%24 = load i32, i32* @GMP_RNDU
%25 = tail call i32 @mpfr_set(i32 undef, i32 undef, i32 %24)
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = bitcast i8** %26 to i32**
%28 = load i32*, i32** %27
%29 = load i32, i32* %28
%30 = load i32, i32* @GMP_RNDU
%31 = tail call i32 @mpfr_sub(i32 undef, i32 undef, i32 undef, i32 %30)
%32 = load i32, i32* @GMP_RNDU
%33 = tail call i32 @mpfr_div_si(i32 undef, i32 undef, i32 %29, i32 %32)
%34 = tail call i64 @mpfr_cmp(i32 undef, i32 undef)
%35 = icmp slt i64 %34, 1
br i1 %35, label %36, label %50
36: ; preds = %2, %36
%37 = tail call i32 @_FPU_GETCW(i16 zeroext undef)
%38 = load i16, i16* @_FPU_DEFAULT
%39 = load i16, i16* @_FPU_EXTENDED
%40 = xor i16 %39, -1
%41 = and i16 %38, %40
%42 = load i16, i16* @_FPU_DOUBLE
%43 = or i16 %41, %42
%44 = tail call i32 @_FPU_SETCW(i16 zeroext %43)
%45 = tail call i32 @_FPU_SETCW(i16 zeroext undef)
%46 = load i32, i32* @GMP_RNDU
%47 = tail call i32 @mpfr_add(i32 undef, i32 undef, i32 undef, i32 %46)
%48 = tail call i64 @mpfr_cmp(i32 undef, i32 undef)
%49 = icmp slt i64 %48, 1
br i1 %49, label %36, label %50
50: ; preds = %36, %2
%51 = tail call i32 @mpfr_clear(i32 undef)
%52 = tail call i32 @mpfr_clear(i32 undef)
%53 = tail call i32 @mpfr_clear(i32 undef)
%54 = tail call i32 @mpfr_clear(i32 undef)
store i32 0, i32* %0
ret i32 1
}