#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 array_length(char **);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ memmove(char **, char **, int);
char **array_remove_idx(char **strings, int idx) {
  int len = array_length(strings);
  free(strings[idx]);
  memmove(&strings[idx], &strings[idx + 1], (len - idx) * sizeof(char *));
  return strings;
}


x86 assembly (clang, -O0):
<array_remove_idx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <array_length@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memmove@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_remove_idx>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
call   1040 <array_length@plt>
mov    %eax,%ebp
movslq %r14d,%rbx
lea    (%r15,%rbx,8),%r14
mov    (%r15,%rbx,8),%rdi
call   1030 <free@plt>
lea    (%r15,%rbx,8),%rsi
add    $0x8,%rsi
sub    %ebx,%ebp
shl    $0x3,%ebp
mov    %r14,%rdi
mov    %ebp,%edx
call   1050 <memmove@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @array_remove_idx(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%6 = load i8**, i8*** %3
%7 = call i32 @array_length(i8** %6)
store i32 %7, i32* %5
%8 = load i8**, i8*** %3
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8*, i8** %8, i64 %10
%12 = load i8*, i8** %11
%13 = call i32 @free(i8* %12)
%14 = load i8**, i8*** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8**, i8*** %3
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %18, i64 %21
%23 = load i32, i32* %5
%24 = load i32, i32* %4
%25 = sub nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 8
%28 = trunc i64 %27 to i32
%29 = call i32 @memmove(i8** %17, i8** %22, i32 %28)
%30 = load i8**, i8*** %3
ret i8** %30
}

LLVM IR (-O2):
define i8** @array_remove_idx(i8** returned %0, i32 %1) {
%3 = tail call i32 @array_length(i8** %0)
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds i8*, i8** %0, i64 %4
%6 = load i8*, i8** %5
%7 = tail call i32 @free(i8* %6)
%8 = add nsw i32 %1, 1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8*, i8** %0, i64 %9
%11 = sub nsw i32 %3, %1
%12 = shl i32 %11, 3
%13 = tail call i32 @memmove(i8** %5, i8** %10, i32 %12)
ret i8** %0
}