#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*/ DisplayMenuItem(int, int, char const *, int);
int TextHeight();
void DisplayMenu(int x, const char **table, int count, int index) {
  int i;
  for (i = 0; i < count; i++)
    DisplayMenuItem(x, 50 + i * TextHeight(), table[i], i == index);
}


x86 assembly (clang, -O0):
<DisplayMenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1194 <DisplayMenu+0x74>
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1030 <TextHeight@plt>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edi
imul   %eax,%esi
add    $0x32,%esi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
call   1040 <DisplayMenuItem@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113c <DisplayMenu+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DisplayMenu>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
jle    116c <DisplayMenu+0x4c>
mov    %rsi,%r14
mov    %edi,%r15d
mov    %ecx,%r12d
mov    %edx,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <TextHeight@plt>
mov    %ebx,%esi
imul   %eax,%esi
add    $0x32,%esi
mov    (%r14,%rbx,8),%rdx
xor    %ecx,%ecx
cmp    %rbx,%r12
sete   %cl
mov    %r15d,%edi
call   1040 <DisplayMenuItem@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <DisplayMenu+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @DisplayMenu(i32 %0, i8** %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %30, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %7
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %33
14: ; preds = %10
%15 = load i32, i32* %5
%16 = load i32, i32* %9
%17 = call i32 (...) @TextHeight()
%18 = mul nsw i32 %16, %17
%19 = add nsw i32 50, %18
%20 = load i8**, i8*** %6
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = load i32, i32* %9
%26 = load i32, i32* %8
%27 = icmp eq i32 %25, %26
%28 = zext i1 %27 to i32
%29 = call i32 @DisplayMenuItem(i32 %15, i32 %19, i8* %24, i32 %28)
br label %30
30: ; preds = %14
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 1
store i32 %32, i32* %9
br label %10
33: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @DisplayMenu(i32 %0, i8** nocapture %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %22
6: ; preds = %4
%7 = zext i32 %3 to i64
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %20, %9 ]
%11 = tail call i32 (...) @TextHeight()
%12 = trunc i64 %10 to i32
%13 = mul nsw i32 %11, %12
%14 = add nsw i32 %13, 50
%15 = getelementptr inbounds i8*, i8** %1, i64 %10
%16 = load i8*, i8** %15
%17 = icmp eq i64 %10, %7
%18 = zext i1 %17 to i32
%19 = tail call i32 @DisplayMenuItem(i32 %0, i32 %14, i8* %16, i32 %18)
%20 = add nuw nsw i64 %10, 1
%21 = icmp eq i64 %20, %8
br i1 %21, label %22, label %9
22: ; preds = %9, %4
ret void
}