#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 */
typedef int /*<<< orphan*/ MENU;
typedef int /*<<< orphan*/ ITEM;

/* Variables and functions */
int /*<<< orphan*/ free_item(int /*<<< orphan*/ *);
int /*<<< orphan*/ free_menu(int /*<<< orphan*/ *);
int /*<<< orphan*/ unpost_menu(int /*<<< orphan*/ *);
void remove_menu(ITEM **items, MENU *men, int n) {
  int i;
  unpost_menu(men);
  free_menu(men);
  for (i = 0; i < n; ++i)
    free_item(items[i]);
}


x86 assembly (clang, -O0):
<remove_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <unpost_menu@plt>
mov    -0x10(%rbp),%rdi
call   1050 <free_menu@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1187 <remove_menu+0x57>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <free_item@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115c <remove_menu+0x2c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_menu>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <unpost_menu@plt>
mov    %rbp,%rdi
call   1050 <free_menu@plt>
test   %r14d,%r14d
jle    1172 <remove_menu+0x42>
mov    %r14d,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
call   1040 <free_item@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <remove_menu+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @remove_menu(i32** %0, i32* %1, i32 %2) {
%4 = alloca i32**
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32** %0, i32*** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%8 = load i32*, i32** %5
%9 = call i32 @unpost_menu(i32* %8)
%10 = load i32*, i32** %5
%11 = call i32 @free_menu(i32* %10)
store i32 0, i32* %7
br label %12
12: ; preds = %23, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i32**, i32*** %4
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32*, i32** %17, i64 %19
%21 = load i32*, i32** %20
%22 = call i32 @free_item(i32* %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %12
26: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @remove_menu(i32** nocapture %0, i32* %1, i32 %2) {
%4 = tail call i32 @unpost_menu(i32* %1)
%5 = tail call i32 @free_menu(i32* %1)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %16
7: ; preds = %3
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %14, %9 ]
%11 = getelementptr inbounds i32*, i32** %0, i64 %10
%12 = load i32*, i32** %11
%13 = tail call i32 @free_item(i32* %12)
%14 = add nuw nsw i64 %10, 1
%15 = icmp eq i64 %14, %8
br i1 %15, label %16, label %9
16: ; preds = %9, %3
ret void
}