#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 */
struct CLObjectList {
  int dummy;
};
struct CLObject {
  int dummy;
};

/* Variables and functions */
struct CLObject *CLObjectList_objectAtIndex(struct CLObjectList *,
                                            unsigned long);
int /*<<< orphan*/ CLObjectList_removeObject(struct CLObjectList *,
                                             struct CLObject *);
struct CLObject *CLObjectList_removeObjectAtIndex(struct CLObjectList *self,
                                                  unsigned long theIndex) {
  struct CLObject *object = CLObjectList_objectAtIndex(self, theIndex);
  if (object != NULL)
    CLObjectList_removeObject(self, object);
  return object;
}


x86 assembly (clang, -O0):
<CLObjectList_removeObjectAtIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <CLObjectList_objectAtIndex@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1159 <CLObjectList_removeObjectAtIndex+0x39>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <CLObjectList_removeObject@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CLObjectList_removeObjectAtIndex>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <CLObjectList_objectAtIndex@plt>
mov    %rax,%rbx
test   %rax,%rax
je     113f <CLObjectList_removeObjectAtIndex+0x1f>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <CLObjectList_removeObject@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.CLObject = type { i32 }
%struct.CLObjectList = type { i32 }
define %struct.CLObject* @CLObjectList_removeObjectAtIndex(%struct.CLObjectList* %0, i64 %1) {
%3 = alloca %struct.CLObjectList*
%4 = alloca i64
%5 = alloca %struct.CLObject*
store %struct.CLObjectList* %0, %struct.CLObjectList** %3
store i64 %1, i64* %4
%6 = load %struct.CLObjectList*, %struct.CLObjectList** %3
%7 = load i64, i64* %4
%8 = call %struct.CLObject* @CLObjectList_objectAtIndex(%struct.CLObjectList* %6, i64 %7)
store %struct.CLObject* %8, %struct.CLObject** %5
%9 = load %struct.CLObject*, %struct.CLObject** %5
%10 = icmp ne %struct.CLObject* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load %struct.CLObjectList*, %struct.CLObjectList** %3
%13 = load %struct.CLObject*, %struct.CLObject** %5
%14 = call i32 @CLObjectList_removeObject(%struct.CLObjectList* %12, %struct.CLObject* %13)
br label %15
15: ; preds = %11, %2
%16 = load %struct.CLObject*, %struct.CLObject** %5
ret %struct.CLObject* %16
}

LLVM IR (-O2):
%struct.CLObject = type { i32 }
%struct.CLObjectList = type { i32 }
define %struct.CLObject* @CLObjectList_removeObjectAtIndex(%struct.CLObjectList* %0, i64 %1) {
%3 = tail call %struct.CLObject* @CLObjectList_objectAtIndex(%struct.CLObjectList* %0, i64 %1)
%4 = icmp eq %struct.CLObject* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @CLObjectList_removeObject(%struct.CLObjectList* %0, %struct.CLObject* %3)
br label %7
7: ; preds = %5, %2
ret %struct.CLObject* %3
}