#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ processInput(int, char **, int, int *);
int /*<<< orphan*/ readFileData(int *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ wirteFileData(int, char *);
int main(int argc, char **argv) {
  if (argc < 2 || !strcmp("--help", argv[1])) {
    printf("usage: intelbacklight [arguments]\n arguments:\n -get\n -set "
           "<percentage>\n -inc <percentage>\n -dec <percentage>\n --help\n "
           "--version\n");
    return 0;
  } else if (!strcmp("--version", argv[1])) {
    printf("intelbacklight 0.1 <harrison@rodgers.io>\n");
    return 0;
  }
  int current = 0, maxval = 0, input = 0;
  readFileData(&current, "/sys/class/backlight/intel_backlight"
                         "/brightness");
  readFileData(&maxval, "/sys/class/backlight/intel_backlight"
                        "/max_brightness");
  if (!strcmp("-get", argv[1])) {
    printf("%F\n", ((float)current / maxval) * 100);
    return 0;
  }
  processInput(maxval, argv, argc, &input);
  if (!strcmp("-set", argv[1])) {
    current = input;
  } else if (!strcmp("-inc", argv[1])) {
    current += input;
  } else if (!strcmp("-dec", argv[1])) {
    current = input > current ? 0 : current - input;
  } else {
    fprintf(stderr, "error: unknown flag: %s\n", argv[1]);
    return 1;
  }
  wirteFileData(current, "/sys/class/backlight/intel_backlight"
                         "/brightness");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     119d <main+0x3d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe75(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11b7 <main+0x57>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1373 <main+0x213>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xec6(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11ee <main+0x8e>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1373 <main+0x213>
jmp    11f3 <main+0x93>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x14(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1040 <readFileData@plt>
lea    -0x18(%rbp),%rdi
lea    0xecd(%rip),%rsi
call   1040 <readFileData@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xeed(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    127d <main+0x11d>
cvtsi2ssl -0x14(%rbp),%xmm0
cvtsi2ssl -0x18(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  0xda5(%rip),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xebf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1373 <main+0x213>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    -0x1c(%rbp),%rcx
call   1080 <processInput@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe8e(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12b8 <main+0x158>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    135d <main+0x1fd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe6b(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12e3 <main+0x183>
mov    -0x1c(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1358 <main+0x1f8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe45(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    132a <main+0x1ca>
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1316 <main+0x1b6>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    131f <main+0x1bf>
mov    -0x14(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1353 <main+0x1f3>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdfa(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1373 <main+0x213>
jmp    1358 <main+0x1f8>
jmp    135d <main+0x1fd>
mov    -0x14(%rbp),%edi
lea    0xd59(%rip),%rsi
call   1070 <wirteFileData@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jl     1281 <main+0x111>
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x8(%rsi),%rbx
lea    0xe73(%rip),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1281 <main+0x111>
lea    0xf6e(%rip),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1298 <main+0x128>
movl   $0x0,0x4(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe34(%rip),%rsi
lea    0x4(%rsp),%rdi
call   1050 <readFileData@plt>
lea    0xe53(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1050 <readFileData@plt>
mov    0x8(%r14),%rsi
lea    0xe72(%rip),%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     12a1 <main+0x131>
mov    0xc(%rsp),%edi
lea    0x8(%rsp),%rcx
mov    %r14,%rsi
mov    %ebp,%edx
call   1090 <processInput@plt>
mov    0x8(%r14),%rbx
lea    0xe50(%rip),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     12cd <main+0x15d>
lea    0xe3e(%rip),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     12d3 <main+0x163>
lea    0xe2c(%rip),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     12dd <main+0x16d>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
mov    $0x1,%eax
jmp    128f <main+0x11f>
lea    0xe18(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe81(%rip),%rdi
jmp    1288 <main+0x118>
cvtsi2ssl 0x4(%rsp),%xmm0
cvtsi2ssl 0xc(%rsp),%xmm1
divss  %xmm1,%xmm0
mulss  0xd47(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb0(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    128d <main+0x11d>
mov    0x8(%rsp),%edi
jmp    12ea <main+0x17a>
mov    0x4(%rsp),%edi
add    0x8(%rsp),%edi
jmp    12ea <main+0x17a>
mov    0x4(%rsp),%edi
xor    %eax,%eax
sub    0x8(%rsp),%edi
cmovl  %eax,%edi
mov    %edi,0x4(%rsp)
lea    0xd16(%rip),%rsi
call   1080 <wirteFileData@plt>
jmp    128d <main+0x11d>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [129 x i8] c"usage: intelbacklight [arguments]\0A arguments:\0A -get\0A -set <percentage>\0A -inc <percentage>\0A -dec <percentage>\0A --help\0A --version\0A\00"
@.str.2 = [10 x i8] c"--version\00"
@.str.3 = [42 x i8] c"intelbacklight 0.1 <harrison@rodgers.io>\0A\00"
@.str.4 = [48 x i8] c"/sys/class/backlight/intel_backlight/brightness\00"
@.str.5 = [52 x i8] c"/sys/class/backlight/intel_backlight/max_brightness\00"
@.str.6 = [5 x i8] c"-get\00"
@.str.7 = [4 x i8] c"%F\0A\00"
@.str.8 = [5 x i8] c"-set\00"
@.str.9 = [5 x i8] c"-inc\00"
@.str.10 = [5 x i8] c"-dec\00"
@stderr = global i32 0
@.str.11 = [25 x i8] c"error: unknown flag: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %17, label %11
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %11, %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %95
19: ; preds = %11
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %19
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %95
27: ; preds = %19
br label %28
28: ; preds = %27
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%29 = call i32 @readFileData(i32* %6, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 @readFileData(i32* %7, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0))
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %45, label %36
36: ; preds = %28
%37 = load i32, i32* %6
%38 = sitofp i32 %37 to float
%39 = load i32, i32* %7
%40 = sitofp i32 %39 to float
%41 = fdiv float %38, %40
%42 = fmul float %41, 1.000000e+02
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double %43)
store i32 0, i32* %3
br label %95
45: ; preds = %28
%46 = load i32, i32* %7
%47 = load i8**, i8*** %5
%48 = load i32, i32* %4
%49 = call i32 @processInput(i32 %46, i8** %47, i32 %48, i32* %8)
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %57, label %55
55: ; preds = %45
%56 = load i32, i32* %8
store i32 %56, i32* %6
br label %92
57: ; preds = %45
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %60)
%62 = icmp ne i32 %61, 0
br i1 %62, label %67, label %63
63: ; preds = %57
%64 = load i32, i32* %8
%65 = load i32, i32* %6
%66 = add nsw i32 %65, %64
store i32 %66, i32* %6
br label %91
67: ; preds = %57
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 1
%70 = load i8*, i8** %69
%71 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* %70)
%72 = icmp ne i32 %71, 0
br i1 %72, label %84, label %73
73: ; preds = %67
%74 = load i32, i32* %8
%75 = load i32, i32* %6
%76 = icmp sgt i32 %74, %75
br i1 %76, label %77, label %78
77: ; preds = %73
br label %82
78: ; preds = %73
%79 = load i32, i32* %6
%80 = load i32, i32* %8
%81 = sub nsw i32 %79, %80
br label %82
82: ; preds = %78, %77
%83 = phi i32 [ 0, %77 ], [ %81, %78 ]
store i32 %83, i32* %6
br label %90
84: ; preds = %67
%85 = load i32, i32* @stderr
%86 = load i8**, i8*** %5
%87 = getelementptr inbounds i8*, i8** %86, i64 1
%88 = load i8*, i8** %87
%89 = call i32 @fprintf(i32 %85, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %88)
store i32 1, i32* %3
br label %95
90: ; preds = %82
br label %91
91: ; preds = %90, %63
br label %92
92: ; preds = %91, %55
%93 = load i32, i32* %6
%94 = call i32 @wirteFileData(i32 %93, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %95
95: ; preds = %92, %84, %36, %25, %17
%96 = load i32, i32* %3
ret i32 %96
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@.str.2 = [10 x i8] c"--version\00"
@.str.4 = [48 x i8] c"/sys/class/backlight/intel_backlight/brightness\00"
@.str.5 = [52 x i8] c"/sys/class/backlight/intel_backlight/max_brightness\00"
@.str.6 = [5 x i8] c"-get\00"
@.str.7 = [4 x i8] c"%F\0A\00"
@.str.8 = [5 x i8] c"-set\00"
@.str.9 = [5 x i8] c"-inc\00"
@.str.10 = [5 x i8] c"-dec\00"
@stderr = global i32 0
@.str.11 = [25 x i8] c"error: unknown flag: %s\0A\00"
@str = [128 x i8] c"usage: intelbacklight [arguments]\0A arguments:\0A -get\0A -set <percentage>\0A -inc <percentage>\0A -dec <percentage>\0A --help\0A --version\00"
@str.12 = [41 x i8] c"intelbacklight 0.1 <harrison@rodgers.io>\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = icmp slt i32 %0, 2
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7, %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @str, i64 0, i64 0))
br label %69
14: ; preds = %7
%15 = tail call i32 @strcmp(i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* dereferenceable(1) %9)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.12, i64 0, i64 0))
br label %69
19: ; preds = %14
%20 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%21 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%22 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%23 = call i32 @readFileData(i32* %3, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 @readFileData(i32* %4, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0))
%25 = load i8*, i8** %8
%26 = call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* dereferenceable(1) %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %19
%29 = load i32, i32* %3
%30 = sitofp i32 %29 to float
%31 = load i32, i32* %4
%32 = sitofp i32 %31 to float
%33 = fdiv float %30, %32
%34 = fmul float %33, 1.000000e+02
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double %35)
br label %67
37: ; preds = %19
%38 = load i32, i32* %4
%39 = call i32 @processInput(i32 %38, i8** %1, i32 %0, i32* %5)
%40 = load i8*, i8** %8
%41 = call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* dereferenceable(1) %40)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = load i32, i32* %5
store i32 %44, i32* %3
br label %64
45: ; preds = %37
%46 = call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* dereferenceable(1) %40)
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = load i32, i32* %5
%50 = load i32, i32* %3
%51 = add nsw i32 %50, %49
store i32 %51, i32* %3
br label %64
52: ; preds = %45
%53 = call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* dereferenceable(1) %40)
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %61
55: ; preds = %52
%56 = load i32, i32* %5
%57 = load i32, i32* %3
%58 = icmp slt i32 %57, %56
%59 = sub nsw i32 %57, %56
%60 = select i1 %58, i32 0, i32 %59
store i32 %60, i32* %3
br label %64
61: ; preds = %52
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %40)
br label %67
64: ; preds = %48, %55, %43
%65 = phi i32 [ %51, %48 ], [ %60, %55 ], [ %44, %43 ]
%66 = call i32 @wirteFileData(i32 %65, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %67
67: ; preds = %64, %61, %28
%68 = phi i32 [ 1, %61 ], [ 0, %64 ], [ 0, %28 ]
br label %69
69: ; preds = %67, %17, %12
%70 = phi i32 [ 0, %12 ], [ %68, %67 ], [ 0, %17 ]
ret i32 %70
}