#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__ realloc(float *, int);
float *InsertQueue(float X, float *Q) {
  int tam = 1;
  while (Q[tam - 1] >= 0)
    tam++;
  tam++;
  Q = (float *)realloc(Q, tam * sizeof(float));
  if (Q == NULL)
    return NULL;
  Q[tam - 2] = X;
  Q[tam - 1] = -1.0;
  return Q;
}


x86 assembly (clang, -O0):
<InsertQueue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0xc(%rbp)
mov    %rdi,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1154 <InsertQueue+0x44>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1128 <InsertQueue+0x18>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1030 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118c <InsertQueue+0x7c>
movq   $0x0,-0x8(%rbp)
jmp    11c5 <InsertQueue+0xb5>
movss  -0xc(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movss  0xe48(%rip),%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InsertQueue>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm0,0xc(%rsp)
mov    $0x4,%esi
xor    %ebx,%ebx
xorps  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movss  (%rdi,%rbx,4),%xmm1
add    $0x1,%rbx
add    $0x4,%esi
ucomiss %xmm0,%xmm1
jae    1130 <InsertQueue+0x20>
call   1030 <realloc@plt>
test   %rax,%rax
je     1162 <InsertQueue+0x52>
movss  0xc(%rsp),%xmm0
movss  %xmm0,-0x4(%rax,%rbx,4)
mov    %ebx,%ecx
movl   $0xbf800000,(%rax,%rcx,4)
jmp    1164 <InsertQueue+0x54>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float* @InsertQueue(float %0, float* %1) {
%3 = alloca float*
%4 = alloca float
%5 = alloca float*
%6 = alloca i32
store float %0, float* %4
store float* %1, float** %5
store i32 1, i32* %6
br label %7
7: ; preds = %15, %2
%8 = load float*, float** %5
%9 = load i32, i32* %6
%10 = sub nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds float, float* %8, i64 %11
%13 = load float, float* %12
%14 = fcmp oge float %13, 0.000000e+00
br i1 %14, label %15, label %18
15: ; preds = %7
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
br label %7
18: ; preds = %7
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
%21 = load float*, float** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 4
%25 = trunc i64 %24 to i32
%26 = call i64 @realloc(float* %21, i32 %25)
%27 = inttoptr i64 %26 to float*
store float* %27, float** %5
%28 = load float*, float** %5
%29 = icmp eq float* %28, null
br i1 %29, label %30, label %31
30: ; preds = %18
store float* null, float** %3
br label %44
31: ; preds = %18
%32 = load float, float* %4
%33 = load float*, float** %5
%34 = load i32, i32* %6
%35 = sub nsw i32 %34, 2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds float, float* %33, i64 %36
store float %32, float* %37
%38 = load float*, float** %5
%39 = load i32, i32* %6
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds float, float* %38, i64 %41
store float -1.000000e+00, float* %42
%43 = load float*, float** %5
store float* %43, float** %3
br label %44
44: ; preds = %31, %30
%45 = load float*, float** %3
ret float* %45
}

LLVM IR (-O2):
define float* @InsertQueue(float %0, float* %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ %9, %3 ], [ 1, %2 ]
%5 = add nsw i64 %4, -1
%6 = getelementptr inbounds float, float* %1, i64 %5
%7 = load float, float* %6
%8 = fcmp ult float %7, 0.000000e+00
%9 = add nuw i64 %4, 1
br i1 %8, label %10, label %3
10: ; preds = %3
%11 = trunc i64 %4 to i32
%12 = shl i32 %11, 2
%13 = add i32 %12, 4
%14 = tail call i64 @realloc(float* %1, i32 %13)
%15 = inttoptr i64 %14 to float*
%16 = icmp eq i64 %14, 0
br i1 %16, label %21, label %17
17: ; preds = %10
%18 = getelementptr inbounds float, float* %15, i64 %5
store float %0, float* %18
%19 = and i64 %4, 4294967295
%20 = getelementptr inbounds float, float* %15, i64 %19
store float -1.000000e+00, float* %20
br label %21
21: ; preds = %10, %17
%22 = phi float* [ %15, %17 ], [ null, %10 ]
ret float* %22
}