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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ GMP_RNDN;
int /*<<< orphan*/ GMP_RNDZ;
int atoi(char *);
unsigned long eval(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
                   int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ mpfr_clears(int /*<<< orphan*/, int /*<<< orphan*/,
                               int /*<<< orphan*/, int /*<<< orphan*/,
                               int /*<<< orphan*/);
int mpfr_get_exp(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_init2(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpfr_inits2(int, int /*<<< orphan*/, int /*<<< orphan*/,
                               int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_nextabove(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_printf(char *, int, int /*<<< orphan*/, int,
                               int /*<<< orphan*/, unsigned long,
                               unsigned long);
int /*<<< orphan*/ mpfr_set_ui_2exp(int /*<<< orphan*/, int, int,
                                    int /*<<< orphan*/);
scalar_t__ mpfr_sub(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
                    int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int dmax, n, p;
  mpfr_t x, y, z, t;
  if (argc != 3 && argc != 4) {
    fprintf(stderr, "Usage: divworst <dmax> <n> [ <p> ]\n");
    exit(EXIT_FAILURE);
  }
  dmax = atoi(argv[1]);
  n = atoi(argv[2]);
  p = argc == 3 ? n : atoi(argv[3]);
  if (p < n) {
    fprintf(stderr, "divworst: p must be greater or equal to n\n");
    exit(EXIT_FAILURE);
  }
  mpfr_inits2(n, x, y, z, (mpfr_ptr)0);
  mpfr_init2(t, p);
  for (mpfr_set_ui_2exp(x, 1, -1, GMP_RNDN); mpfr_get_exp(x) <= dmax;
       mpfr_nextabove(x))
    for (mpfr_set_ui_2exp(y, 1, -1, GMP_RNDN); mpfr_get_exp(y) == 0;
         mpfr_nextabove(y)) {
      unsigned long rz, rn;
      if (mpfr_sub(z, x, y, GMP_RNDZ) != 0)
        continue;
      rz = eval(x, y, z, t, GMP_RNDZ);
      rn = eval(x, y, z, t, GMP_RNDN);
      if (rz == rn)
        continue;
      mpfr_printf("x = %.*Rb ; y = %.*Rb ; Z: %lu ; N: %lu\n", n - 1, x, n - 1,
                  y, rz, rn);
    }
  mpfr_clears(x, y, z, t, (mpfr_ptr)0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     120d <main+0x4d>
cmpl   $0x4,-0x8(%rbp)
je     120d <main+0x4d>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1242 <main+0x82>
mov    -0x18(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    1252 <main+0x92>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1287 <main+0xc7>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
lea    0xdb0(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
xor    %r8d,%r8d
call   10e0 <mpfr_inits2@plt>
mov    -0x2c(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   10b0 <mpfr_init2@plt>
mov    -0x20(%rbp),%edi
mov    0x2d28(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   1090 <mpfr_set_ui_2exp@plt>
mov    -0x20(%rbp),%edi
call   1070 <mpfr_get_exp@plt>
cmp    -0x14(%rbp),%eax
jg     13bf <main+0x1ff>
mov    -0x24(%rbp),%edi
mov    0x2cfc(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   1090 <mpfr_set_ui_2exp@plt>
mov    -0x24(%rbp),%edi
call   1070 <mpfr_get_exp@plt>
cmp    $0x0,%eax
jne    13ad <main+0x1ed>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x2cc2(%rip),%rax
mov    (%rax),%ecx
call   1030 <mpfr_sub@plt>
cmp    $0x0,%rax
je     1324 <main+0x164>
jmp    13a0 <main+0x1e0>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    0x2c99(%rip),%rax
mov    (%rax),%r8d
call   10c0 <eval@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    0x2c82(%rip),%rax
mov    (%rax),%r8d
call   10c0 <eval@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x40(%rbp),%rax
jne    1375 <main+0x1b5>
jmp    13a0 <main+0x1e0>
mov    -0x18(%rbp),%esi
sub    $0x1,%esi
mov    -0x20(%rbp),%edx
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x24(%rbp),%r8d
mov    -0x38(%rbp),%r9
mov    -0x40(%rbp),%rax
lea    0xcb8(%rip),%rdi
mov    %rax,(%rsp)
call   1040 <mpfr_printf@plt>
mov    -0x24(%rbp),%edi
call   1050 <mpfr_nextabove@plt>
jmp    12ed <main+0x12d>
jmp    13b2 <main+0x1f2>
mov    -0x20(%rbp),%edi
call   1050 <mpfr_nextabove@plt>
jmp    12c1 <main+0x101>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
xor    %r8d,%r8d
call   1060 <mpfr_clears@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r15d
lea    -0x5(%r15),%eax
cmp    $0xfffffffd,%eax
jbe    12fc <main+0x13c>
mov    %rsi,%r12
mov    0x8(%rsi),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%r12),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r13d
mov    %eax,%ebx
cmp    $0x3,%r15d
je     1214 <main+0x54>
mov    0x18(%r12),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebx
cmp    %r13d,%eax
jl     130e <main+0x14e>
mov    %r13d,%edi
xor    %r8d,%r8d
call   10e0 <mpfr_inits2@plt>
mov    %ebx,%esi
call   10b0 <mpfr_init2@plt>
mov    0x2dab(%rip),%r12
mov    (%r12),%ecx
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   1090 <mpfr_set_ui_2exp@plt>
call   1070 <mpfr_get_exp@plt>
cmp    %r14d,%eax
jle    1263 <main+0xa3>
xor    %r8d,%r8d
call   1060 <mpfr_clears@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0xffffffff,%r13d
mov    0x2d62(%rip),%rbp
lea    0xdda(%rip),%r15
jmp    128f <main+0xcf>
nopw   0x0(%rax,%rax,1)
call   1050 <mpfr_nextabove@plt>
call   1070 <mpfr_get_exp@plt>
cmp    %r14d,%eax
jg     124a <main+0x8a>
mov    (%r12),%ecx
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   1090 <mpfr_set_ui_2exp@plt>
jmp    12b5 <main+0xf5>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1050 <mpfr_nextabove@plt>
call   1070 <mpfr_get_exp@plt>
test   %eax,%eax
jne    1280 <main+0xc0>
mov    0x0(%rbp),%ecx
call   1030 <mpfr_sub@plt>
test   %rax,%rax
jne    12b0 <main+0xf0>
mov    0x0(%rbp),%r8d
call   10c0 <eval@plt>
mov    %rax,%rbx
mov    (%r12),%r8d
call   10c0 <eval@plt>
cmp    %rax,%rbx
je     12b0 <main+0xf0>
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %r13d,%esi
mov    %r13d,%ecx
mov    %rbx,%r9
call   1040 <mpfr_printf@plt>
jmp    12b0 <main+0xf0>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
lea    0xcf4(%rip),%rsi
jmp    131e <main+0x15e>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
lea    0xd06(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Usage: divworst <dmax> <n> [ <p> ]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [43 x i8] c"divworst: p must be greater or equal to n\0A\00"
@GMP_RNDN = global i32 0
@GMP_RNDZ = global i32 0
@.str.2 = [41 x i8] c"x = %.*Rb ; y = %.*Rb ; Z: %lu ; N: %lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %25
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 4
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %17, %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %6
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %7
%34 = load i32, i32* %4
%35 = icmp eq i32 %34, 3
br i1 %35, label %36, label %38
36: ; preds = %25
%37 = load i32, i32* %7
br label %43
38: ; preds = %25
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 3
%41 = load i8*, i8** %40
%42 = call i32 @atoi(i8* %41)
br label %43
43: ; preds = %38, %36
%44 = phi i32 [ %37, %36 ], [ %42, %38 ]
store i32 %44, i32* %8
%45 = load i32, i32* %8
%46 = load i32, i32* %7
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %53
48: ; preds = %43
%49 = load i32, i32* @stderr
%50 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %43
%54 = load i32, i32* %7
%55 = load i32, i32* %9
%56 = load i32, i32* %10
%57 = load i32, i32* %11
%58 = call i32 @mpfr_inits2(i32 %54, i32 %55, i32 %56, i32 %57, i32 0)
%59 = load i32, i32* %12
%60 = load i32, i32* %8
%61 = call i32 @mpfr_init2(i32 %59, i32 %60)
%62 = load i32, i32* %9
%63 = load i32, i32* @GMP_RNDN
%64 = call i32 @mpfr_set_ui_2exp(i32 %62, i32 1, i32 -1, i32 %63)
br label %65
65: ; preds = %117, %53
%66 = load i32, i32* %9
%67 = call i32 @mpfr_get_exp(i32 %66)
%68 = load i32, i32* %6
%69 = icmp sle i32 %67, %68
br i1 %69, label %70, label %120
70: ; preds = %65
%71 = load i32, i32* %10
%72 = load i32, i32* @GMP_RNDN
%73 = call i32 @mpfr_set_ui_2exp(i32 %71, i32 1, i32 -1, i32 %72)
br label %74
74: ; preds = %113, %70
%75 = load i32, i32* %10
%76 = call i32 @mpfr_get_exp(i32 %75)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %116
78: ; preds = %74
%79 = load i32, i32* %11
%80 = load i32, i32* %9
%81 = load i32, i32* %10
%82 = load i32, i32* @GMP_RNDZ
%83 = call i64 @mpfr_sub(i32 %79, i32 %80, i32 %81, i32 %82)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %86
85: ; preds = %78
br label %113
86: ; preds = %78
%87 = load i32, i32* %9
%88 = load i32, i32* %10
%89 = load i32, i32* %11
%90 = load i32, i32* %12
%91 = load i32, i32* @GMP_RNDZ
%92 = call i64 @eval(i32 %87, i32 %88, i32 %89, i32 %90, i32 %91)
store i64 %92, i64* %13
%93 = load i32, i32* %9
%94 = load i32, i32* %10
%95 = load i32, i32* %11
%96 = load i32, i32* %12
%97 = load i32, i32* @GMP_RNDN
%98 = call i64 @eval(i32 %93, i32 %94, i32 %95, i32 %96, i32 %97)
store i64 %98, i64* %14
%99 = load i64, i64* %13
%100 = load i64, i64* %14
%101 = icmp eq i64 %99, %100
br i1 %101, label %102, label %103
102: ; preds = %86
br label %113
103: ; preds = %86
%104 = load i32, i32* %7
%105 = sub nsw i32 %104, 1
%106 = load i32, i32* %9
%107 = load i32, i32* %7
%108 = sub nsw i32 %107, 1
%109 = load i32, i32* %10
%110 = load i64, i64* %13
%111 = load i64, i64* %14
%112 = call i32 @mpfr_printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %105, i32 %106, i32 %108, i32 %109, i64 %110, i64 %111)
br label %113
113: ; preds = %103, %102, %85
%114 = load i32, i32* %10
%115 = call i32 @mpfr_nextabove(i32 %114)
br label %74
116: ; preds = %74
br label %117
117: ; preds = %116
%118 = load i32, i32* %9
%119 = call i32 @mpfr_nextabove(i32 %118)
br label %65
120: ; preds = %65
%121 = load i32, i32* %9
%122 = load i32, i32* %10
%123 = load i32, i32* %11
%124 = load i32, i32* %12
%125 = call i32 @mpfr_clears(i32 %121, i32 %122, i32 %123, i32 %124, i32 0)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Usage: divworst <dmax> <n> [ <p> ]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [43 x i8] c"divworst: p must be greater or equal to n\0A\00"
@GMP_RNDN = global i32 0
@GMP_RNDZ = global i32 0
@.str.2 = [41 x i8] c"x = %.*Rb ; y = %.*Rb ; Z: %lu ; N: %lu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add i32 %0, -5
%4 = icmp ult i32 %3, -2
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = icmp eq i32 %0, 3
br i1 %17, label %28, label %18
18: ; preds = %10
%19 = getelementptr inbounds i8*, i8** %1, i64 3
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = icmp slt i32 %21, %16
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = tail call i32 @exit(i32 %26)
unreachable
28: ; preds = %10, %18
%29 = phi i32 [ %21, %18 ], [ %16, %10 ]
%30 = tail call i32 @mpfr_inits2(i32 %16, i32 undef, i32 undef, i32 undef, i32 0)
%31 = tail call i32 @mpfr_init2(i32 undef, i32 %29)
%32 = load i32, i32* @GMP_RNDN
%33 = tail call i32 @mpfr_set_ui_2exp(i32 undef, i32 1, i32 -1, i32 %32)
%34 = tail call i32 @mpfr_get_exp(i32 undef)
%35 = icmp sgt i32 %34, %13
br i1 %35, label %63, label %36
36: ; preds = %28
%37 = add nsw i32 %16, -1
br label %38
38: ; preds = %36, %59
%39 = load i32, i32* @GMP_RNDN
%40 = tail call i32 @mpfr_set_ui_2exp(i32 undef, i32 1, i32 -1, i32 %39)
%41 = tail call i32 @mpfr_get_exp(i32 undef)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %59
43: ; preds = %38, %55
%44 = load i32, i32* @GMP_RNDZ
%45 = tail call i64 @mpfr_sub(i32 undef, i32 undef, i32 undef, i32 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %55
47: ; preds = %43
%48 = load i32, i32* @GMP_RNDZ
%49 = tail call i64 @eval(i32 undef, i32 undef, i32 undef, i32 undef, i32 %48)
%50 = load i32, i32* @GMP_RNDN
%51 = tail call i64 @eval(i32 undef, i32 undef, i32 undef, i32 undef, i32 %50)
%52 = icmp eq i64 %49, %51
br i1 %52, label %55, label %53
53: ; preds = %47
%54 = tail call i32 @mpfr_printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %37, i32 undef, i32 %37, i32 undef, i64 %49, i64 %51)
br label %55
55: ; preds = %47, %43, %53
%56 = tail call i32 @mpfr_nextabove(i32 undef)
%57 = tail call i32 @mpfr_get_exp(i32 undef)
%58 = icmp eq i32 %57, 0
br i1 %58, label %43, label %59
59: ; preds = %55, %38
%60 = tail call i32 @mpfr_nextabove(i32 undef)
%61 = tail call i32 @mpfr_get_exp(i32 undef)
%62 = icmp sgt i32 %61, %13
br i1 %62, label %63, label %38
63: ; preds = %59, %28
%64 = tail call i32 @mpfr_clears(i32 undef, i32 undef, i32 undef, i32 undef, i32 0)
ret i32 0
}