#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*/ printf(char *);
long cmdcnt(int ver, int aver) {
  switch (ver) {
  case 1:
    return 400;
  case 2:
    if (aver == 4)
      return 1100;
    else
      return 900;
  case 3:
    return 900;
  case 4:
    return 1500;
  }
  printf("INTERNAL ERROR: Invalid VER\n");
  return 0;
}


x86 assembly (clang, -O0):
<cmdcnt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1192 <cmdcnt+0x82>
mov    -0x18(%rbp),%rax
lea    0xec2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movq   $0x190,-0x8(%rbp)
jmp    11a6 <cmdcnt+0x96>
cmpl   $0x4,-0x10(%rbp)
jne    116b <cmdcnt+0x5b>
movq   $0x44c,-0x8(%rbp)
jmp    11a6 <cmdcnt+0x96>
movq   $0x384,-0x8(%rbp)
jmp    11a6 <cmdcnt+0x96>
movq   $0x384,-0x8(%rbp)
jmp    11a6 <cmdcnt+0x96>
movq   $0x5dc,-0x8(%rbp)
jmp    11a6 <cmdcnt+0x96>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmdcnt>:
push   %rax
add    $0xffffffff,%edi
cmp    $0x3,%edi
ja     1141 <cmdcnt+0x31>
mov    $0x190,%eax
lea    0xedb(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
cmp    $0x4,%esi
mov    $0x44c,%ecx
mov    $0x384,%eax
cmove  %rcx,%rax
pop    %rcx
ret
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x384,%eax
pop    %rcx
ret
mov    $0x5dc,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"INTERNAL ERROR: Invalid VER\0A\00"
define i64 @cmdcnt(i32 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
switch i32 %6, label %15 [
i32 1, label %7
i32 2, label %8
i32 3, label %13
i32 4, label %14
]
7: ; preds = %2
store i64 400, i64* %3
br label %17
8: ; preds = %2
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 4
br i1 %10, label %11, label %12
11: ; preds = %8
store i64 1100, i64* %3
br label %17
12: ; preds = %8
store i64 900, i64* %3
br label %17
13: ; preds = %2
store i64 900, i64* %3
br label %17
14: ; preds = %2
store i64 1500, i64* %3
br label %17
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %3
br label %17
17: ; preds = %15, %14, %13, %12, %11, %7
%18 = load i64, i64* %3
ret i64 %18
}

LLVM IR (-O2):
@str = [28 x i8] c"INTERNAL ERROR: Invalid VER\00"
define i64 @cmdcnt(i32 %0, i32 %1) {
switch i32 %0, label %8 [
i32 1, label %10
i32 2, label %3
i32 3, label %6
i32 4, label %7
]
3: ; preds = %2
%4 = icmp eq i32 %1, 4
%5 = select i1 %4, i64 1100, i64 900
br label %10
6: ; preds = %2
br label %10
7: ; preds = %2
br label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %3, %2, %8, %7, %6
%11 = phi i64 [ 0, %8 ], [ 1500, %7 ], [ 900, %6 ], [ 400, %2 ], [ %5, %3 ]
ret i64 %11
}