#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*/ _assert(int, char *, int, char *);
float powi(float a, int n) {
  float pow;
  _assert(
      (n >= 0),
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/mthiffau/HeatheRTOS/refs/heads/master/xmath.c",
      31, "n >= 0");
  if (n == 0)
    return 1.f;
  else if (n == 1)
    return a;
  pow = powi(a, n / 2);
  pow *= pow;
  if (n % 2 == 1)
    pow *= a;
  return pow;
}


x86 assembly (clang, -O0):
<powi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
lea    0xec1(%rip),%rsi
mov    $0x1f,%edx
lea    0xf3d(%rip),%rcx
call   1040 <_assert@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1170 <powi+0x50>
movss  0xe9a(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11e6 <powi+0xc6>
cmpl   $0x1,-0xc(%rbp)
jne    1189 <powi+0x69>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11e6 <powi+0xc6>
jmp    118e <powi+0x6e>
movss  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <powi@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11dc <powi+0xbc>
movss  -0x8(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<powi>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
movss  %xmm0,0x4(%rsp)
not    %edi
shr    $0x1f,%edi
lea    0xecd(%rip),%rsi
lea    0xf4e(%rip),%rcx
mov    $0x1f,%edx
call   1040 <_assert@plt>
test   %ebx,%ebx
je     1159 <powi+0x39>
cmp    $0x1,%ebx
jne    1163 <powi+0x43>
movss  0x4(%rsp),%xmm1
jmp    1199 <powi+0x79>
movss  0xe9f(%rip),%xmm1
jmp    1199 <powi+0x79>
mov    %ebx,%ebp
shr    $0x1f,%ebp
add    %ebx,%ebp
mov    %ebp,%edi
sar    %edi
movss  0x4(%rsp),%xmm0
call   1030 <powi@plt>
movss  0x4(%rsp),%xmm1
mulss  %xmm0,%xmm0
and    $0xfffffffe,%ebp
sub    %ebp,%ebx
cmp    $0x1,%ebx
je     1195 <powi+0x75>
movss  0xe6b(%rip),%xmm1
mulss  %xmm0,%xmm1
movaps %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mthiffau/HeatheRTOS/refs/heads/master/xmath.c\00"
@.str.1 = [7 x i8] c"n >= 0\00"
define float @powi(float %0, i32 %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca float
store float %0, float* %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = icmp sge i32 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @_assert(i32 %9, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str, i64 0, i64 0), i32 31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %2
store float 1.000000e+00, float* %3
br label %37
14: ; preds = %2
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = load float, float* %4
store float %18, float* %3
br label %37
19: ; preds = %14
br label %20
20: ; preds = %19
%21 = load float, float* %4
%22 = load i32, i32* %5
%23 = sdiv i32 %22, 2
%24 = call float @powi(float %21, i32 %23)
store float %24, float* %6
%25 = load float, float* %6
%26 = load float, float* %6
%27 = fmul float %26, %25
store float %27, float* %6
%28 = load i32, i32* %5
%29 = srem i32 %28, 2
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %35
31: ; preds = %20
%32 = load float, float* %4
%33 = load float, float* %6
%34 = fmul float %33, %32
store float %34, float* %6
br label %35
35: ; preds = %31, %20
%36 = load float, float* %6
store float %36, float* %3
br label %37
37: ; preds = %35, %17, %13
%38 = load float, float* %3
ret float %38
}

LLVM IR (-O2):
@.str = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mthiffau/HeatheRTOS/refs/heads/master/xmath.c\00"
@.str.1 = [7 x i8] c"n >= 0\00"
define float @powi(float %0, i32 %1) {
%3 = xor i32 %1, -1
%4 = lshr i32 %3, 31
%5 = tail call i32 @_assert(i32 %4, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str, i64 0, i64 0), i32 31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
switch i32 %1, label %9 [
i32 0, label %7
i32 1, label %6
]
6: ; preds = %2
br label %7
7: ; preds = %6, %2, %9
%8 = phi float [ %16, %9 ], [ %0, %6 ], [ 1.000000e+00, %2 ]
ret float %8
9: ; preds = %2
%10 = sdiv i32 %1, 2
%11 = tail call float @powi(float %0, i32 %10)
%12 = fmul float %11, %11
%13 = srem i32 %1, 2
%14 = icmp eq i32 %13, 1
%15 = select i1 %14, float %0, float 1.000000e+00
%16 = fmul float %15, %12
br label %7
}