#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 */
double f(double);
double g(int a) {
  int b, c, d, e = 0;
  double h;
  for (d = 0; d < a; d++)
    for (c = 0; c < a; c++)
      b = 1;
  h = (double)e / (double)a;
  if (h) {
    h = 1.0 / h;
    h = f(h);
  } else
    h = 1.0;
  return h;
}


x86 assembly (clang, -O0):
<g>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1170 <g+0x60>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    115d <g+0x4d>
movl   $0x1,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113c <g+0x2c>
jmp    1162 <g+0x52>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1129 <g+0x19>
cvtsi2sdl -0x14(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a0 <g+0x90>
jp     11a0 <g+0x90>
jmp    11c6 <g+0xb6>
movsd  0xe58(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    11d3 <g+0xc3>
movsd  0xe32(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g>:
cvtsi2sd %edi,%xmm0
xorpd  %xmm2,%xmm2
xorpd  %xmm1,%xmm1
divsd  %xmm0,%xmm1
movsd  0xed8(%rip),%xmm0
ucomisd %xmm2,%xmm1
jne    1130 <g+0x20>
jnp    1139 <g+0x29>
divsd  %xmm1,%xmm0
jmp    1030 <f@plt>
ret

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

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