#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*/ NotifyBox(int, char *, int);
int /*<<< orphan*/ SetGUIRequestMode(int);
int /*<<< orphan*/ bmp_printf(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              char *, int);
int /*<<< orphan*/ clrscr();
int get_ms_clock_value();
int /*<<< orphan*/ menu_redraw_do();
int /*<<< orphan*/ msleep(int);
void menu_benchmark() {
  SetGUIRequestMode(1);
  msleep(1000);
  int t0 = get_ms_clock_value();
  for (int i = 0; i < 500; i++) {
    menu_redraw_do();
    bmp_printf((0 | (((2) << 16) & (0xFFFF0000)) | ((0) & 0xFF) << 8 |
                ((0) & 0xFF) << 0),
               0, 0, "%d%% ", i / 5);
  }
  int t1 = get_ms_clock_value();
  clrscr();
  NotifyBox(20000, "Elapsed time: %d ms", t1 - t0);
}


x86 assembly (clang, -O0):
<menu_benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1080 <SetGUIRequestMode@plt>
mov    $0x3e8,%edi
call   1050 <msleep@plt>
mov    $0x0,%al
call   1060 <get_ms_clock_value@plt>
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x1f4,-0x8(%rbp)
jge    11e2 <menu_benchmark+0x72>
mov    $0x0,%al
call   1070 <menu_redraw_do@plt>
mov    -0x8(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,%r8d
mov    $0x20000,%edi
xor    %edx,%edx
lea    0xe33(%rip),%rcx
mov    %edx,%esi
call   1030 <bmp_printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119d <menu_benchmark+0x2d>
mov    $0x0,%al
call   1060 <get_ms_clock_value@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <clrscr@plt>
mov    -0xc(%rbp),%edx
sub    -0x4(%rbp),%edx
mov    $0x4e20,%edi
lea    0xe01(%rip),%rsi
call   1090 <NotifyBox@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu_benchmark>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%edi
call   1080 <SetGUIRequestMode@plt>
mov    $0x3e8,%edi
call   1050 <msleep@plt>
xor    %eax,%eax
call   1060 <get_ms_clock_value@plt>
mov    %eax,%r14d
lea    0xe67(%rip),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <menu_redraw_do@plt>
movzwl %bp,%eax
imul   $0xcccd,%eax,%r8d
shr    $0x12,%r8d
mov    $0x20000,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    %rbx,%rcx
call   1030 <bmp_printf@plt>
add    $0x1,%ebp
cmp    $0x1f4,%ebp
jne    11a0 <menu_benchmark+0x30>
xor    %eax,%eax
call   1060 <get_ms_clock_value@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <clrscr@plt>
sub    %r14d,%ebx
lea    0xe1b(%rip),%rsi
mov    $0x4e20,%edi
mov    %ebx,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1090 <NotifyBox@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%d%% \00"
@.str.1 = [20 x i8] c"Elapsed time: %d ms\00"
define void @menu_benchmark() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @SetGUIRequestMode(i32 1)
%5 = call i32 @msleep(i32 1000)
%6 = call i32 (...) @get_ms_clock_value()
store i32 %6, i32* %1
store i32 0, i32* %2
br label %7
7: ; preds = %15, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 500
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = call i32 (...) @menu_redraw_do()
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 5
%14 = call i32 @bmp_printf(i32 131072, i32 0, i32 0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %10
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %7
18: ; preds = %7
%19 = call i32 (...) @get_ms_clock_value()
store i32 %19, i32* %3
%20 = call i32 (...) @clrscr()
%21 = load i32, i32* %3
%22 = load i32, i32* %1
%23 = sub nsw i32 %21, %22
%24 = call i32 @NotifyBox(i32 20000, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d%% \00"
@.str.1 = [20 x i8] c"Elapsed time: %d ms\00"
define void @menu_benchmark() {
%1 = tail call i32 @SetGUIRequestMode(i32 1)
%2 = tail call i32 @msleep(i32 1000)
%3 = tail call i32 (...) @get_ms_clock_value()
br label %9
4: ; preds = %9
%5 = tail call i32 (...) @get_ms_clock_value()
%6 = tail call i32 (...) @clrscr()
%7 = sub nsw i32 %5, %3
%8 = tail call i32 @NotifyBox(i32 20000, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %7)
ret void
9: ; preds = %0, %9
%10 = phi i32 [ 0, %0 ], [ %16, %9 ]
%11 = tail call i32 (...) @menu_redraw_do()
%12 = trunc i32 %10 to i16
%13 = udiv i16 %12, 5
%14 = zext i16 %13 to i32
%15 = tail call i32 @bmp_printf(i32 131072, i32 0, i32 0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = add nuw nsw i32 %10, 1
%17 = icmp eq i32 %16, 500
br i1 %17, label %4, label %9
}