#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 combinaciones(int, int);
double potencia(double, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
main() {
  double a = 1, b = 1, m = 1, x = 1, y = 1, result = 0;
  int n = 1, k = 0;
  printf("Binomio (ax + by)^n:\n");
  printf("a = ");
  scanf("%lf", &a);
  printf("b = ");
  scanf("%lf", &b);
  printf("n = ");
  scanf("%lf", &m);
  n = (int)m;
  printf("x = ");
  scanf("%lf", &x);
  printf("y = ");
  scanf("%lf", &y);
  printf("Calcular (%g*%g + %g*%g)^%d:\n", a, x, b, y, n);
  for (k = 0, result = 0; k <= n; k++)
    result += combinaciones(n, k) * potencia(a * x, n - k) * potencia(b * y, k);
  printf("Resultado: %g.\n", result);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xea9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe9c(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe8f(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe82(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe75(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3c(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1e(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
cvttsd2si -0x20(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf8(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdda(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
mov    -0x3c(%rbp),%esi
lea    0xdcb(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
movl   $0x0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jg     1302 <main+0x1c2>
mov    -0x3c(%rbp),%edi
mov    -0x40(%rbp),%esi
call   1050 <combinaciones@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x3c(%rbp),%edi
sub    -0x40(%rbp),%edi
call   1060 <potencia@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    -0x40(%rbp),%edi
call   1060 <potencia@plt>
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1286 <main+0x146>
movsd  -0x38(%rbp),%xmm0
lea    0xd4b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
movabs $0x3ff0000000000000,%rax
mov    %rax,0x28(%rsp)
mov    %rax,0x20(%rsp)
mov    %rax,0x30(%rsp)
mov    %rax,0x18(%rsp)
mov    %rax,0x10(%rsp)
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe70(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe65(%rip),%r14
lea    0x28(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
lea    0xe3f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x30(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
cvttsd2si 0x30(%rsp),%r15d
lea    0xe22(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
lea    0xe0c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
movsd  0x28(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
lea    0xdde(%rip),%rdi
mov    %r15d,%esi
mov    $0x4,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
test   %r15d,%r15d
js     12c8 <main+0x178>
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm0,0x8(%rsp)
mov    %r15d,%edi
mov    %ebx,%esi
call   1060 <combinaciones@plt>
movsd  %xmm0,(%rsp)
movsd  0x28(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
mov    %ebp,%edi
call   1070 <potencia@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x20(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
mov    %ebx,%edi
call   1070 <potencia@plt>
mulsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%ebx
add    $0xffffffff,%ebp
jb     1260 <main+0x110>
lea    0xd6c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Binomio (ax + by)^n:\0A\00"
@.str.1 = [5 x i8] c"a = \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [5 x i8] c"b = \00"
@.str.4 = [5 x i8] c"n = \00"
@.str.5 = [5 x i8] c"x = \00"
@.str.6 = [5 x i8] c"y = \00"
@.str.7 = [30 x i8] c"Calcular (%g*%g + %g*%g)^%d:\0A\00"
@.str.8 = [16 x i8] c"Resultado: %g.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store double 1.000000e+00, double* %3
store double 1.000000e+00, double* %4
store double 1.000000e+00, double* %5
store double 1.000000e+00, double* %6
store double 0.000000e+00, double* %7
store i32 1, i32* %8
store i32 0, i32* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %4)
%17 = load double, double* %4
%18 = fptosi double %17 to i32
store i32 %18, i32* %8
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %5)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %6)
%23 = load double, double* %2
%24 = load double, double* %5
%25 = load double, double* %3
%26 = load double, double* %6
%27 = load i32, i32* %8
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), double %23, double %24, double %25, double %26, i32 %27)
store i32 0, i32* %9
store double 0.000000e+00, double* %7
br label %29
29: ; preds = %52, %0
%30 = load i32, i32* %9
%31 = load i32, i32* %8
%32 = icmp sle i32 %30, %31
br i1 %32, label %33, label %55
33: ; preds = %29
%34 = load i32, i32* %8
%35 = load i32, i32* %9
%36 = call double @combinaciones(i32 %34, i32 %35)
%37 = load double, double* %2
%38 = load double, double* %5
%39 = fmul double %37, %38
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = sub nsw i32 %40, %41
%43 = call double @potencia(double %39, i32 %42)
%44 = fmul double %36, %43
%45 = load double, double* %3
%46 = load double, double* %6
%47 = fmul double %45, %46
%48 = load i32, i32* %9
%49 = call double @potencia(double %47, i32 %48)
%50 = load double, double* %7
%51 = call double @llvm.fmuladd.f64(double %44, double %49, double %50)
store double %51, double* %7
br label %52
52: ; preds = %33
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %29
55: ; preds = %29
%56 = load double, double* %7
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), double %56)
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"a = \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [5 x i8] c"b = \00"
@.str.4 = [5 x i8] c"n = \00"
@.str.5 = [5 x i8] c"x = \00"
@.str.6 = [5 x i8] c"y = \00"
@.str.7 = [30 x i8] c"Calcular (%g*%g + %g*%g)^%d:\0A\00"
@.str.8 = [16 x i8] c"Resultado: %g.\0A\00"
@str = [21 x i8] c"Binomio (ax + by)^n:\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %1 to i8*
store double 1.000000e+00, double* %1
%7 = bitcast double* %2 to i8*
store double 1.000000e+00, double* %2
%8 = bitcast double* %3 to i8*
store double 1.000000e+00, double* %3
%9 = bitcast double* %4 to i8*
store double 1.000000e+00, double* %4
%10 = bitcast double* %5 to i8*
store double 1.000000e+00, double* %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%18 = load double, double* %3
%19 = fptosi double %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %4)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %5)
%24 = load double, double* %1
%25 = load double, double* %4
%26 = load double, double* %2
%27 = load double, double* %5
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), double %24, double %25, double %26, double %27, i32 %19)
%29 = icmp slt i32 %19, 0
br i1 %29, label %47, label %30
30: ; preds = %0, %30
%31 = phi i32 [ %45, %30 ], [ 0, %0 ]
%32 = phi double [ %44, %30 ], [ 0.000000e+00, %0 ]
%33 = call double @combinaciones(i32 %19, i32 %31)
%34 = load double, double* %1
%35 = load double, double* %4
%36 = fmul double %34, %35
%37 = sub nsw i32 %19, %31
%38 = call double @potencia(double %36, i32 %37)
%39 = fmul double %33, %38
%40 = load double, double* %2
%41 = load double, double* %5
%42 = fmul double %40, %41
%43 = call double @potencia(double %42, i32 %31)
%44 = call double @llvm.fmuladd.f64(double %39, double %43, double %32)
%45 = add nuw i32 %31, 1
%46 = icmp eq i32 %31, %19
br i1 %46, label %47, label %30
47: ; preds = %30, %0
%48 = phi double [ 0.000000e+00, %0 ], [ %44, %30 ]
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), double %48)
ret i32 0
}