#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*/ double2rational(double);
int gcd(int, int);
int /*<<< orphan*/ printf(char *, int, int, int);
void test_gcd_double2rational() {
  int m = 6, n = 9;
  printf("gcd of %d and %d = %d\n", m, n, gcd(m, n));
  double ds[] = {1234.5678, 0.5223, 1.125, 6.116, 42.0};
  for (int i = 0; i < 4; i++)
    double2rational(ds[i]);
}


x86 assembly (clang, -O0):
<test_gcd_double2rational>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x6,-0x4(%rbp)
movl   $0x9,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <gcd@plt>
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    %eax,%ecx
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movsd  0xe87(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe72(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe5d(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe48(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe33(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    1200 <test_gcd_double2rational+0xc0>
movslq -0x34(%rbp),%rax
movsd  -0x30(%rbp,%rax,8),%xmm0
call   1060 <double2rational@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11d9 <test_gcd_double2rational+0x99>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_gcd_double2rational>:
push   %rax
mov    $0x6,%edi
mov    $0x9,%esi
call   1040 <gcd@plt>
lea    0xed9(%rip),%rdi
mov    $0x6,%esi
mov    $0x9,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
movsd  0xea0(%rip),%xmm0
call   1050 <double2rational@plt>
movsd  0xe9b(%rip),%xmm0
call   1050 <double2rational@plt>
movsd  0xe96(%rip),%xmm0
call   1050 <double2rational@plt>
movsd  0xe91(%rip),%xmm0
pop    %rax
jmp    1050 <double2rational@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"gcd of %d and %d = %d\0A\00"
define void @test_gcd_double2rational() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x double]
%4 = alloca i32
store i32 6, i32* %1
store i32 9, i32* %2
%5 = load i32, i32* %1
%6 = load i32, i32* %2
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = call i32 @gcd(i32 %7, i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6, i32 %9)
%11 = bitcast [5 x double]* %3 to i8*
%12 = bitcast i8* %11 to [5 x double]*
%13 = getelementptr inbounds [5 x double], [5 x double]* %12, i32 0, i32 0
store double 0x40934A456D5CFAAD, double* %13
%14 = getelementptr inbounds [5 x double], [5 x double]* %12, i32 0, i32 1
store double 5.223000e-01, double* %14
%15 = getelementptr inbounds [5 x double], [5 x double]* %12, i32 0, i32 2
store double 1.125000e+00, double* %15
%16 = getelementptr inbounds [5 x double], [5 x double]* %12, i32 0, i32 3
store double 6.116000e+00, double* %16
%17 = getelementptr inbounds [5 x double], [5 x double]* %12, i32 0, i32 4
store double 4.200000e+01, double* %17
store i32 0, i32* %4
br label %18
18: ; preds = %27, %0
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 4
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 %23
%25 = load double, double* %24
%26 = call i32 @double2rational(double %25)
br label %27
27: ; preds = %21
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %18
30: ; preds = %18
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"gcd of %d and %d = %d\0A\00"
define void @test_gcd_double2rational() {
%1 = tail call i32 @gcd(i32 6, i32 9)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 6, i32 9, i32 %1)
%3 = tail call i32 @double2rational(double 0x40934A456D5CFAAD)
%4 = tail call i32 @double2rational(double 5.223000e-01)
%5 = tail call i32 @double2rational(double 1.125000e+00)
%6 = tail call i32 @double2rational(double 6.116000e+00)
ret void
}