#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 */
struct mpm_env {
  int dummy;
};
typedef int /*<<< orphan*/ mpz_t;
typedef int /*<<< orphan*/ mpf_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ malloc(int);
int /*<<< orphan*/ mpf_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set_d(int /*<<< orphan*/, float);
int /*<<< orphan*/ mpm_c2i(struct mpm_env *, int, int /*<<< orphan*/ *,
                           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
struct mpm_env *mpm_create_env(int, int);
int /*<<< orphan*/ mpm_destroy_env(struct mpm_env *);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_get_ui(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  FILE *f = NULL;
  int dimz;
  int dimf;
  int order;
  int i, j;
  int n;
  int coordz;
  float coordf;
  mpz_t *coordsz = NULL;
  mpf_t *coordsf = NULL;
  mpz_t index;
  struct mpm_env *e;
  if (argc < 2) {
    printf("Usage: hilbert_test datafile\n");
    exit(2);
  }
  if ((f = fopen(argv[1], "r")) == NULL) {
    perror("Unable to open datafile:");
    exit(3);
  }
  fscanf(f, "%d", &dimz);
  fscanf(f, "%d\n", &dimf);
  fscanf(f, "%d\n", &order);
  fscanf(f, "%d\n", &n);
  if (dimz)
    coordsz = (mpz_t *)malloc(dimz * sizeof(mpz_t));
  if (dimf)
    coordsf = (mpf_t *)malloc(dimf * sizeof(mpf_t));
  for (i = 0; i < dimz; i++)
    mpz_init(coordsz[i]);
  for (i = 0; i < dimf; i++)
    mpf_init(coordsf[i]);
  mpz_init(index);
  e = mpm_create_env(dimz, dimf);
  for (i = 0; i < n; i++) {
    printf("(");
    for (j = 0; j < dimz; j++) {
      fscanf(f, "%d", &coordz);
      mpz_set_ui(coordsz[j], coordz);
      if (j)
        printf(", %d", coordz);
      else
        printf("%d", coordz);
    }
    for (j = 0; j < dimf; j++) {
      fscanf(f, "%f", &coordf);
      mpf_set_d(coordsf[j], coordf);
      if ((dimz + j))
        printf(", %f", coordf);
      else
        printf("%f", coordf);
    }
    mpm_c2i(e, order, coordsz, coordsf, &index);
    printf("): %d\n", (int)mpz_get_ui(index));
  }
  mpm_destroy_env(e);
  for (i = 0; i < dimz; i++)
    mpz_clear(coordsz[i]);
  for (i = 0; i < dimf; i++)
    mpf_clear(coordsf[i]);
  mpz_clear(index);
  if (dimz)
    free(coordsz);
  if (dimf)
    free(coordsf);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1270 <main+0x50>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x2,%edi
call   1140 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd9f(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    12a8 <main+0x88>
lea    0xd87(%rip),%rdi
call   1120 <perror@plt>
mov    $0x3,%edi
call   1140 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xd8a(%rip),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    0xd7f(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    0xd69(%rip),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    0xd53(%rip),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
cmpl   $0x0,-0x1c(%rbp)
je     131d <main+0xfd>
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     133a <main+0x11a>
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    136b <main+0x14b>
mov    -0x40(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1090 <mpz_init@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1341 <main+0x121>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    139c <main+0x17c>
mov    -0x48(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   10a0 <mpf_init@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1372 <main+0x152>
mov    -0x4c(%rbp),%edi
call   1090 <mpz_init@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1080 <mpm_create_env@plt>
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1525 <main+0x305>
lea    0xc6c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1454 <main+0x234>
mov    -0x18(%rbp),%rdi
lea    0xc4b(%rip),%rsi
lea    -0x34(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x34(%rbp),%esi
call   10f0 <mpz_set_ui@plt>
cmpl   $0x0,-0x2c(%rbp)
je     1430 <main+0x210>
mov    -0x34(%rbp),%esi
lea    0xc17(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1441 <main+0x221>
mov    -0x34(%rbp),%esi
lea    0xc03(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1446 <main+0x226>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    13db <main+0x1bb>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    14e7 <main+0x2c7>
mov    -0x18(%rbp),%rdi
lea    0xbd0(%rip),%rsi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x48(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
movss  -0x38(%rbp),%xmm0
call   10c0 <mpf_set_d@plt>
mov    -0x1c(%rbp),%eax
add    -0x2c(%rbp),%eax
cmp    $0x0,%eax
je     14bd <main+0x29d>
movss  -0x38(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xb8f(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
jmp    14d4 <main+0x2b4>
movss  -0x38(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xb75(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
jmp    14d9 <main+0x2b9>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    145b <main+0x23b>
mov    -0x58(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
lea    -0x4c(%rbp),%r8
call   1040 <mpm_c2i@plt>
mov    -0x4c(%rbp),%edi
call   10d0 <mpz_get_ui@plt>
mov    %eax,%esi
lea    0xb35(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    13ba <main+0x19a>
mov    -0x58(%rbp),%rdi
call   1130 <mpm_destroy_env@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    155f <main+0x33f>
mov    -0x40(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1100 <mpz_clear@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1535 <main+0x315>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1590 <main+0x370>
mov    -0x48(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   10b0 <mpf_clear@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1566 <main+0x346>
mov    -0x4c(%rbp),%edi
call   1100 <mpz_clear@plt>
cmpl   $0x0,-0x1c(%rbp)
je     15ab <main+0x38b>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x20(%rbp)
je     15be <main+0x39e>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x1,%edi
jle    1567 <main+0x327>
mov    0x8(%rsi),%rdi
lea    0xd9e(%rip),%rsi
call   1130 <fopen@plt>
test   %rax,%rax
je     157d <main+0x33d>
mov    %rax,%r12
lea    0xda3(%rip),%rsi
xor    %r14d,%r14d
mov    %rsp,%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1090 <fscanf@plt>
lea    0xd97(%rip),%rbp
lea    0x4(%rsp),%rdx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <fscanf@plt>
lea    0x1c(%rsp),%rdx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <fscanf@plt>
lea    0x14(%rsp),%rdx
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <fscanf@plt>
mov    (%rsp),%edi
test   %edi,%edi
je     12d9 <main+0x99>
shl    $0x2,%edi
call   1100 <malloc@plt>
mov    %rax,%r14
mov    0x4(%rsp),%edi
test   %edi,%edi
je     12f4 <main+0xb4>
shl    $0x2,%edi
call   1100 <malloc@plt>
mov    %rax,%r13
cmpl   $0x0,(%rsp)
jg     12fd <main+0xbd>
jmp    1316 <main+0xd6>
xor    %r13d,%r13d
cmpl   $0x0,(%rsp)
jle    1316 <main+0xd6>
xor    %ebp,%ebp
nop
mov    (%r14,%rbp,4),%edi
call   10b0 <mpz_init@plt>
add    $0x1,%rbp
movslq (%rsp),%rax
cmp    %rax,%rbp
jl     1300 <main+0xc0>
cmpl   $0x0,0x4(%rsp)
jle    1338 <main+0xf8>
xor    %ebp,%ebp
nop
mov    0x0(%r13,%rbp,4),%edi
call   10c0 <mpf_init@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rax
cmp    %rax,%rbp
jl     1320 <main+0xe0>
mov    0xc(%rsp),%edi
call   10b0 <mpz_init@plt>
mov    (%rsp),%edi
mov    0x4(%rsp),%esi
call   10a0 <mpm_create_env@plt>
mov    %rax,0x20(%rsp)
cmpl   $0x0,0x14(%rsp)
jle    14d7 <main+0x297>
xor    %eax,%eax
mov    %r14,0x30(%rsp)
mov    %r13,0x28(%rsp)
jmp    13b8 <main+0x178>
nopl   0x0(%rax,%rax,1)
mov    0x1c(%rsp),%esi
mov    0x20(%rsp),%rdi
mov    0x30(%rsp),%r14
mov    %r14,%rdx
mov    %r13,%rcx
lea    0xc(%rsp),%r8
call   1060 <mpm_c2i@plt>
mov    0xc(%rsp),%edi
call   10f0 <mpz_get_ui@plt>
lea    0xc87(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x18(%rsp),%eax
add    $0x1,%eax
cmp    0x14(%rsp),%eax
jge    14d7 <main+0x297>
mov    %eax,0x18(%rsp)
mov    $0x28,%edi
call   1040 <putchar@plt>
cmpl   $0x0,(%rsp)
mov    %r14,%r13
lea    0xc49(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xc3b(%rip),%rbx
jle    1459 <main+0x219>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1090 <fscanf@plt>
mov    0x0(%r13),%edi
mov    0x8(%rsp),%esi
call   1110 <mpz_set_ui@plt>
mov    0x8(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
cmpl   $0x2,(%rsp)
jl     1459 <main+0x219>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1090 <fscanf@plt>
mov    0x0(%r13,%rbp,4),%edi
mov    0x8(%rsp),%esi
call   1110 <mpz_set_ui@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movslq (%rsp),%rax
add    $0x1,%rbp
cmp    %rax,%rbp
jl     1420 <main+0x1e0>
cmpl   $0x0,0x4(%rsp)
lea    0x10(%rsp),%rbx
mov    0x28(%rsp),%r13
lea    0xbb3(%rip),%r15
jle    1370 <main+0x130>
xor    %r14d,%r14d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <fscanf@plt>
mov    0x0(%r13,%rbp,4),%edi
movss  0x10(%rsp),%xmm0
call   10e0 <mpf_set_d@plt>
cmp    (%rsp),%r14d
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xb6b(%rip),%rdi
cmove  %r15,%rdi
mov    $0x1,%al
call   1080 <printf@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rax
add    $0xffffffff,%r14d
cmp    %rax,%rbp
jl     1480 <main+0x240>
jmp    1370 <main+0x130>
mov    0x20(%rsp),%rdi
call   1150 <mpm_destroy_env@plt>
cmpl   $0x0,(%rsp)
jle    1506 <main+0x2c6>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r14,%rbp,4),%edi
call   1120 <mpz_clear@plt>
add    $0x1,%rbp
movslq (%rsp),%rax
cmp    %rax,%rbp
jl     14f0 <main+0x2b0>
cmpl   $0x0,0x4(%rsp)
jle    1528 <main+0x2e8>
xor    %ebp,%ebp
nop
mov    0x0(%r13,%rbp,4),%edi
call   10d0 <mpf_clear@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rax
cmp    %rax,%rbp
jl     1510 <main+0x2d0>
mov    0xc(%rsp),%edi
call   1120 <mpz_clear@plt>
cmpl   $0x0,(%rsp)
je     153f <main+0x2ff>
mov    %r14,%rdi
call   1030 <free@plt>
cmpl   $0x0,0x4(%rsp)
je     154e <main+0x30e>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xabe(%rip),%rdi
call   1050 <puts@plt>
mov    $0x2,%edi
call   1160 <exit@plt>
lea    0xa7e(%rip),%rdi
call   1140 <perror@plt>
mov    $0x3,%edi
call   1160 <exit@plt>

LLVM IR (-O0):
%struct.mpm_env = type { i32 }
@.str = [30 x i8] c"Usage: hilbert_test datafile\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"Unable to open datafile:\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.5 = [2 x i8] c"(\00"
@.str.6 = [5 x i8] c", %d\00"
@.str.7 = [3 x i8] c"%f\00"
@.str.8 = [5 x i8] c", %f\00"
@.str.9 = [7 x i8] c"): %d\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 i32
%14 = alloca float
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32
%18 = alloca %struct.mpm_env*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %15
store i32* null, i32** %16
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 2
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 2)
unreachable
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %6
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @exit(i32 3)
unreachable
33: ; preds = %24
%34 = load i32*, i32** %6
%35 = call i32 (i32*, i8*, ...) @fscanf(i32* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%36 = load i32*, i32** %6
%37 = call i32 (i32*, i8*, ...) @fscanf(i32* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%38 = load i32*, i32** %6
%39 = call i32 (i32*, i8*, ...) @fscanf(i32* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %9)
%40 = load i32*, i32** %6
%41 = call i32 (i32*, i8*, ...) @fscanf(i32* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %12)
%42 = load i32, i32* %7
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %51
44: ; preds = %33
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = mul i64 %46, 4
%48 = trunc i64 %47 to i32
%49 = call i64 @malloc(i32 %48)
%50 = inttoptr i64 %49 to i32*
store i32* %50, i32** %15
br label %51
51: ; preds = %44, %33
%52 = load i32, i32* %8
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %51
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = mul i64 %56, 4
%58 = trunc i64 %57 to i32
%59 = call i64 @malloc(i32 %58)
%60 = inttoptr i64 %59 to i32*
store i32* %60, i32** %16
br label %61
61: ; preds = %54, %51
store i32 0, i32* %10
br label %62
62: ; preds = %73, %61
%63 = load i32, i32* %10
%64 = load i32, i32* %7
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %76
66: ; preds = %62
%67 = load i32*, i32** %15
%68 = load i32, i32* %10
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
%71 = load i32, i32* %70
%72 = call i32 @mpz_init(i32 %71)
br label %73
73: ; preds = %66
%74 = load i32, i32* %10
%75 = add nsw i32 %74, 1
store i32 %75, i32* %10
br label %62
76: ; preds = %62
store i32 0, i32* %10
br label %77
77: ; preds = %88, %76
%78 = load i32, i32* %10
%79 = load i32, i32* %8
%80 = icmp slt i32 %78, %79
br i1 %80, label %81, label %91
81: ; preds = %77
%82 = load i32*, i32** %16
%83 = load i32, i32* %10
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i32, i32* %82, i64 %84
%86 = load i32, i32* %85
%87 = call i32 @mpf_init(i32 %86)
br label %88
88: ; preds = %81
%89 = load i32, i32* %10
%90 = add nsw i32 %89, 1
store i32 %90, i32* %10
br label %77
91: ; preds = %77
%92 = load i32, i32* %17
%93 = call i32 @mpz_init(i32 %92)
%94 = load i32, i32* %7
%95 = load i32, i32* %8
%96 = call %struct.mpm_env* @mpm_create_env(i32 %94, i32 %95)
store %struct.mpm_env* %96, %struct.mpm_env** %18
store i32 0, i32* %10
br label %97
97: ; preds = %170, %91
%98 = load i32, i32* %10
%99 = load i32, i32* %12
%100 = icmp slt i32 %98, %99
br i1 %100, label %101, label %173
101: ; preds = %97
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %11
br label %103
103: ; preds = %126, %101
%104 = load i32, i32* %11
%105 = load i32, i32* %7
%106 = icmp slt i32 %104, %105
br i1 %106, label %107, label %129
107: ; preds = %103
%108 = load i32*, i32** %6
%109 = call i32 (i32*, i8*, ...) @fscanf(i32* %108, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %13)
%110 = load i32*, i32** %15
%111 = load i32, i32* %11
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds i32, i32* %110, i64 %112
%114 = load i32, i32* %113
%115 = load i32, i32* %13
%116 = call i32 @mpz_set_ui(i32 %114, i32 %115)
%117 = load i32, i32* %11
%118 = icmp ne i32 %117, 0
br i1 %118, label %119, label %122
119: ; preds = %107
%120 = load i32, i32* %13
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %120)
br label %125
122: ; preds = %107
%123 = load i32, i32* %13
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %123)
br label %125
125: ; preds = %122, %119
br label %126
126: ; preds = %125
%127 = load i32, i32* %11
%128 = add nsw i32 %127, 1
store i32 %128, i32* %11
br label %103
129: ; preds = %103
store i32 0, i32* %11
br label %130
130: ; preds = %157, %129
%131 = load i32, i32* %11
%132 = load i32, i32* %8
%133 = icmp slt i32 %131, %132
br i1 %133, label %134, label %160
134: ; preds = %130
%135 = load i32*, i32** %6
%136 = call i32 (i32*, i8*, ...) @fscanf(i32* %135, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), float* %14)
%137 = load i32*, i32** %16
%138 = load i32, i32* %11
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds i32, i32* %137, i64 %139
%141 = load i32, i32* %140
%142 = load float, float* %14
%143 = call i32 @mpf_set_d(i32 %141, float %142)
%144 = load i32, i32* %7
%145 = load i32, i32* %11
%146 = add nsw i32 %144, %145
%147 = icmp ne i32 %146, 0
br i1 %147, label %148, label %152
148: ; preds = %134
%149 = load float, float* %14
%150 = fpext float %149 to double
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), double %150)
br label %156
152: ; preds = %134
%153 = load float, float* %14
%154 = fpext float %153 to double
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), double %154)
br label %156
156: ; preds = %152, %148
br label %157
157: ; preds = %156
%158 = load i32, i32* %11
%159 = add nsw i32 %158, 1
store i32 %159, i32* %11
br label %130
160: ; preds = %130
%161 = load %struct.mpm_env*, %struct.mpm_env** %18
%162 = load i32, i32* %9
%163 = load i32*, i32** %15
%164 = load i32*, i32** %16
%165 = call i32 @mpm_c2i(%struct.mpm_env* %161, i32 %162, i32* %163, i32* %164, i32* %17)
%166 = load i32, i32* %17
%167 = call i64 @mpz_get_ui(i32 %166)
%168 = trunc i64 %167 to i32
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %168)
br label %170
170: ; preds = %160
%171 = load i32, i32* %10
%172 = add nsw i32 %171, 1
store i32 %172, i32* %10
br label %97
173: ; preds = %97
%174 = load %struct.mpm_env*, %struct.mpm_env** %18
%175 = call i32 @mpm_destroy_env(%struct.mpm_env* %174)
store i32 0, i32* %10
br label %176
176: ; preds = %187, %173
%177 = load i32, i32* %10
%178 = load i32, i32* %7
%179 = icmp slt i32 %177, %178
br i1 %179, label %180, label %190
180: ; preds = %176
%181 = load i32*, i32** %15
%182 = load i32, i32* %10
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds i32, i32* %181, i64 %183
%185 = load i32, i32* %184
%186 = call i32 @mpz_clear(i32 %185)
br label %187
187: ; preds = %180
%188 = load i32, i32* %10
%189 = add nsw i32 %188, 1
store i32 %189, i32* %10
br label %176
190: ; preds = %176
store i32 0, i32* %10
br label %191
191: ; preds = %202, %190
%192 = load i32, i32* %10
%193 = load i32, i32* %8
%194 = icmp slt i32 %192, %193
br i1 %194, label %195, label %205
195: ; preds = %191
%196 = load i32*, i32** %16
%197 = load i32, i32* %10
%198 = sext i32 %197 to i64
%199 = getelementptr inbounds i32, i32* %196, i64 %198
%200 = load i32, i32* %199
%201 = call i32 @mpf_clear(i32 %200)
br label %202
202: ; preds = %195
%203 = load i32, i32* %10
%204 = add nsw i32 %203, 1
store i32 %204, i32* %10
br label %191
205: ; preds = %191
%206 = load i32, i32* %17
%207 = call i32 @mpz_clear(i32 %206)
%208 = load i32, i32* %7
%209 = icmp ne i32 %208, 0
br i1 %209, label %210, label %213
210: ; preds = %205
%211 = load i32*, i32** %15
%212 = call i32 @free(i32* %211)
br label %213
213: ; preds = %210, %205
%214 = load i32, i32* %8
%215 = icmp ne i32 %214, 0
br i1 %215, label %216, label %219
216: ; preds = %213
%217 = load i32*, i32** %16
%218 = call i32 @free(i32* %217)
br label %219
219: ; preds = %216, %213
%220 = load i32*, i32** %6
%221 = call i32 @fclose(i32* %220)
ret i32 0
}

LLVM IR (-O2):
%struct.mpm_env = type { i32 }
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"Unable to open datafile:\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.6 = [5 x i8] c", %d\00"
@.str.7 = [3 x i8] c"%f\00"
@.str.8 = [5 x i8] c", %f\00"
@.str.9 = [7 x i8] c"): %d\0A\00"
@str = [29 x i8] c"Usage: hilbert_test datafile\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
%9 = alloca i32
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = bitcast float* %8 to i8*
%16 = bitcast i32* %9 to i8*
%17 = icmp slt i32 %0, 2
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%20 = tail call i32 @exit(i32 2)
unreachable
21: ; preds = %2
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%28 = tail call i32 @exit(i32 3)
unreachable
29: ; preds = %21
%30 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%31 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%32 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %5)
%33 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %29
%37 = shl i32 %34, 2
%38 = call i64 @malloc(i32 %37)
%39 = inttoptr i64 %38 to i32*
br label %40
40: ; preds = %36, %29
%41 = phi i32* [ %39, %36 ], [ null, %29 ]
%42 = load i32, i32* %4
%43 = icmp eq i32 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = shl i32 %42, 2
%46 = call i64 @malloc(i32 %45)
%47 = inttoptr i64 %46 to i32*
br label %48
48: ; preds = %44, %40
%49 = phi i32* [ %47, %44 ], [ null, %40 ]
%50 = load i32, i32* %3
%51 = icmp sgt i32 %50, 0
br i1 %51, label %55, label %52
52: ; preds = %55, %48
%53 = load i32, i32* %4
%54 = icmp sgt i32 %53, 0
br i1 %54, label %64, label %73
55: ; preds = %48, %55
%56 = phi i64 [ %60, %55 ], [ 0, %48 ]
%57 = getelementptr inbounds i32, i32* %41, i64 %56
%58 = load i32, i32* %57
%59 = call i32 @mpz_init(i32 %58)
%60 = add nuw nsw i64 %56, 1
%61 = load i32, i32* %3
%62 = sext i32 %61 to i64
%63 = icmp slt i64 %60, %62
br i1 %63, label %55, label %52
64: ; preds = %52, %64
%65 = phi i64 [ %69, %64 ], [ 0, %52 ]
%66 = getelementptr inbounds i32, i32* %49, i64 %65
%67 = load i32, i32* %66
%68 = call i32 @mpf_init(i32 %67)
%69 = add nuw nsw i64 %65, 1
%70 = load i32, i32* %4
%71 = sext i32 %70 to i64
%72 = icmp slt i64 %69, %71
br i1 %72, label %64, label %73
73: ; preds = %64, %52
%74 = load i32, i32* %9
%75 = call i32 @mpz_init(i32 %74)
%76 = load i32, i32* %3
%77 = load i32, i32* %4
%78 = call %struct.mpm_env* @mpm_create_env(i32 %76, i32 %77)
%79 = load i32, i32* %6
%80 = icmp sgt i32 %79, 0
br i1 %80, label %81, label %140
81: ; preds = %73, %130
%82 = phi i32 [ %137, %130 ], [ 0, %73 ]
%83 = call i32 @putchar(i32 40)
%84 = load i32, i32* %3
%85 = icmp sgt i32 %84, 0
br i1 %85, label %86, label %95
86: ; preds = %81
%87 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%88 = load i32, i32* %41
%89 = load i32, i32* %7
%90 = call i32 @mpz_set_ui(i32 %88, i32 %89)
%91 = load i32, i32* %7
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %91)
%93 = load i32, i32* %3
%94 = icmp sgt i32 %93, 1
br i1 %94, label %98, label %95
95: ; preds = %98, %86, %81
%96 = load i32, i32* %4
%97 = icmp sgt i32 %96, 0
br i1 %97, label %111, label %130
98: ; preds = %86, %98
%99 = phi i64 [ %108, %98 ], [ 1, %86 ]
%100 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%101 = getelementptr inbounds i32, i32* %41, i64 %99
%102 = load i32, i32* %101
%103 = load i32, i32* %7
%104 = call i32 @mpz_set_ui(i32 %102, i32 %103)
%105 = load i32, i32* %7
%106 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %105)
%107 = load i32, i32* %3
%108 = add nuw nsw i64 %99, 1
%109 = sext i32 %107 to i64
%110 = icmp slt i64 %108, %109
br i1 %110, label %98, label %95
111: ; preds = %95, %111
%112 = phi i64 [ %126, %111 ], [ 0, %95 ]
%113 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), float* %8)
%114 = getelementptr inbounds i32, i32* %49, i64 %112
%115 = load i32, i32* %114
%116 = load float, float* %8
%117 = call i32 @mpf_set_d(i32 %115, float %116)
%118 = load i32, i32* %3
%119 = trunc i64 %112 to i32
%120 = sub i32 0, %119
%121 = icmp eq i32 %118, %120
%122 = load float, float* %8
%123 = fpext float %122 to double
%124 = select i1 %121, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0)
%125 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %124, double %123)
%126 = add nuw nsw i64 %112, 1
%127 = load i32, i32* %4
%128 = sext i32 %127 to i64
%129 = icmp slt i64 %126, %128
br i1 %129, label %111, label %130
130: ; preds = %111, %95
%131 = load i32, i32* %5
%132 = call i32 @mpm_c2i(%struct.mpm_env* %78, i32 %131, i32* %41, i32* %49, i32* %9)
%133 = load i32, i32* %9
%134 = call i64 @mpz_get_ui(i32 %133)
%135 = trunc i64 %134 to i32
%136 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %135)
%137 = add nuw nsw i32 %82, 1
%138 = load i32, i32* %6
%139 = icmp slt i32 %137, %138
br i1 %139, label %81, label %140
140: ; preds = %130, %73
%141 = call i32 @mpm_destroy_env(%struct.mpm_env* %78)
%142 = load i32, i32* %3
%143 = icmp sgt i32 %142, 0
br i1 %143, label %147, label %144
144: ; preds = %147, %140
%145 = load i32, i32* %4
%146 = icmp sgt i32 %145, 0
br i1 %146, label %156, label %165
147: ; preds = %140, %147
%148 = phi i64 [ %152, %147 ], [ 0, %140 ]
%149 = getelementptr inbounds i32, i32* %41, i64 %148
%150 = load i32, i32* %149
%151 = call i32 @mpz_clear(i32 %150)
%152 = add nuw nsw i64 %148, 1
%153 = load i32, i32* %3
%154 = sext i32 %153 to i64
%155 = icmp slt i64 %152, %154
br i1 %155, label %147, label %144
156: ; preds = %144, %156
%157 = phi i64 [ %161, %156 ], [ 0, %144 ]
%158 = getelementptr inbounds i32, i32* %49, i64 %157
%159 = load i32, i32* %158
%160 = call i32 @mpf_clear(i32 %159)
%161 = add nuw nsw i64 %157, 1
%162 = load i32, i32* %4
%163 = sext i32 %162 to i64
%164 = icmp slt i64 %161, %163
br i1 %164, label %156, label %165
165: ; preds = %156, %144
%166 = load i32, i32* %9
%167 = call i32 @mpz_clear(i32 %166)
%168 = load i32, i32* %3
%169 = icmp eq i32 %168, 0
br i1 %169, label %172, label %170
170: ; preds = %165
%171 = call i32 @free(i32* %41)
br label %172
172: ; preds = %170, %165
%173 = load i32, i32* %4
%174 = icmp eq i32 %173, 0
br i1 %174, label %177, label %175
175: ; preds = %172
%176 = call i32 @free(i32* %49)
br label %177
177: ; preds = %175, %172
%178 = call i32 @fclose(i32* %24)
ret i32 0
}