#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*/ assert(int);
double divide(double, double);
double fromlong(double);
int /*<<< orphan*/ printf(char *, double, ...);
double tolong(double);
void test4(int i, double b, double c) {
  double d;
  if (0)
    printf("tolong(b) = %ld\n", tolong(b));
  if (0)
    printf("tolong(c) = %ld\n", tolong(c));
  printf("Case %d: %lf, %lf\n", i, b, c);
  if (0)
    printf("My result long(b / c) = %ld\n", divide(tolong(b), tolong(c)));
  printf("My result b / c = %lf\n", d = fromlong(divide(tolong(b), tolong(c))));
  if (0)
    printf("IEEE long(b / c) = %ld\n", tolong(b / c));
  if (0)
    printf("IEEE b / c = %lf\n", b / c);
  assert(d == b / c);
}


x86 assembly (clang, -O0):
<test4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
lea    0xe85(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
movsd  -0x10(%rbp),%xmm0
call   1070 <tolong@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1070 <tolong@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
call   1030 <divide@plt>
call   1040 <fromlong@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xe5a(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
divsd  -0x18(%rbp),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test4>:
sub    $0x18,%rsp
movaps %xmm1,%xmm2
movsd  %xmm1,0x8(%rsp)
movaps %xmm0,%xmm1
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
lea    0xe8c(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
movsd  0x10(%rsp),%xmm0
call   1070 <tolong@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <tolong@plt>
movaps %xmm0,%xmm1
movsd  (%rsp),%xmm0
call   1030 <divide@plt>
call   1040 <fromlong@plt>
movsd  %xmm0,(%rsp)
lea    0xe5f(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
cmpeqsd (%rsp),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
add    $0x18,%rsp
jmp    1060 <assert@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Case %d: %lf, %lf\0A\00"
@.str.1 = [23 x i8] c"My result b / c = %lf\0A\00"
define void @test4(i32 %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
store double %2, double* %6
%8 = load i32, i32* %4
%9 = sitofp i32 %8 to double
%10 = load double, double* %5
%11 = load double, double* %6
%12 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %9, double %10, double %11)
%13 = load double, double* %5
%14 = call double @tolong(double %13)
%15 = load double, double* %6
%16 = call double @tolong(double %15)
%17 = call double @divide(double %14, double %16)
%18 = call double @fromlong(double %17)
store double %18, double* %7
%19 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double %18)
%20 = load double, double* %7
%21 = load double, double* %5
%22 = load double, double* %6
%23 = fdiv double %21, %22
%24 = fcmp oeq double %20, %23
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Case %d: %lf, %lf\0A\00"
@.str.1 = [23 x i8] c"My result b / c = %lf\0A\00"
define void @test4(i32 %0, double %1, double %2) {
%4 = sitofp i32 %0 to double
%5 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %4, double %1, double %2)
%6 = tail call double @tolong(double %1)
%7 = tail call double @tolong(double %2)
%8 = tail call double @divide(double %6, double %7)
%9 = tail call double @fromlong(double %8)
%10 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double %9)
%11 = fdiv double %1, %2
%12 = fcmp oeq double %9, %11
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
ret void
}