#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 ptr_list_remove_first(void ***list, int *count, void *ptr) {
  int i;
  int found;
  found = 0;
  for (i = 0; i < *count; i++)
    if ((*list)[i] == ptr || ptr == NULL) {
      (*list)[i] = NULL;
      found++;
      break;
    }
  return found;
}


x86 assembly (clang, -O0):
<ptr_list_remove_first>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    1185 <ptr_list_remove_first+0x85>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmp    -0x18(%rbp),%rax
je     1151 <ptr_list_remove_first+0x51>
cmpq   $0x0,-0x18(%rbp)
jne    1172 <ptr_list_remove_first+0x72>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1185 <ptr_list_remove_first+0x85>
jmp    1177 <ptr_list_remove_first+0x77>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    111e <ptr_list_remove_first+0x1e>
mov    -0x20(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptr_list_remove_first>:
mov    (%rsi),%eax
test   %eax,%eax
jle    1124 <ptr_list_remove_first+0x24>
mov    (%rdi),%rcx
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
test   %rdx,%rdx
je     1127 <ptr_list_remove_first+0x27>
cmp    %rdx,(%rcx,%rsi,8)
je     1127 <ptr_list_remove_first+0x27>
add    $0x1,%rsi
cmp    %rsi,%rax
jne    1110 <ptr_list_remove_first+0x10>
xor    %eax,%eax
ret
movq   $0x0,(%rcx,%rsi,8)
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @ptr_list_remove_first(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
store i32 0, i32* %8
store i32 0, i32* %7
br label %9
9: ; preds = %35, %3
%10 = load i32, i32* %7
%11 = load i32*, i32** %5
%12 = load i32, i32* %11
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %38
14: ; preds = %9
%15 = load i8***, i8**** %4
%16 = load i8**, i8*** %15
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = load i8*, i8** %6
%22 = icmp eq i8* %20, %21
br i1 %22, label %26, label %23
23: ; preds = %14
%24 = load i8*, i8** %6
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %34
26: ; preds = %23, %14
%27 = load i8***, i8**** %4
%28 = load i8**, i8*** %27
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
store i8* null, i8** %31
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %38
34: ; preds = %23
br label %35
35: ; preds = %34
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %9
38: ; preds = %26, %9
%39 = load i32, i32* %8
ret i32 %39
}

LLVM IR (-O2):
define i32 @ptr_list_remove_first(i8*** nocapture %0, i32* nocapture %1, i8* readnone %2) {
%4 = load i32, i32* %1
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %22
6: ; preds = %3
%7 = load i8**, i8*** %0
%8 = icmp eq i8* %2, null
%9 = zext i32 %4 to i64
br label %10
10: ; preds = %6, %19
%11 = phi i64 [ 0, %6 ], [ %20, %19 ]
%12 = getelementptr inbounds i8*, i8** %7, i64 %11
%13 = load i8*, i8** %12
%14 = icmp eq i8* %13, %2
%15 = or i1 %8, %14
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = and i64 %11, 4294967295
%18 = getelementptr inbounds i8*, i8** %7, i64 %17
store i8* null, i8** %18
br label %22
19: ; preds = %10
%20 = add nuw nsw i64 %11, 1
%21 = icmp eq i64 %20, %9
br i1 %21, label %22, label %10
22: ; preds = %19, %3, %16
%23 = phi i32 [ 1, %16 ], [ 0, %3 ], [ 0, %19 ]
ret i32 %23
}