#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 izborFilma();
int izborFilmaPoImenu();
int izborFilmaPoPopularnosti();
int izborFilmaPoZanru();
int glavniMeni() {
  int state = 1;
  int filmId;
  while (state) {
    int o = izborFilma();
    switch (o) {
    case 0:
      state = 0;
      break;
    case 1:
      state = 0;
      filmId = izborFilmaPoImenu();
      break;
    case 2:
      state = 0;
      filmId = izborFilmaPoZanru();
      break;
    case 3:
      state = 0;
      filmId = izborFilmaPoPopularnosti();
      break;
    }
  }
  return filmId;
}


x86 assembly (clang, -O0):
<glavniMeni>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11d6 <glavniMeni+0x96>
xor    %eax,%eax
call   1040 <izborFilma@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     11d1 <glavniMeni+0x91>
mov    -0x18(%rbp),%rax
lea    0xe81(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x4(%rbp)
jmp    11d1 <glavniMeni+0x91>
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <izborFilmaPoImenu@plt>
mov    %eax,-0x8(%rbp)
jmp    11d1 <glavniMeni+0x91>
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <izborFilmaPoZanru@plt>
mov    %eax,-0x8(%rbp)
jmp    11d1 <glavniMeni+0x91>
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <izborFilmaPoPopularnosti@plt>
mov    %eax,-0x8(%rbp)
jmp    114f <glavniMeni+0xf>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glavniMeni>:
push   %rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <izborFilma@plt>
cmp    $0x3,%eax
ja     1150 <glavniMeni+0x10>
mov    %eax,%eax
lea    0xe9b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
jmp    1060 <izborFilmaPoZanru@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <izborFilmaPoPopularnosti@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <izborFilmaPoImenu@plt>

LLVM IR (-O0):
define i32 @glavniMeni() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 1, i32* %1
br label %4
4: ; preds = %17, %0
%5 = load i32, i32* %1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = call i32 (...) @izborFilma()
store i32 %8, i32* %3
%9 = load i32, i32* %3
switch i32 %9, label %17 [
i32 0, label %10
i32 1, label %11
i32 2, label %13
i32 3, label %15
]
10: ; preds = %7
store i32 0, i32* %1
br label %17
11: ; preds = %7
store i32 0, i32* %1
%12 = call i32 (...) @izborFilmaPoImenu()
store i32 %12, i32* %2
br label %17
13: ; preds = %7
store i32 0, i32* %1
%14 = call i32 (...) @izborFilmaPoZanru()
store i32 %14, i32* %2
br label %17
15: ; preds = %7
store i32 0, i32* %1
%16 = call i32 (...) @izborFilmaPoPopularnosti()
store i32 %16, i32* %2
br label %17
17: ; preds = %7, %15, %13, %11, %10
br label %4
18: ; preds = %4
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
define i32 @glavniMeni() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 (...) @izborFilma()
switch i32 %2, label %1 [
i32 0, label %9
i32 1, label %3
i32 2, label %5
i32 3, label %7
]
3: ; preds = %1
%4 = tail call i32 (...) @izborFilmaPoImenu()
br label %9
5: ; preds = %1
%6 = tail call i32 (...) @izborFilmaPoZanru()
br label %9
7: ; preds = %1
%8 = tail call i32 (...) @izborFilmaPoPopularnosti()
br label %9
9: ; preds = %1, %7, %5, %3
%10 = phi i32 [ %4, %3 ], [ %6, %5 ], [ %8, %7 ], [ undef, %1 ]
ret i32 %10
}