#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(double *, int);
void pop(double **a, int *n) {
  for (int i = 0; i < (*n) - 1; i++)
    (*a)[i] = (*a)[i + 1];
  (*n)--;
  (*a) = (double *)realloc(*a, (*n) * sizeof(double));
}


x86 assembly (clang, -O0):
<pop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    116e <pop+0x5e>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <pop+0x17>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1030 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pop>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    (%rsi),%eax
lea    -0x1(%rax),%ebp
mov    (%rdi),%rbx
cmp    $0x2,%eax
jl     114c <pop+0x2c>
lea    0x8(%rbx),%rsi
mov    %ebp,%edx
shl    $0x3,%rdx
mov    %rbx,%rdi
call   1040 <memmove@plt>
mov    %ebp,(%r15)
shl    $0x3,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <realloc@plt>
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @pop(double** nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = add i32 %3, -1
%5 = icmp sgt i32 %3, 1
%6 = load double*, double** %0
br i1 %5, label %7, label %13
7: ; preds = %2
%8 = bitcast double* %6 to i8*
%9 = getelementptr double, double* %6, i64 1
%10 = bitcast double* %9 to i8*
%11 = zext i32 %4 to i64
%12 = shl nuw nsw i64 %11, 3
br label %13
13: ; preds = %2, %7
store i32 %4, i32* %1
%14 = shl i32 %4, 3
%15 = tail call i64 @realloc(double* %6, i32 %14)
%16 = inttoptr i64 %15 to double*
store double* %16, double** %0
ret void
}