#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 */
float expf(float);
float powf(float, float);
float GCI_incomplete_gamma(float a, float x) {
  float returnValue = 0.0f;
  float multiplicand = powf(x, a) * expf(-x);
  int iter;
  float sum = 0.0f;
  float factor = 1.0f;
  float powerOfX = 1.0f;
  float value;
  for (iter = 0; iter < 1000; ++iter) {
    factor *= (a + (float)iter);
    sum += powerOfX / factor;
    value = multiplicand * sum;
    if (value == returnValue) {
      return returnValue;
    }
    returnValue = value;
    powerOfX *= x;
  }
  return returnValue;
}


x86 assembly (clang, -O0):
<GCI_incomplete_gamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1030 <powf@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1040 <expf@plt>
movaps %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe7a(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0xe6d(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3e8,-0x18(%rbp)
jge    1232 <GCI_incomplete_gamma+0x112>
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x18(%rbp),%xmm1
addss  %xmm1,%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x24(%rbp),%xmm0
divss  -0x20(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jne    120b <GCI_incomplete_gamma+0xeb>
jp     120b <GCI_incomplete_gamma+0xeb>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    123c <GCI_incomplete_gamma+0x11c>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119f <GCI_incomplete_gamma+0x7f>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GCI_incomplete_gamma>:
sub    $0x28,%rsp
movaps %xmm1,0x10(%rsp)
movaps %xmm0,%xmm2
movss  %xmm0,0x8(%rsp)
movaps %xmm1,%xmm0
movaps %xmm2,%xmm1
call   1030 <powf@plt>
movss  %xmm0,0xc(%rsp)
movaps 0xeb6(%rip),%xmm0
xorps  0x10(%rsp),%xmm0
call   1040 <expf@plt>
movss  0x8(%rsp),%xmm7
movaps 0x10(%rsp),%xmm8
mulss  0xc(%rsp),%xmm0
xor    %eax,%eax
xorps  %xmm3,%xmm3
movss  0xe9d(%rip),%xmm2
movaps %xmm2,%xmm4
xorps  %xmm5,%xmm5
nopl   0x0(%rax)
movaps %xmm4,%xmm1
xorps  %xmm4,%xmm4
cvtsi2ss %eax,%xmm4
movaps %xmm3,%xmm6
addss  %xmm7,%xmm4
mulss  %xmm1,%xmm4
movaps %xmm2,%xmm3
divss  %xmm4,%xmm3
addss  %xmm6,%xmm3
movaps %xmm0,%xmm6
mulss  %xmm3,%xmm6
ucomiss %xmm5,%xmm6
movaps %xmm5,%xmm1
jne    11b1 <GCI_incomplete_gamma+0x91>
jnp    11f6 <GCI_incomplete_gamma+0xd6>
add    $0x1,%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
mulss  %xmm8,%xmm2
addss  %xmm7,%xmm1
mulss  %xmm1,%xmm4
movaps %xmm2,%xmm1
divss  %xmm4,%xmm1
addss  %xmm1,%xmm3
movaps %xmm0,%xmm5
mulss  %xmm3,%xmm5
ucomiss %xmm6,%xmm5
movaps %xmm6,%xmm1
jne    11e4 <GCI_incomplete_gamma+0xc4>
jnp    11f6 <GCI_incomplete_gamma+0xd6>
mulss  %xmm8,%xmm2
add    $0x1,%eax
movaps %xmm5,%xmm1
cmp    $0x3e8,%eax
jne    1180 <GCI_incomplete_gamma+0x60>
movaps %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define float @GCI_incomplete_gamma(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
store float %0, float* %4
store float %1, float* %5
store float 0.000000e+00, float* %6
%13 = load float, float* %5
%14 = load float, float* %4
%15 = call float @powf(float %13, float %14)
%16 = load float, float* %5
%17 = fneg float %16
%18 = call float @expf(float %17)
%19 = fmul float %15, %18
store float %19, float* %7
store float 0.000000e+00, float* %9
store float 1.000000e+00, float* %10
store float 1.000000e+00, float* %11
store i32 0, i32* %8
br label %20
20: ; preds = %48, %2
%21 = load i32, i32* %8
%22 = icmp slt i32 %21, 1000
br i1 %22, label %23, label %51
23: ; preds = %20
%24 = load float, float* %4
%25 = load i32, i32* %8
%26 = sitofp i32 %25 to float
%27 = fadd float %24, %26
%28 = load float, float* %10
%29 = fmul float %28, %27
store float %29, float* %10
%30 = load float, float* %11
%31 = load float, float* %10
%32 = fdiv float %30, %31
%33 = load float, float* %9
%34 = fadd float %33, %32
store float %34, float* %9
%35 = load float, float* %7
%36 = load float, float* %9
%37 = fmul float %35, %36
store float %37, float* %12
%38 = load float, float* %12
%39 = load float, float* %6
%40 = fcmp oeq float %38, %39
br i1 %40, label %41, label %43
41: ; preds = %23
%42 = load float, float* %6
store float %42, float* %3
br label %53
43: ; preds = %23
%44 = load float, float* %12
store float %44, float* %6
%45 = load float, float* %5
%46 = load float, float* %11
%47 = fmul float %46, %45
store float %47, float* %11
br label %48
48: ; preds = %43
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %20
51: ; preds = %20
%52 = load float, float* %6
store float %52, float* %3
br label %53
53: ; preds = %51, %41
%54 = load float, float* %3
ret float %54
}

LLVM IR (-O2):
define float @GCI_incomplete_gamma(float %0, float %1) {
%3 = tail call float @powf(float %1, float %0)
%4 = fneg float %1
%5 = tail call float @expf(float %4)
%6 = fmul float %3, %5
br label %7
7: ; preds = %30, %2
%8 = phi float [ 1.000000e+00, %2 ], [ %31, %30 ]
%9 = phi float [ 1.000000e+00, %2 ], [ %25, %30 ]
%10 = phi float [ 0.000000e+00, %2 ], [ %27, %30 ]
%11 = phi i32 [ 0, %2 ], [ %32, %30 ]
%12 = phi float [ 0.000000e+00, %2 ], [ %28, %30 ]
%13 = sitofp i32 %11 to float
%14 = fadd float %13, %0
%15 = fmul float %9, %14
%16 = fdiv float %8, %15
%17 = fadd float %10, %16
%18 = fmul float %6, %17
%19 = fcmp oeq float %18, %12
br i1 %19, label %34, label %20
20: ; preds = %7
%21 = fmul float %8, %1
%22 = or i32 %11, 1
%23 = sitofp i32 %22 to float
%24 = fadd float %23, %0
%25 = fmul float %15, %24
%26 = fdiv float %21, %25
%27 = fadd float %17, %26
%28 = fmul float %6, %27
%29 = fcmp oeq float %28, %18
br i1 %29, label %34, label %30
30: ; preds = %20
%31 = fmul float %21, %1
%32 = add nuw nsw i32 %11, 2
%33 = icmp eq i32 %32, 1000
br i1 %33, label %34, label %7
34: ; preds = %30, %20, %7
%35 = phi float [ %12, %7 ], [ %18, %20 ], [ %28, %30 ]
ret float %35
}