#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 */
scalar_t__ hamming_distance(int, int);
double pow(int, scalar_t__);
double transition_probability(int i, int j, double error_prob, int length) {
  return pow(error_prob, hamming_distance(i, j)) *
         pow(1 - error_prob, length - hamming_distance(i, j));
}


x86 assembly (clang, -O0):
<transition_probability>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <hamming_distance@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rsi
call   1040 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe9f(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
movslq -0x14(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <hamming_distance@plt>
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edi
sub    %rax,%rsi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transition_probability>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
movsd  %xmm0,(%rsp)
mov    %esi,%r12d
mov    %edi,%ebx
cvttsd2si %xmm0,%r15d
call   1030 <hamming_distance@plt>
mov    %r15d,%edi
mov    %rax,%rsi
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xea4(%rip),%xmm0
subsd  (%rsp),%xmm0
cvttsd2si %xmm0,%r15d
movslq %r14d,%rbp
mov    %ebx,%edi
mov    %r12d,%esi
call   1030 <hamming_distance@plt>
sub    %rax,%rbp
mov    %r15d,%edi
mov    %rbp,%rsi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @transition_probability(i32 %0, i32 %1, double %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store double %2, double* %7
store i32 %3, i32* %8
%9 = load double, double* %7
%10 = fptosi double %9 to i32
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = call i64 @hamming_distance(i32 %11, i32 %12)
%14 = call double @pow(i32 %10, i64 %13)
%15 = load double, double* %7
%16 = fsub double 1.000000e+00, %15
%17 = fptosi double %16 to i32
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call i64 @hamming_distance(i32 %20, i32 %21)
%23 = sub nsw i64 %19, %22
%24 = call double @pow(i32 %17, i64 %23)
%25 = fmul double %14, %24
ret double %25
}

LLVM IR (-O2):
define double @transition_probability(i32 %0, i32 %1, double %2, i32 %3) {
%5 = fptosi double %2 to i32
%6 = tail call i64 @hamming_distance(i32 %0, i32 %1)
%7 = tail call double @pow(i32 %5, i64 %6)
%8 = fsub double 1.000000e+00, %2
%9 = fptosi double %8 to i32
%10 = sext i32 %3 to i64
%11 = tail call i64 @hamming_distance(i32 %0, i32 %1)
%12 = sub nsw i64 %10, %11
%13 = tail call double @pow(i32 %9, i64 %12)
%14 = fmul double %7, %13
ret double %14
}