#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*/ outport(int, int, int, int, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
bright(int fdSer) {
  int opcode, bright_level;
  opcode = 0x0f8;
  printf("Enter brightness level: 0..7 [brightest] -> ");
  scanf("%d", &bright_level);
  if (bright_level > -1 && bright_level < 8) {
    outport(fdSer, bright_level, bright_level, bright_level, bright_level,
            opcode);
  } else {
    printf("Invalid value!!!\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<bright>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0xf8,-0xc(%rbp)
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0xffffffff,-0x10(%rbp)
jle    1190 <bright+0x60>
cmpl   $0x8,-0x10(%rbp)
jge    1190 <bright+0x60>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0xc(%rbp),%r9d
call   1040 <outport@plt>
jmp    119c <bright+0x6c>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bright>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
lea    0xec3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%ecx
cmp    $0x7,%ecx
ja     1193 <bright+0x43>
mov    %ebx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
mov    %ecx,%r8d
mov    $0xf8,%r9d
call   1060 <outport@plt>
jmp    119f <bright+0x4f>
lea    0xe96(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Enter brightness level: 0..7 [brightest] -> \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Invalid value!!!\07\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @bright(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 248, i32* %4
%6 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%8 = load i32, i32* %5
%9 = icmp sgt i32 %8, -1
br i1 %9, label %10, label %21
10: ; preds = %1
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 8
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = load i32, i32* %3
%15 = load i32, i32* %5
%16 = load i32, i32* %5
%17 = load i32, i32* %5
%18 = load i32, i32* %5
%19 = load i32, i32* %4
%20 = call i32 @outport(i32 %14, i32 %15, i32 %16, i32 %17, i32 %18, i32 %19)
br label %23
21: ; preds = %10, %1
%22 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %13
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str = [45 x i8] c"Enter brightness level: 0..7 [brightest] -> \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [18 x i8] c"Invalid value!!!\07\00"
define i32 @bright(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp ult i32 %6, 8
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @outport(i32 %0, i32 %6, i32 %6, i32 %6, i32 %6, i32 248)
br label %12
10: ; preds = %1
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = call i32 @putchar(i32 10)
ret i32 undef
}