#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, short);
void set_brightness(FILE *led_file, short brightness_value) {
  if ((255 < brightness_value) || (0 > brightness_value)) {
    printf("Value must be between %d and %d\n", 0, 255);
    exit(2);
  }
  char char_value[3];
  sprintf(char_value, "%d", brightness_value);
  fputs(char_value, led_file);
  fflush(led_file);
}


x86 assembly (clang, -O0):
<set_brightness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
movswl -0xa(%rbp),%ecx
mov    $0xff,%eax
cmp    %ecx,%eax
jl     1182 <set_brightness+0x32>
movswl -0xa(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jle    119f <set_brightness+0x4f>
lea    0xe77(%rip),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1030 <printf@plt>
mov    $0x2,%edi
call   1070 <exit@plt>
lea    -0xd(%rbp),%rdi
lea    0xe77(%rip),%rsi
movswl -0xa(%rbp),%edx
call   1060 <sprintf@plt>
lea    -0xd(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_brightness>:
push   %r14
push   %rbx
push   %rax
movzwl %si,%eax
cmp    $0x100,%eax
jae    1192 <set_brightness+0x42>
mov    %rdi,%rbx
movswl %si,%edx
lea    0xeb6(%rip),%rsi
lea    0x5(%rsp),%r14
mov    %r14,%rdi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fflush@plt>
lea    0xe67(%rip),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1030 <printf@plt>
mov    $0x2,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"Value must be between %d and %d\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define void @set_brightness(i32* %0, i16 signext %1) {
%3 = alloca i32*
%4 = alloca i16
%5 = alloca [3 x i8]
store i32* %0, i32** %3
store i16 %1, i16* %4
%6 = load i16, i16* %4
%7 = sext i16 %6 to i32
%8 = icmp slt i32 255, %7
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load i16, i16* %4
%11 = sext i16 %10 to i32
%12 = icmp sgt i32 0, %11
br i1 %12, label %13, label %16
13: ; preds = %9, %2
%14 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 0, i32 255)
%15 = call i32 @exit(i32 2)
unreachable
16: ; preds = %9
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%18 = load i16, i16* %4
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i16 signext %18)
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%21 = load i32*, i32** %3
%22 = call i32 @fputs(i8* %20, i32* %21)
%23 = load i32*, i32** %3
%24 = call i32 @fflush(i32* %23)
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"Value must be between %d and %d\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define void @set_brightness(i32* nocapture %0, i16 signext %1) {
%3 = alloca [3 x i8]
%4 = icmp ugt i16 %1, 255
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 0, i32 255)
%7 = tail call i32 @exit(i32 2)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%10 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i16 signext %1)
%11 = call i32 @fputs(i8* %9, i32* %0)
%12 = tail call i32 @fflush(i32* %0)
ret void
}