#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 */
int /*<<< orphan*/ gen_rational_best_approximation(unsigned long, unsigned long,
                                                   unsigned long, unsigned long,
                                                   unsigned long *,
                                                   unsigned long *,
                                                   unsigned long);
int /*<<< orphan*/ limit2_u64(unsigned long *, int, int);
unsigned long mksym_u64();
unsigned long rational_best_approximation(unsigned long, unsigned long,
                                          unsigned long, unsigned long,
                                          unsigned long *, unsigned long *);
void test_rational() {
  unsigned long num = 2;
  unsigned long den = 4;
  unsigned long max_num = 100;
  unsigned long max_den = 100;
  unsigned long best_num = 0;
  unsigned long best_den = 0;
  num = mksym_u64();
  limit2_u64(&num, 1, 4);
  unsigned long status = rational_best_approximation(num, den, max_num, max_den,
                                                     &best_num, &best_den);
  gen_rational_best_approximation(num, den, max_num, max_den, &best_num,
                                  &best_den, status);
}


x86 assembly (clang, -O0):
<test_rational>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movq   $0x2,-0x8(%rbp)
movq   $0x4,-0x10(%rbp)
movq   $0x64,-0x18(%rbp)
movq   $0x64,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    $0x0,%al
call   1040 <mksym_u64@plt>
mov    %rax,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <limit2_u64@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
lea    -0x30(%rbp),%r9
call   1060 <rational_best_approximation@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x38(%rbp),%rax
lea    -0x28(%rbp),%r8
lea    -0x30(%rbp),%r9
mov    %rax,(%rsp)
call   1050 <gen_rational_best_approximation@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_rational>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x20(%rsp)
movq   $0x0,0x18(%rsp)
xor    %eax,%eax
call   1040 <mksym_u64@plt>
mov    %rax,0x10(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <limit2_u64@plt>
mov    0x10(%rsp),%rdi
lea    0x20(%rsp),%rbx
lea    0x18(%rsp),%r14
mov    $0x4,%esi
mov    $0x64,%edx
mov    $0x64,%ecx
mov    %rbx,%r8
mov    %r14,%r9
call   1060 <rational_best_approximation@plt>
mov    0x10(%rsp),%rdi
mov    %rax,(%rsp)
mov    $0x4,%esi
mov    $0x64,%edx
mov    $0x64,%ecx
mov    %rbx,%r8
mov    %r14,%r9
call   1050 <gen_rational_best_approximation@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @test_rational() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i64 2, i64* %1
store i64 4, i64* %2
store i64 100, i64* %3
store i64 100, i64* %4
store i64 0, i64* %5
store i64 0, i64* %6
%8 = call i64 (...) @mksym_u64()
store i64 %8, i64* %1
%9 = call i32 @limit2_u64(i64* %1, i32 1, i32 4)
%10 = load i64, i64* %1
%11 = load i64, i64* %2
%12 = load i64, i64* %3
%13 = load i64, i64* %4
%14 = call i64 @rational_best_approximation(i64 %10, i64 %11, i64 %12, i64 %13, i64* %5, i64* %6)
store i64 %14, i64* %7
%15 = load i64, i64* %1
%16 = load i64, i64* %2
%17 = load i64, i64* %3
%18 = load i64, i64* %4
%19 = load i64, i64* %7
%20 = call i32 @gen_rational_best_approximation(i64 %15, i64 %16, i64 %17, i64 %18, i64* %5, i64* %6, i64 %19)
ret void
}

LLVM IR (-O2):
define void @test_rational() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %1 to i8*
%5 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = tail call i64 (...) @mksym_u64()
store i64 %7, i64* %1
%8 = call i32 @limit2_u64(i64* %1, i32 1, i32 4)
%9 = load i64, i64* %1
%10 = call i64 @rational_best_approximation(i64 %9, i64 4, i64 100, i64 100, i64* %2, i64* %3)
%11 = load i64, i64* %1
%12 = call i32 @gen_rational_best_approximation(i64 %11, i64 4, i64 100, i64 100, i64* %2, i64* %3, i64 %10)
ret void
}