#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 lobject {
  int dummy;
};
struct lemon {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ larray_del_item(struct lemon *, struct lobject *, int);
struct lobject *larray_get_item(struct lemon *, struct lobject *, int);
int larray_length(struct lemon *, struct lobject *);
scalar_t__ lobject_is_equal(struct lemon *, struct lobject *, struct lobject *);
void lclass_del_slot(struct lemon *lemon, struct lobject *base, int nslots,
                     struct lobject **slots) {
  int i;
  int j;
  struct lobject *item;
  for (i = 0; i < nslots; i++) {
    for (j = 0; j < larray_length(lemon, slots[i]); j++) {
      item = larray_get_item(lemon, slots[i], j);
      if (lobject_is_equal(lemon, base, item)) {
        larray_del_item(lemon, slots[i], j);
        j -= 1;
      }
    }
  }
}


x86 assembly (clang, -O0):
<lclass_del_slot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1217 <lclass_del_slot+0xd7>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <larray_length@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    1204 <lclass_del_slot+0xc4>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x28(%rbp),%edx
call   1030 <larray_get_item@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1040 <lobject_is_equal@plt>
cmp    $0x0,%rax
je     11f1 <lclass_del_slot+0xb1>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x28(%rbp),%edx
call   1050 <larray_del_item@plt>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11f6 <lclass_del_slot+0xb6>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1171 <lclass_del_slot+0x31>
jmp    1209 <lclass_del_slot+0xc9>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115e <lclass_del_slot+0x1e>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lclass_del_slot>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    11c7 <lclass_del_slot+0x87>
mov    %rcx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%r12d
xor    %r13d,%r13d
jmp    1169 <lclass_del_slot+0x29>
add    $0x1,%r13
cmp    %r12,%r13
je     11c7 <lclass_del_slot+0x87>
mov    (%r15,%r13,8),%rsi
mov    %rbx,%rdi
call   1060 <larray_length@plt>
test   %eax,%eax
jle    1160 <lclass_del_slot+0x20>
xor    %ebp,%ebp
jmp    1193 <lclass_del_slot+0x53>
nopl   (%rax)
add    $0x1,%ebp
mov    (%r15,%r13,8),%rsi
mov    %rbx,%rdi
call   1060 <larray_length@plt>
cmp    %eax,%ebp
jge    1160 <lclass_del_slot+0x20>
mov    (%r15,%r13,8),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1030 <larray_get_item@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1040 <lobject_is_equal@plt>
test   %rax,%rax
je     1180 <lclass_del_slot+0x40>
mov    (%r15,%r13,8),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1050 <larray_del_item@plt>
add    $0xffffffff,%ebp
jmp    1180 <lclass_del_slot+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.lemon = type { i32 }
%struct.lobject = type { i32 }
define void @lclass_del_slot(%struct.lemon* %0, %struct.lobject* %1, i32 %2, %struct.lobject** %3) {
%5 = alloca %struct.lemon*
%6 = alloca %struct.lobject*
%7 = alloca i32
%8 = alloca %struct.lobject**
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.lobject*
store %struct.lemon* %0, %struct.lemon** %5
store %struct.lobject* %1, %struct.lobject** %6
store i32 %2, i32* %7
store %struct.lobject** %3, %struct.lobject*** %8
store i32 0, i32* %9
br label %12
12: ; preds = %57, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %60
16: ; preds = %12
store i32 0, i32* %10
br label %17
17: ; preds = %53, %16
%18 = load i32, i32* %10
%19 = load %struct.lemon*, %struct.lemon** %5
%20 = load %struct.lobject**, %struct.lobject*** %8
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds %struct.lobject*, %struct.lobject** %20, i64 %22
%24 = load %struct.lobject*, %struct.lobject** %23
%25 = call i32 @larray_length(%struct.lemon* %19, %struct.lobject* %24)
%26 = icmp slt i32 %18, %25
br i1 %26, label %27, label %56
27: ; preds = %17
%28 = load %struct.lemon*, %struct.lemon** %5
%29 = load %struct.lobject**, %struct.lobject*** %8
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds %struct.lobject*, %struct.lobject** %29, i64 %31
%33 = load %struct.lobject*, %struct.lobject** %32
%34 = load i32, i32* %10
%35 = call %struct.lobject* @larray_get_item(%struct.lemon* %28, %struct.lobject* %33, i32 %34)
store %struct.lobject* %35, %struct.lobject** %11
%36 = load %struct.lemon*, %struct.lemon** %5
%37 = load %struct.lobject*, %struct.lobject** %6
%38 = load %struct.lobject*, %struct.lobject** %11
%39 = call i64 @lobject_is_equal(%struct.lemon* %36, %struct.lobject* %37, %struct.lobject* %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %52
41: ; preds = %27
%42 = load %struct.lemon*, %struct.lemon** %5
%43 = load %struct.lobject**, %struct.lobject*** %8
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds %struct.lobject*, %struct.lobject** %43, i64 %45
%47 = load %struct.lobject*, %struct.lobject** %46
%48 = load i32, i32* %10
%49 = call i32 @larray_del_item(%struct.lemon* %42, %struct.lobject* %47, i32 %48)
%50 = load i32, i32* %10
%51 = sub nsw i32 %50, 1
store i32 %51, i32* %10
br label %52
52: ; preds = %41, %27
br label %53
53: ; preds = %52
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %17
56: ; preds = %17
br label %57
57: ; preds = %56
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
store i32 %59, i32* %9
br label %12
60: ; preds = %12
ret void
}

LLVM IR (-O2):
%struct.lemon = type { i32 }
%struct.lobject = type { i32 }
define void @lclass_del_slot(%struct.lemon* %0, %struct.lobject* %1, i32 %2, %struct.lobject** nocapture %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %33
6: ; preds = %4
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %30
%9 = phi i64 [ 0, %6 ], [ %31, %30 ]
%10 = getelementptr inbounds %struct.lobject*, %struct.lobject** %3, i64 %9
%11 = load %struct.lobject*, %struct.lobject** %10
%12 = tail call i32 @larray_length(%struct.lemon* %0, %struct.lobject* %11)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %8, %24
%15 = phi i32 [ %26, %24 ], [ 0, %8 ]
%16 = load %struct.lobject*, %struct.lobject** %10
%17 = tail call %struct.lobject* @larray_get_item(%struct.lemon* %0, %struct.lobject* %16, i32 %15)
%18 = tail call i64 @lobject_is_equal(%struct.lemon* %0, %struct.lobject* %1, %struct.lobject* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %14
%21 = load %struct.lobject*, %struct.lobject** %10
%22 = tail call i32 @larray_del_item(%struct.lemon* %0, %struct.lobject* %21, i32 %15)
%23 = add nsw i32 %15, -1
br label %24
24: ; preds = %14, %20
%25 = phi i32 [ %23, %20 ], [ %15, %14 ]
%26 = add nsw i32 %25, 1
%27 = load %struct.lobject*, %struct.lobject** %10
%28 = tail call i32 @larray_length(%struct.lemon* %0, %struct.lobject* %27)
%29 = icmp slt i32 %26, %28
br i1 %29, label %14, label %30
30: ; preds = %24, %8
%31 = add nuw nsw i64 %9, 1
%32 = icmp eq i64 %31, %7
br i1 %32, label %33, label %8
33: ; preds = %30, %4
ret void
}