#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 inarray(char const **, int, char const *);
void delete (char **array, int *len, const char *string) {
  int pos = inarray((const char **)array, *len, string);
  int last = *len - 1;
  if (pos != last) {
    array[pos] = array[last];
  }
  (*len)--;
}


x86 assembly (clang, -O0):
<delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
call   1030 <inarray@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     116a <delete+0x5a>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%esi
call   1030 <inarray@plt>
movslq (%rbx),%rdx
lea    -0x1(%rdx),%ecx
cmp    %ecx,%eax
je     1136 <delete+0x26>
mov    -0x8(%r14,%rdx,8),%rdx
cltq
mov    %rdx,(%r14,%rax,8)
mov    %ecx,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @delete(i8** %0, i32* %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8** %0, i8*** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%9 = load i8**, i8*** %4
%10 = load i32*, i32** %5
%11 = load i32, i32* %10
%12 = load i8*, i8** %6
%13 = call i32 @inarray(i8** %9, i32 %11, i8* %12)
store i32 %13, i32* %7
%14 = load i32*, i32** %5
%15 = load i32, i32* %14
%16 = sub nsw i32 %15, 1
store i32 %16, i32* %8
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %3
%21 = load i8**, i8*** %4
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %4
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
store i8* %25, i8** %29
br label %30
30: ; preds = %20, %3
%31 = load i32*, i32** %5
%32 = load i32, i32* %31
%33 = add nsw i32 %32, -1
store i32 %33, i32* %31
ret void
}

LLVM IR (-O2):
define void @delete(i8** %0, i32* nocapture %1, i8* %2) {
%4 = load i32, i32* %1
%5 = tail call i32 @inarray(i8** %0, i32 %4, i8* %2)
%6 = load i32, i32* %1
%7 = add nsw i32 %6, -1
%8 = icmp eq i32 %5, %7
br i1 %8, label %15, label %9
9: ; preds = %3
%10 = sext i32 %7 to i64
%11 = getelementptr inbounds i8*, i8** %0, i64 %10
%12 = load i8*, i8** %11
%13 = sext i32 %5 to i64
%14 = getelementptr inbounds i8*, i8** %0, i64 %13
store i8* %12, i8** %14
br label %15
15: ; preds = %9, %3
store i32 %7, i32* %1
ret void
}