#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*/ foo(double);
void bar(double x, double y) {
  foo(x);
  if (y)
    x = y ? 0 : 1 / y;
  else if (y)
    x = y < 1 ? 1 : y;
  else
    x = 1 / y < 1 ? 1 : x;
  foo(x);
}


x86 assembly (clang, -O0):
<bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <foo@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1149 <bar+0x39>
jp     1149 <bar+0x39>
jmp    1194 <bar+0x84>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1166 <bar+0x56>
jp     1166 <bar+0x56>
jmp    1173 <bar+0x63>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1185 <bar+0x75>
movsd  0xe85(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1239 <bar+0x129>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11b1 <bar+0xa1>
jp     11b1 <bar+0xa1>
jmp    11ef <bar+0xdf>
movsd  0xe47(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11d6 <bar+0xc6>
movsd  0xe34(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11e0 <bar+0xd0>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1234 <bar+0x124>
movsd  0xe09(%rip),%xmm1
divsd  -0x10(%rbp),%xmm1
movsd  0xdfc(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1220 <bar+0x110>
movsd  0xdea(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    122a <bar+0x11a>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1239 <bar+0x129>
movsd  -0x8(%rbp),%xmm0
call   1030 <foo@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bar>:
sub    $0x28,%rsp
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,0x10(%rsp)
call   1030 <foo@plt>
movsd  0x8(%rsp),%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jne    1137 <bar+0x27>
jnp    1140 <bar+0x30>
add    $0x28,%rsp
jmp    1030 <foo@plt>
movsd  0xeb8(%rip),%xmm1
movapd %xmm1,%xmm0
divsd  %xmm2,%xmm0
cmpltsd %xmm1,%xmm0
andpd  %xmm0,%xmm1
andnpd 0x10(%rsp),%xmm0
orpd   %xmm1,%xmm0
add    $0x28,%rsp
jmp    1030 <foo@plt>

LLVM IR (-O0):
define void @bar(double %0, double %1) {
%3 = alloca double
%4 = alloca double
store double %0, double* %3
store double %1, double* %4
%5 = load double, double* %3
%6 = call i32 @foo(double %5)
%7 = load double, double* %4
%8 = fcmp une double %7, 0.000000e+00
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = load double, double* %4
%11 = fcmp une double %10, 0.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %9
br label %16
13: ; preds = %9
%14 = load double, double* %4
%15 = fdiv double 1.000000e+00, %14
br label %16
16: ; preds = %13, %12
%17 = phi double [ 0.000000e+00, %12 ], [ %15, %13 ]
store double %17, double* %3
br label %39
18: ; preds = %2
%19 = load double, double* %4
%20 = fcmp une double %19, 0.000000e+00
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load double, double* %4
%23 = fcmp olt double %22, 1.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %21
br label %27
25: ; preds = %21
%26 = load double, double* %4
br label %27
27: ; preds = %25, %24
%28 = phi double [ 1.000000e+00, %24 ], [ %26, %25 ]
store double %28, double* %3
br label %38
29: ; preds = %18
%30 = load double, double* %4
%31 = fdiv double 1.000000e+00, %30
%32 = fcmp olt double %31, 1.000000e+00
br i1 %32, label %33, label %34
33: ; preds = %29
br label %36
34: ; preds = %29
%35 = load double, double* %3
br label %36
36: ; preds = %34, %33
%37 = phi double [ 1.000000e+00, %33 ], [ %35, %34 ]
store double %37, double* %3
br label %38
38: ; preds = %36, %27
br label %39
39: ; preds = %38, %16
%40 = load double, double* %3
%41 = call i32 @foo(double %40)
ret void
}

LLVM IR (-O2):
define void @bar(double %0, double %1) {
%3 = tail call i32 @foo(double %0)
%4 = fcmp une double %1, 0.000000e+00
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = fdiv double 1.000000e+00, %1
%7 = fcmp olt double %6, 1.000000e+00
%8 = select i1 %7, double 1.000000e+00, double %0
br label %9
9: ; preds = %2, %5
%10 = phi double [ %8, %5 ], [ 0.000000e+00, %2 ]
%11 = tail call i32 @foo(double %10)
ret void
}