#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 int64_t;

/* Variables and functions */
int diophantine_minimise_x(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  (void)argc;
  (void)argv;
  int64_t max_x = 0;
  int64_t max_d = 0;
  for (int64_t D = 1; D <= 1000; D++) {
    int64_t x = diophantine_minimise_x(D);
    if (x > max_x) {
      max_x = x;
      max_d = D;
    }
  }
  printf("%ld\n", max_d);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jg     118e <main+0x6e>
mov    -0x1c(%rbp),%edi
call   1040 <diophantine_minimise_x@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    117b <main+0x5b>
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1180 <main+0x60>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114b <main+0x2b>
mov    -0x18(%rbp),%esi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%ebp
xor    %ebx,%ebx
xor    %r14d,%r14d
xchg   %ax,%ax
mov    %ebp,%edi
call   1040 <diophantine_minimise_x@plt>
cmp    %ebx,%eax
cmovg  %ebp,%r14d
cmovg  %eax,%ebx
add    $0x1,%ebp
cmp    $0x3e9,%ebp
jne    1130 <main+0x10>
lea    0xeae(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%ld\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 1, i32* %8
br label %12
12: ; preds = %25, %2
%13 = load i32, i32* %8
%14 = icmp sle i32 %13, 1000
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load i32, i32* %8
%17 = call i32 @diophantine_minimise_x(i32 %16)
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = load i32, i32* %6
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i32, i32* %9
store i32 %22, i32* %6
%23 = load i32, i32* %8
store i32 %23, i32* %7
br label %24
24: ; preds = %21, %15
br label %25
25: ; preds = %24
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %12
28: ; preds = %12
%29 = load i32, i32* %7
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%ld\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %5
3: ; preds = %5
%4 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
ret i32 0
5: ; preds = %2, %5
%6 = phi i32 [ 0, %2 ], [ %12, %5 ]
%7 = phi i32 [ 1, %2 ], [ %13, %5 ]
%8 = phi i32 [ 0, %2 ], [ %11, %5 ]
%9 = tail call i32 @diophantine_minimise_x(i32 %7)
%10 = icmp sgt i32 %9, %6
%11 = select i1 %10, i32 %7, i32 %8
%12 = select i1 %10, i32 %9, i32 %6
%13 = add nuw nsw i32 %7, 1
%14 = icmp eq i32 %13, 1001
br i1 %14, label %3, label %5
}