#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int convertBrightness(int bval) {
  int brightness = 0;
  switch (bval) {
  case -1:
    brightness = 80;
    break;
  case 0:
    brightness = 120;
    break;
  case 10:
    brightness = 4882;
    break;
  default:
    brightness = bval * 500;
  }
  if (brightness > 4882 || brightness < 80) {
    fprintf(stderr, "Error: Invalid brightness value.\n");
    exit(1);
  }
  return brightness;
}


x86 assembly (clang, -O0):
<convertBrightness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0xffffffff,%eax
je     1167 <convertBrightness+0x47>
jmp    1146 <convertBrightness+0x26>
mov    -0xc(%rbp),%eax
test   %eax,%eax
je     1173 <convertBrightness+0x53>
jmp    1156 <convertBrightness+0x36>
mov    -0xc(%rbp),%eax
sub    $0xa,%eax
je     117f <convertBrightness+0x5f>
jmp    118b <convertBrightness+0x6b>
movl   $0x50,-0x8(%rbp)
jmp    1195 <convertBrightness+0x75>
movl   $0x78,-0x8(%rbp)
jmp    1195 <convertBrightness+0x75>
movl   $0x1312,-0x8(%rbp)
jmp    1195 <convertBrightness+0x75>
imul   $0x1f4,-0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x1312,-0x8(%rbp)
jg     11ac <convertBrightness+0x8c>
cmpl   $0x50,-0x8(%rbp)
jge    11cb <convertBrightness+0xab>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertBrightness>:
cmp    $0xffffffff,%edi
je     1134 <convertBrightness+0x14>
cmp    $0xa,%edi
je     113a <convertBrightness+0x1a>
test   %edi,%edi
jne    1141 <convertBrightness+0x21>
mov    $0x78,%eax
ret
mov    $0x50,%eax
ret
mov    $0x1312,%eax
jmp    1155 <convertBrightness+0x35>
imul   $0x1f4,%edi,%eax
lea    -0x1313(%rax),%ecx
cmp    $0xffffed3c,%ecx
jbe    1156 <convertBrightness+0x36>
ret
push   %rax
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Error: Invalid brightness value.\0A\00"
define i32 @convertBrightness(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
switch i32 %4, label %8 [
i32 -1, label %5
i32 0, label %6
i32 10, label %7
]
5: ; preds = %1
store i32 80, i32* %3
br label %11
6: ; preds = %1
store i32 120, i32* %3
br label %11
7: ; preds = %1
store i32 4882, i32* %3
br label %11
8: ; preds = %1
%9 = load i32, i32* %2
%10 = mul nsw i32 %9, 500
store i32 %10, i32* %3
br label %11
11: ; preds = %8, %7, %6, %5
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 4882
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 80
br i1 %16, label %17, label %21
17: ; preds = %14, %11
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %14
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Error: Invalid brightness value.\0A\00"
define i32 @convertBrightness(i32 %0) {
switch i32 %0, label %4 [
i32 -1, label %12
i32 0, label %2
i32 10, label %3
]
2: ; preds = %1
br label %12
3: ; preds = %1
br label %12
4: ; preds = %1
%5 = mul nsw i32 %0, 500
%6 = add i32 %5, -4883
%7 = icmp ult i32 %6, -4803
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %1, %2, %3, %4
%13 = phi i32 [ %5, %4 ], [ 80, %1 ], [ 120, %2 ], [ 4882, %3 ]
ret i32 %13
}