#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*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, double *, double *, double *);
int main(void) {
  double r1, r2, r3;
  double r_eq;
  puts("\n Computing Equivalent Resistance \n");
  printf("\n Enter values of resistances #1, #2, and #3 (ohms). \n"
         " All resistances must be greater than 0: ");
  scanf("%lg%lg%lg", &r1, &r2, &r3);
  printf("        r1 = %g    r2 = %g    r3 = %g\n", r1, r2, r3);
  r_eq = r1 * r2 * r3 / (r1 * r2 + r1 * r3 + r2 * r3);
  printf(" The equivalent resistance is %g\n\n", r_eq);
  puts("\n Normal termination.");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf24(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1050 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
lea    0xf07(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x10(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xed5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
lea    0xedd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf2f(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm2
lea    0xf0f(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movapd %xmm1,%xmm0
mulsd  %xmm2,%xmm0
movsd  (%rsp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm0,%xmm1
mulsd  %xmm3,%xmm0
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
divsd  %xmm2,%xmm0
lea    0xef7(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xf0c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"\0A Computing Equivalent Resistance \0A\00"
@.str.1 = [96 x i8] c"\0A Enter values of resistances,, and (ohms). \0A All resistances must be greater than 0: \00"
@.str.2 = [10 x i8] c"%lg%lg%lg\00"
@.str.3 = [39 x i8] c" r1 = %g r2 = %g r3 = %g\0A\00"
@.str.4 = [35 x i8] c" The equivalent resistance is %g\0A\0A\00"
@.str.5 = [22 x i8] c"\0A Normal termination.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
%6 = call i32 @puts(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double* %2, double* %3, double* %4)
%9 = load double, double* %2
%10 = load double, double* %3
%11 = load double, double* %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), double %9, double %10, double %11)
%13 = load double, double* %2
%14 = load double, double* %3
%15 = fmul double %13, %14
%16 = load double, double* %4
%17 = fmul double %15, %16
%18 = load double, double* %2
%19 = load double, double* %3
%20 = load double, double* %2
%21 = load double, double* %4
%22 = fmul double %20, %21
%23 = call double @llvm.fmuladd.f64(double %18, double %19, double %22)
%24 = load double, double* %3
%25 = load double, double* %4
%26 = call double @llvm.fmuladd.f64(double %24, double %25, double %23)
%27 = fdiv double %17, %26
store double %27, double* %5
%28 = load double, double* %5
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), double %28)
%30 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@.str = [36 x i8] c"\0A Computing Equivalent Resistance \0A\00"
@.str.1 = [96 x i8] c"\0A Enter values of resistances,, and (ohms). \0A All resistances must be greater than 0: \00"
@.str.2 = [10 x i8] c"%lg%lg%lg\00"
@.str.3 = [39 x i8] c" r1 = %g r2 = %g r3 = %g\0A\00"
@.str.4 = [35 x i8] c" The equivalent resistance is %g\0A\0A\00"
@.str.5 = [22 x i8] c"\0A Normal termination.\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([96 x i8], [96 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double* %1, double* %2, double* %3)
%10 = load double, double* %1
%11 = load double, double* %2
%12 = load double, double* %3
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), double %10, double %11, double %12)
%14 = load double, double* %1
%15 = load double, double* %2
%16 = fmul double %14, %15
%17 = load double, double* %3
%18 = fmul double %16, %17
%19 = fmul double %14, %17
%20 = call double @llvm.fmuladd.f64(double %14, double %15, double %19)
%21 = call double @llvm.fmuladd.f64(double %15, double %17, double %20)
%22 = fdiv double %18, %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), double %22)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
ret i32 1
}