#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*/ free(char *);
int /*<<< orphan*/ memmove(char *, char *, size_t);
int strlen(char *);
void argz_delete(char **argz, size_t *argz_len, char *entry) {
  if (entry) {
    size_t entry_len = strlen(entry) + 1;
    *argz_len -= entry_len;
    memmove(entry, entry + entry_len, *argz_len - (entry - *argz));
    if (*argz_len == 0) {
      free(*argz);
      *argz = 0;
    }
  }
}


x86 assembly (clang, -O0):
<argz_delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c5 <argz_delete+0x95>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
sub    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
sub    %rax,%rdx
call   1050 <memmove@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11c0 <argz_delete+0x90>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
jmp    11c5 <argz_delete+0x95>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<argz_delete>:
push   %r15
push   %r14
push   %rbx
test   %rdx,%rdx
je     1185 <argz_delete+0x55>
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rdx,%rdi
call   1040 <strlen@plt>
cltq
lea    0x1(%rax),%rcx
mov    (%r15),%rdx
sub    %rcx,%rdx
mov    %rdx,(%r15)
lea    (%rbx,%rax,1),%rsi
add    $0x1,%rsi
sub    %rbx,%rdx
add    (%r14),%rdx
mov    %rbx,%rdi
call   1050 <memmove@plt>
cmpq   $0x0,(%r15)
jne    1185 <argz_delete+0x55>
mov    (%r14),%rdi
call   1030 <free@plt>
movq   $0x0,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @argz_delete(i8** nocapture %0, i64* nocapture %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %23, label %5
5: ; preds = %3
%6 = tail call i32 @strlen(i8* %2)
%7 = add nsw i32 %6, 1
%8 = sext i32 %7 to i64
%9 = load i64, i64* %1
%10 = sub i64 %9, %8
store i64 %10, i64* %1
%11 = getelementptr inbounds i8, i8* %2, i64 %8
%12 = load i8*, i8** %0
%13 = ptrtoint i8* %2 to i64
%14 = ptrtoint i8* %12 to i64
%15 = sub i64 %10, %13
%16 = add i64 %15, %14
%17 = tail call i32 @memmove(i8* %2, i8* %11, i64 %16)
%18 = load i64, i64* %1
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %5
%21 = load i8*, i8** %0
%22 = tail call i32 @free(i8* %21)
store i8* null, i8** %0
br label %23
23: ; preds = %5, %20, %3
ret void
}