double industrial_calculation(int consumption_peak, int consumption_off) {
  double amount_due = 0.0;
  if (consumption_peak > 0) {
    consumption_peak -= 1000;
    amount_due = 76.00;
    if (consumption_peak > 0) {
      amount_due += consumption_peak * 0.065;
    }
  }
  if (consumption_off > 0) {
    consumption_off -= 1000;
    amount_due = 40.00;
    if (consumption_off > 0) {
      amount_due += consumption_off * 0.028;
    }
  }
  return amount_due;
}


x86 assembly (clang, -O0):
<industrial_calculation>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    1162 <industrial_calculation+0x62>
mov    -0x4(%rbp),%eax
sub    $0x3e8,%eax
mov    %eax,-0x4(%rbp)
movsd  0xed1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    115d <industrial_calculation+0x5d>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xeb8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1162 <industrial_calculation+0x62>
cmpl   $0x0,-0x8(%rbp)
jle    11b2 <industrial_calculation+0xb2>
mov    -0x8(%rbp),%eax
sub    $0x3e8,%eax
mov    %eax,-0x8(%rbp)
movsd  0xe91(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11ad <industrial_calculation+0xad>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe78(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11b2 <industrial_calculation+0xb2>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<industrial_calculation>:
test   %edi,%edi
jle    112c <industrial_calculation+0x2c>
cmp    $0x3e9,%edi
jb     1135 <industrial_calculation+0x35>
add    $0xfffffc18,%edi
cvtsi2sd %edi,%xmm0
mulsd  0xeea(%rip),%xmm0
addsd  0xeda(%rip),%xmm0
test   %esi,%esi
jg     1141 <industrial_calculation+0x41>
jmp    1134 <industrial_calculation+0x34>
xorpd  %xmm0,%xmm0
test   %esi,%esi
jg     1141 <industrial_calculation+0x41>
ret
movsd  0xec3(%rip),%xmm0
test   %esi,%esi
jle    1134 <industrial_calculation+0x34>
cmp    $0x3e9,%esi
jb     1167 <industrial_calculation+0x67>
add    $0xfffffc18,%esi
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
mulsd  0xeba(%rip),%xmm0
addsd  0xeaa(%rip),%xmm0
ret
movsd  0xea1(%rip),%xmm0
ret

LLVM IR (-O0):
define double @industrial_calculation(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
store i32 %0, i32* %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %5
%6 = load i32, i32* %3
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %2
%9 = load i32, i32* %3
%10 = sub nsw i32 %9, 1000
store i32 %10, i32* %3
store double 7.600000e+01, double* %5
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i32, i32* %3
%15 = sitofp i32 %14 to double
%16 = load double, double* %5
%17 = call double @llvm.fmuladd.f64(double %15, double 6.500000e-02, double %16)
store double %17, double* %5
br label %18
18: ; preds = %13, %8
br label %19
19: ; preds = %18, %2
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %33
22: ; preds = %19
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 1000
store i32 %24, i32* %4
store double 4.000000e+01, double* %5
%25 = load i32, i32* %4
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %22
%28 = load i32, i32* %4
%29 = sitofp i32 %28 to double
%30 = load double, double* %5
%31 = call double @llvm.fmuladd.f64(double %29, double 2.800000e-02, double %30)
store double %31, double* %5
br label %32
32: ; preds = %27, %22
br label %33
33: ; preds = %32, %19
%34 = load double, double* %5
ret double %34
}

LLVM IR (-O2):
define double @industrial_calculation(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = icmp ugt i32 %0, 1000
br i1 %5, label %6, label %10
6: ; preds = %4
%7 = add nsw i32 %0, -1000
%8 = sitofp i32 %7 to double
%9 = tail call double @llvm.fmuladd.f64(double %8, double 6.500000e-02, double 7.600000e+01)
br label %10
10: ; preds = %4, %6, %2
%11 = phi double [ %9, %6 ], [ 7.600000e+01, %4 ], [ 0.000000e+00, %2 ]
%12 = icmp sgt i32 %1, 0
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = icmp ugt i32 %1, 1000
br i1 %14, label %15, label %19
15: ; preds = %13
%16 = add nsw i32 %1, -1000
%17 = sitofp i32 %16 to double
%18 = tail call double @llvm.fmuladd.f64(double %17, double 2.800000e-02, double 4.000000e+01)
br label %19
19: ; preds = %13, %15, %10
%20 = phi double [ %18, %15 ], [ 4.000000e+01, %13 ], [ %11, %10 ]
ret double %20
}