#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*/ display_setModeToAverage();
int /*<<< orphan*/ display_setModeToMaximum();
int /*<<< orphan*/ display_setModeToMinimum();
void event_modeSelectButtonPressed(void) {
  static int mode = 0;
  if (mode == 0) {
    display_setModeToMinimum();
    mode++;
  } else if (mode == 1) {
    display_setModeToMaximum();
    mode++;
  } else if (mode == 2) {
    display_setModeToAverage();
    mode++;
  } else {
    mode = 0;
  }
}


x86 assembly (clang, -O0):
<event_modeSelectButtonPressed>:
push   %rbp
mov    %rsp,%rbp
cmpl   $0x0,0x2f01(%rip)
jne    115c <event_modeSelectButtonPressed+0x2c>
mov    $0x0,%al
call   1040 <display_setModeToMinimum@plt>
mov    0x2eee(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ee5(%rip)
jmp    11c0 <event_modeSelectButtonPressed+0x90>
cmpl   $0x1,0x2ed9(%rip)
jne    1184 <event_modeSelectButtonPressed+0x54>
mov    $0x0,%al
call   1050 <display_setModeToMaximum@plt>
mov    0x2ec6(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ebd(%rip)
jmp    11bb <event_modeSelectButtonPressed+0x8b>
cmpl   $0x2,0x2eb1(%rip)
jne    11ac <event_modeSelectButtonPressed+0x7c>
mov    $0x0,%al
call   1030 <display_setModeToAverage@plt>
mov    0x2e9e(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e95(%rip)
jmp    11b6 <event_modeSelectButtonPressed+0x86>
movl   $0x0,0x2e86(%rip)
jmp    11bb <event_modeSelectButtonPressed+0x8b>
jmp    11c0 <event_modeSelectButtonPressed+0x90>
pop    %rbp
ret

x86 assembly (clang, -O2):
<event_modeSelectButtonPressed>:
push   %rax
mov    0x2f05(%rip),%ecx
cmp    $0x2,%ecx
je     1150 <event_modeSelectButtonPressed+0x20>
cmp    $0x1,%ecx
je     1159 <event_modeSelectButtonPressed+0x29>
xor    %eax,%eax
test   %ecx,%ecx
jne    1169 <event_modeSelectButtonPressed+0x39>
xor    %eax,%eax
call   1040 <display_setModeToMinimum@plt>
jmp    1160 <event_modeSelectButtonPressed+0x30>
xor    %eax,%eax
call   1030 <display_setModeToAverage@plt>
jmp    1160 <event_modeSelectButtonPressed+0x30>
xor    %eax,%eax
call   1050 <display_setModeToMaximum@plt>
mov    0x2ed6(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ecd(%rip)
pop    %rax
ret

LLVM IR (-O0):
@event_modeSelectButtonPressed.mode = internal global i32 0
define void @event_modeSelectButtonPressed() {
%1 = load i32, i32* @event_modeSelectButtonPressed.mode
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = call i32 (...) @display_setModeToMinimum()
%5 = load i32, i32* @event_modeSelectButtonPressed.mode
%6 = add nsw i32 %5, 1
store i32 %6, i32* @event_modeSelectButtonPressed.mode
br label %24
7: ; preds = %0
%8 = load i32, i32* @event_modeSelectButtonPressed.mode
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = call i32 (...) @display_setModeToMaximum()
%12 = load i32, i32* @event_modeSelectButtonPressed.mode
%13 = add nsw i32 %12, 1
store i32 %13, i32* @event_modeSelectButtonPressed.mode
br label %23
14: ; preds = %7
%15 = load i32, i32* @event_modeSelectButtonPressed.mode
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = call i32 (...) @display_setModeToAverage()
%19 = load i32, i32* @event_modeSelectButtonPressed.mode
%20 = add nsw i32 %19, 1
store i32 %20, i32* @event_modeSelectButtonPressed.mode
br label %22
21: ; preds = %14
store i32 0, i32* @event_modeSelectButtonPressed.mode
br label %22
22: ; preds = %21, %17
br label %23
23: ; preds = %22, %10
br label %24
24: ; preds = %23, %3
ret void
}

LLVM IR (-O2):
@event_modeSelectButtonPressed.mode = internal unnamed_addr global i32 0
define void @event_modeSelectButtonPressed() {
%1 = load i32, i32* @event_modeSelectButtonPressed.mode
switch i32 %1, label %14 [
i32 0, label %2
i32 1, label %6
i32 2, label %10
]
2: ; preds = %0
%3 = tail call i32 (...) @display_setModeToMinimum()
%4 = load i32, i32* @event_modeSelectButtonPressed.mode
%5 = add nsw i32 %4, 1
br label %14
6: ; preds = %0
%7 = tail call i32 (...) @display_setModeToMaximum()
%8 = load i32, i32* @event_modeSelectButtonPressed.mode
%9 = add nsw i32 %8, 1
br label %14
10: ; preds = %0
%11 = tail call i32 (...) @display_setModeToAverage()
%12 = load i32, i32* @event_modeSelectButtonPressed.mode
%13 = add nsw i32 %12, 1
br label %14
14: ; preds = %0, %6, %10, %2
%15 = phi i32 [ %9, %6 ], [ %13, %10 ], [ %5, %2 ], [ 0, %0 ]
store i32 %15, i32* @event_modeSelectButtonPressed.mode
ret void
}