#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 fang(float);
float fun1(int m, int n) {
  float x1 = m, x2 = n, tmp;
  while (fang((x1 + x2) / 2) != 0) {
    tmp = (x1 + x2) / 2;
    if (fang(x1) * fang(tmp) < 0)
      x2 = tmp;
    else if (fang(x1) * fang(tmp) > 0)
      x1 = tmp;
  }
  return (x1 + x2) / 2;
}


x86 assembly (clang, -O0):
<fun1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  0xebc(%rip),%xmm1
divss  %xmm1,%xmm0
call   1030 <fang@plt>
cmp    $0x0,%eax
je     11e4 <fun1+0xd4>
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  0xe98(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <fang@plt>
mov    %eax,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <fang@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   %ecx,%eax
cmp    $0x0,%eax
jge    11a8 <fun1+0x98>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11df <fun1+0xcf>
movss  -0xc(%rbp),%xmm0
call   1030 <fang@plt>
mov    %eax,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <fang@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   %ecx,%eax
cmp    $0x0,%eax
jle    11da <fun1+0xca>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11df <fun1+0xcf>
jmp    1132 <fun1+0x22>
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  0xe0a(%rip),%xmm1
divss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun1>:
push   %rbx
sub    $0x10,%rsp
cvtsi2ss %edi,%xmm1
cvtsi2ss %esi,%xmm0
movss  %xmm0,0xc(%rsp)
jmp    1139 <fun1+0x29>
cs nopw 0x0(%rax,%rax,1)
nop
movaps %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
movss  %xmm1,0x8(%rsp)
addss  %xmm1,%xmm0
mulss  0xeb5(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
call   1030 <fang@plt>
test   %eax,%eax
je     11c7 <fun1+0xb7>
movss  0x8(%rsp),%xmm0
call   1030 <fang@plt>
mov    %eax,%ebx
movss  0x4(%rsp),%xmm0
call   1030 <fang@plt>
imul   %ebx,%eax
test   %eax,%eax
js     11b0 <fun1+0xa0>
movss  0x8(%rsp),%xmm0
call   1030 <fang@plt>
mov    %eax,%ebx
movss  0x4(%rsp),%xmm0
call   1030 <fang@plt>
imul   %ebx,%eax
test   %eax,%eax
movss  0x4(%rsp),%xmm0
jg     1130 <fun1+0x20>
movss  0x8(%rsp),%xmm0
jmp    1130 <fun1+0x20>
cs nopw 0x0(%rax,%rax,1)
movss  0x4(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm1
jmp    1139 <fun1+0x29>
movss  0x4(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @fun1(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = sitofp i32 %8 to float
store float %9, float* %5
%10 = load i32, i32* %4
%11 = sitofp i32 %10 to float
store float %11, float* %6
br label %12
12: ; preds = %42, %2
%13 = load float, float* %5
%14 = load float, float* %6
%15 = fadd float %13, %14
%16 = fdiv float %15, 2.000000e+00
%17 = call i32 @fang(float %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %43
19: ; preds = %12
%20 = load float, float* %5
%21 = load float, float* %6
%22 = fadd float %20, %21
%23 = fdiv float %22, 2.000000e+00
store float %23, float* %7
%24 = load float, float* %5
%25 = call i32 @fang(float %24)
%26 = load float, float* %7
%27 = call i32 @fang(float %26)
%28 = mul nsw i32 %25, %27
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %19
%31 = load float, float* %7
store float %31, float* %6
br label %42
32: ; preds = %19
%33 = load float, float* %5
%34 = call i32 @fang(float %33)
%35 = load float, float* %7
%36 = call i32 @fang(float %35)
%37 = mul nsw i32 %34, %36
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = load float, float* %7
store float %40, float* %5
br label %41
41: ; preds = %39, %32
br label %42
42: ; preds = %41, %30
br label %12
43: ; preds = %12
%44 = load float, float* %5
%45 = load float, float* %6
%46 = fadd float %44, %45
%47 = fdiv float %46, 2.000000e+00
ret float %47
}

LLVM IR (-O2):
define float @fun1(i32 %0, i32 %1) {
%3 = sitofp i32 %0 to float
%4 = sitofp i32 %1 to float
%5 = fadd float %4, %3
%6 = fmul float %5, 5.000000e-01
%7 = tail call i32 @fang(float %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %30, label %9
9: ; preds = %2, %23
%10 = phi float [ %27, %23 ], [ %6, %2 ]
%11 = phi float [ %25, %23 ], [ %3, %2 ]
%12 = phi float [ %24, %23 ], [ %4, %2 ]
%13 = tail call i32 @fang(float %11)
%14 = tail call i32 @fang(float %10)
%15 = mul nsw i32 %14, %13
%16 = icmp slt i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %9
%18 = tail call i32 @fang(float %11)
%19 = tail call i32 @fang(float %10)
%20 = mul nsw i32 %19, %18
%21 = icmp sgt i32 %20, 0
%22 = select i1 %21, float %10, float %11
br label %23
23: ; preds = %17, %9
%24 = phi float [ %10, %9 ], [ %12, %17 ]
%25 = phi float [ %11, %9 ], [ %22, %17 ]
%26 = fadd float %24, %25
%27 = fmul float %26, 5.000000e-01
%28 = tail call i32 @fang(float %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %9
30: ; preds = %23, %2
%31 = phi float [ %6, %2 ], [ %27, %23 ]
ret float %31
}