int scale_precondition(unsigned scale, unsigned pixel, unsigned width,
                       unsigned height) {
  if (pixel != 1 && pixel != 2 && pixel != 4)
    return -1;
  switch (scale) {
  case 202:
  case 203:
  case 204:
  case 2:
  case 303:
  case 3:
    if (height < 2)
      return -1;
    break;
  case 404:
  case 4:
    if (height < 4)
      return -1;
    break;
  default:
    return -1;
  }
  if (width < 2)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<scale_precondition>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     113a <scale_precondition+0x3a>
cmpl   $0x2,-0xc(%rbp)
je     113a <scale_precondition+0x3a>
cmpl   $0x4,-0xc(%rbp)
je     113a <scale_precondition+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fd <scale_precondition+0xfd>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
add    $0xfffffffe,%eax
sub    $0x2,%eax
jb     119e <scale_precondition+0x9e>
jmp    1151 <scale_precondition+0x51>
mov    -0x18(%rbp),%eax
sub    $0x4,%eax
je     11b9 <scale_precondition+0xb9>
jmp    1162 <scale_precondition+0x62>
mov    -0x18(%rbp),%eax
add    $0xffffff36,%eax
sub    $0x3,%eax
jb     119e <scale_precondition+0x9e>
jmp    1178 <scale_precondition+0x78>
mov    -0x18(%rbp),%eax
sub    $0x12f,%eax
je     119e <scale_precondition+0x9e>
jmp    118b <scale_precondition+0x8b>
mov    -0x18(%rbp),%eax
sub    $0x194,%eax
je     11b9 <scale_precondition+0xb9>
jmp    11d4 <scale_precondition+0xd4>
cmpl   $0x2,-0x14(%rbp)
jae    11b4 <scale_precondition+0xb4>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fd <scale_precondition+0xfd>
jmp    11e0 <scale_precondition+0xe0>
cmpl   $0x4,-0x14(%rbp)
jae    11cf <scale_precondition+0xcf>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fd <scale_precondition+0xfd>
jmp    11e0 <scale_precondition+0xe0>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fd <scale_precondition+0xfd>
cmpl   $0x2,-0x10(%rbp)
jae    11f6 <scale_precondition+0xf6>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fd <scale_precondition+0xfd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<scale_precondition>:
mov    $0xffffffff,%eax
cmp    $0x4,%esi
ja     1139 <scale_precondition+0x39>
mov    $0x16,%r8d
bt     %esi,%r8d
jae    1139 <scale_precondition+0x39>
cmp    $0xc9,%edi
jle    113a <scale_precondition+0x3a>
lea    -0xca(%rdi),%esi
cmp    $0x3,%esi
jb     1142 <scale_precondition+0x42>
cmp    $0x194,%edi
je     114e <scale_precondition+0x4e>
cmp    $0x12f,%edi
je     1142 <scale_precondition+0x42>
ret
lea    -0x2(%rdi),%esi
cmp    $0x2,%esi
jae    1149 <scale_precondition+0x49>
cmp    $0x2,%ecx
jb     1139 <scale_precondition+0x39>
jmp    1153 <scale_precondition+0x53>
cmp    $0x4,%edi
jne    1139 <scale_precondition+0x39>
cmp    $0x4,%ecx
jb     1139 <scale_precondition+0x39>
cmp    $0x2,%edx
sbb    %eax,%eax
ret

LLVM IR (-O0):
define i32 @scale_precondition(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %19
12: ; preds = %4
%13 = load i32, i32* %7
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, 4
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 -1, i32* %5
br label %37
19: ; preds = %15, %12, %4
%20 = load i32, i32* %6
switch i32 %20, label %31 [
i32 202, label %21
i32 203, label %21
i32 204, label %21
i32 2, label %21
i32 303, label %21
i32 3, label %21
i32 404, label %26
i32 4, label %26
]
21: ; preds = %19, %19, %19, %19, %19, %19
%22 = load i32, i32* %9
%23 = icmp ult i32 %22, 2
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 -1, i32* %5
br label %37
25: ; preds = %21
br label %32
26: ; preds = %19, %19
%27 = load i32, i32* %9
%28 = icmp ult i32 %27, 4
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 -1, i32* %5
br label %37
30: ; preds = %26
br label %32
31: ; preds = %19
store i32 -1, i32* %5
br label %37
32: ; preds = %30, %25
%33 = load i32, i32* %8
%34 = icmp ult i32 %33, 2
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 -1, i32* %5
br label %37
36: ; preds = %32
store i32 0, i32* %5
br label %37
37: ; preds = %36, %35, %31, %29, %24, %18
%38 = load i32, i32* %5
ret i32 %38
}

LLVM IR (-O2):
define i32 @scale_precondition(i32 %0, i32 %1, i32 %2, i32 %3) {
switch i32 %1, label %13 [
i32 4, label %5
i32 2, label %5
i32 1, label %5
]
5: ; preds = %4, %4, %4
switch i32 %0, label %13 [
i32 202, label %6
i32 203, label %6
i32 204, label %6
i32 2, label %6
i32 303, label %6
i32 3, label %6
i32 404, label %8
i32 4, label %8
]
6: ; preds = %5, %5, %5, %5, %5, %5
%7 = icmp ult i32 %3, 2
br i1 %7, label %13, label %10
8: ; preds = %5, %5
%9 = icmp ult i32 %3, 4
br i1 %9, label %13, label %10
10: ; preds = %8, %6
%11 = icmp ult i32 %2, 2
%12 = sext i1 %11 to i32
br label %13
13: ; preds = %10, %5, %8, %6, %4
%14 = phi i32 [ -1, %4 ], [ -1, %6 ], [ -1, %8 ], [ -1, %5 ], [ %12, %10 ]
ret i32 %14
}