#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*/ do_nothing();
int /*<<< orphan*/ printf(char *, double, char, double);
double recip(int);
void test4(int denom) {
  double r1, r2;
  int t1, t2;
  r1 = recip(denom);
  r2 = 1.0 / (double)denom;
  t1 = r1 == r2;
  do_nothing();
  t2 = r1 == r2;
  printf("test4 t1: r1 %f %c= r2 %f\n", r1, t1 ? '=' : '!', r2);
  printf("test4 t2: r1 %f %c= r2 %f\n", r1, t2 ? '=' : '!', r2);
}


x86 assembly (clang, -O0):
<test4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <recip@plt>
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xeab(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <do_nothing@plt>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x1c(%rbp),%edx
mov    $0x21,%eax
mov    $0x3d,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsd  -0x18(%rbp),%xmm1
lea    0xe4b(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
mov    -0x20(%rbp),%edx
mov    $0x21,%eax
mov    $0x3d,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsd  -0x18(%rbp),%xmm1
lea    0xe3a(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test4>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
call   1050 <recip@plt>
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0xeaf(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
xor    %eax,%eax
call   1040 <do_nothing@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
ucomisd %xmm1,%xmm0
mov    $0x21,%eax
mov    $0x3d,%ebx
cmovne %eax,%ebx
cmovp  %eax,%ebx
lea    0xe81(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    %ebx,%esi
movsd  (%rsp),%xmm1
add    $0x10,%rsp
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"test4 t1: r1 %f %c= r2 %f\0A\00"
@.str.1 = [27 x i8] c"test4 t2: r1 %f %c= r2 %f\0A\00"
define void @test4(i32 %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = call double @recip(i32 %7)
store double %8, double* %3
%9 = load i32, i32* %2
%10 = sitofp i32 %9 to double
%11 = fdiv double 1.000000e+00, %10
store double %11, double* %4
%12 = load double, double* %3
%13 = load double, double* %4
%14 = fcmp oeq double %12, %13
%15 = zext i1 %14 to i32
store i32 %15, i32* %5
%16 = call i32 (...) @do_nothing()
%17 = load double, double* %3
%18 = load double, double* %4
%19 = fcmp oeq double %17, %18
%20 = zext i1 %19 to i32
store i32 %20, i32* %6
%21 = load double, double* %3
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i32 61, i32 33
%26 = trunc i32 %25 to i8
%27 = load double, double* %4
%28 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), double %21, i8 signext %26, double %27)
%29 = load double, double* %3
%30 = load i32, i32* %6
%31 = icmp ne i32 %30, 0
%32 = zext i1 %31 to i64
%33 = select i1 %31, i32 61, i32 33
%34 = trunc i32 %33 to i8
%35 = load double, double* %4
%36 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), double %29, i8 signext %34, double %35)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"test4 t1: r1 %f %c= r2 %f\0A\00"
@.str.1 = [27 x i8] c"test4 t2: r1 %f %c= r2 %f\0A\00"
define void @test4(i32 %0) {
%2 = tail call double @recip(i32 %0)
%3 = sitofp i32 %0 to double
%4 = fdiv double 1.000000e+00, %3
%5 = fcmp oeq double %2, %4
%6 = tail call i32 (...) @do_nothing()
%7 = select i1 %5, i8 61, i8 33
%8 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), double %2, i8 signext %7, double %4)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), double %2, i8 signext %7, double %4)
ret void
}