#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*/ set_sysparam(int, int);
int soar_ecWatchLevel(int level) {
  if (level > 5 || level < 0)
    return -1;
  set_sysparam(1, (0));
  set_sysparam(2, (0));
  set_sysparam(4, (0));
  set_sysparam(3, (0));
  set_sysparam(5, (0));
  set_sysparam(6, (0));
  set_sysparam(9, (0));
  set_sysparam(8, (0));
  set_sysparam(28, (0));
  switch (level) {
  case 0:
    set_sysparam(7, 1);
    set_sysparam(10, (0));
    set_sysparam(11, (0));
    set_sysparam(12, (0));
    set_sysparam(13, (0));
    set_sysparam(28, (0));
    break;
  case 5:
    set_sysparam(8, (1));
  case 4:
    set_sysparam(9, (1));
  case 3:
    set_sysparam(4, (1));
    set_sysparam(3, (1));
    set_sysparam(5, (1));
    set_sysparam(6, (1));
  case 2:
    set_sysparam(2, (1));
  case 1:
    set_sysparam(1, (1));
  }
  return 0;
}


x86 assembly (clang, -O0):
<soar_ecWatchLevel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jg     112f <soar_ecWatchLevel+0x1f>
cmpl   $0x0,-0x8(%rbp)
jge    113b <soar_ecWatchLevel+0x2b>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a3 <soar_ecWatchLevel+0x193>
mov    $0x1,%edi
xor    %esi,%esi
mov    %esi,-0x14(%rbp)
call   1030 <set_sysparam@plt>
mov    -0x14(%rbp),%esi
mov    $0x2,%edi
call   1030 <set_sysparam@plt>
mov    -0x14(%rbp),%esi
mov    $0x4,%edi
call   1030 <set_sysparam@plt>
mov    -0x14(%rbp),%esi
mov    $0x3,%edi
call   1030 <set_sysparam@plt>
mov    -0x14(%rbp),%esi
mov    $0x5,%edi
call   1030 <set_sysparam@plt>
mov    -0x14(%rbp),%esi
mov    $0x6,%edi
call   1030 <set_sysparam@plt>
mov    -0x14(%rbp),%esi
mov    $0x9,%edi
call   1030 <set_sysparam@plt>
mov    -0x14(%rbp),%esi
mov    $0x8,%edi
call   1030 <set_sysparam@plt>
mov    -0x14(%rbp),%esi
mov    $0x1c,%edi
call   1030 <set_sysparam@plt>
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x5,%rax
ja     129c <soar_ecWatchLevel+0x18c>
mov    -0x10(%rbp),%rax
lea    0xe32(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x7,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0xa,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0xb,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0xc,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0xd,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0x1c,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
jmp    129c <soar_ecWatchLevel+0x18c>
mov    $0x8,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x9,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x3,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x5,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x6,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1030 <set_sysparam@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<soar_ecWatchLevel>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebx
cmp    $0x5,%edi
ja     126e <soar_ecWatchLevel+0x15e>
mov    %edi,%ebp
xor    %ebx,%ebx
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0x3,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0x5,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0x6,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0x9,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0x1c,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
cmp    $0x5,%ebp
ja     126e <soar_ecWatchLevel+0x15e>
mov    %ebp,%eax
lea    0xe5d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x7,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
xor    %ebx,%ebx
mov    $0xa,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0xb,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0xc,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0xd,%edi
xor    %esi,%esi
call   1030 <set_sysparam@plt>
mov    $0x1c,%edi
xor    %esi,%esi
jmp    1269 <soar_ecWatchLevel+0x159>
mov    $0x8,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x9,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x3,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x5,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x6,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1030 <set_sysparam@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @soar_ecWatchLevel(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sgt i32 %4, 5
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %6, %1
store i32 -1, i32* %2
br label %42
10: ; preds = %6
%11 = call i32 @set_sysparam(i32 1, i32 0)
%12 = call i32 @set_sysparam(i32 2, i32 0)
%13 = call i32 @set_sysparam(i32 4, i32 0)
%14 = call i32 @set_sysparam(i32 3, i32 0)
%15 = call i32 @set_sysparam(i32 5, i32 0)
%16 = call i32 @set_sysparam(i32 6, i32 0)
%17 = call i32 @set_sysparam(i32 9, i32 0)
%18 = call i32 @set_sysparam(i32 8, i32 0)
%19 = call i32 @set_sysparam(i32 28, i32 0)
%20 = load i32, i32* %3
switch i32 %20, label %41 [
i32 0, label %21
i32 5, label %28
i32 4, label %30
i32 3, label %32
i32 2, label %37
i32 1, label %39
]
21: ; preds = %10
%22 = call i32 @set_sysparam(i32 7, i32 1)
%23 = call i32 @set_sysparam(i32 10, i32 0)
%24 = call i32 @set_sysparam(i32 11, i32 0)
%25 = call i32 @set_sysparam(i32 12, i32 0)
%26 = call i32 @set_sysparam(i32 13, i32 0)
%27 = call i32 @set_sysparam(i32 28, i32 0)
br label %41
28: ; preds = %10
%29 = call i32 @set_sysparam(i32 8, i32 1)
br label %30
30: ; preds = %10, %28
%31 = call i32 @set_sysparam(i32 9, i32 1)
br label %32
32: ; preds = %10, %30
%33 = call i32 @set_sysparam(i32 4, i32 1)
%34 = call i32 @set_sysparam(i32 3, i32 1)
%35 = call i32 @set_sysparam(i32 5, i32 1)
%36 = call i32 @set_sysparam(i32 6, i32 1)
br label %37
37: ; preds = %10, %32
%38 = call i32 @set_sysparam(i32 2, i32 1)
br label %39
39: ; preds = %10, %37
%40 = call i32 @set_sysparam(i32 1, i32 1)
br label %41
41: ; preds = %39, %10, %21
store i32 0, i32* %2
br label %42
42: ; preds = %41, %9
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
define i32 @soar_ecWatchLevel(i32 %0) {
%2 = icmp ugt i32 %0, 5
br i1 %2, label %33, label %3
3: ; preds = %1
%4 = tail call i32 @set_sysparam(i32 1, i32 0)
%5 = tail call i32 @set_sysparam(i32 2, i32 0)
%6 = tail call i32 @set_sysparam(i32 4, i32 0)
%7 = tail call i32 @set_sysparam(i32 3, i32 0)
%8 = tail call i32 @set_sysparam(i32 5, i32 0)
%9 = tail call i32 @set_sysparam(i32 6, i32 0)
%10 = tail call i32 @set_sysparam(i32 9, i32 0)
%11 = tail call i32 @set_sysparam(i32 8, i32 0)
%12 = tail call i32 @set_sysparam(i32 28, i32 0)
switch i32 %0, label %33 [
i32 0, label %13
i32 5, label %20
i32 4, label %22
i32 3, label %24
i32 2, label %29
i32 1, label %31
]
13: ; preds = %3
%14 = tail call i32 @set_sysparam(i32 7, i32 1)
%15 = tail call i32 @set_sysparam(i32 10, i32 0)
%16 = tail call i32 @set_sysparam(i32 11, i32 0)
%17 = tail call i32 @set_sysparam(i32 12, i32 0)
%18 = tail call i32 @set_sysparam(i32 13, i32 0)
%19 = tail call i32 @set_sysparam(i32 28, i32 0)
br label %33
20: ; preds = %3
%21 = tail call i32 @set_sysparam(i32 8, i32 1)
br label %22
22: ; preds = %3, %20
%23 = tail call i32 @set_sysparam(i32 9, i32 1)
br label %24
24: ; preds = %3, %22
%25 = tail call i32 @set_sysparam(i32 4, i32 1)
%26 = tail call i32 @set_sysparam(i32 3, i32 1)
%27 = tail call i32 @set_sysparam(i32 5, i32 1)
%28 = tail call i32 @set_sysparam(i32 6, i32 1)
br label %29
29: ; preds = %3, %24
%30 = tail call i32 @set_sysparam(i32 2, i32 1)
br label %31
31: ; preds = %3, %29
%32 = tail call i32 @set_sysparam(i32 1, i32 1)
br label %33
33: ; preds = %13, %3, %31, %1
%34 = phi i32 [ -1, %1 ], [ 0, %31 ], [ 0, %3 ], [ 0, %13 ]
ret i32 %34
}