#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ getuid();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sscanf(char *, char *, int *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (getuid() != 0) {
    printf("You need to be a superuser to use this program.\n");
    return 5;
  }
  static const char *CONFIG_PATH = "/etc/backlightctl.conf";
  FILE *config, *brightness, *max_brightness;
  char brightness_path[1024];
  char max_brightness_path[1024];
  int cur_br, max_br, delta_perc, set_perc, set_br;
  config = fopen(CONFIG_PATH, "r");
  if (config == NULL) {
    return 2;
  }
  fscanf(config, "%s\n%s", brightness_path, max_brightness_path);
  fclose(config);
  brightness = fopen(brightness_path, "r+");
  if (brightness == NULL) {
    return 3;
  }
  max_brightness = fopen(max_brightness_path, "r");
  if (max_brightness == NULL) {
    return 4;
  }
  fscanf(brightness, "%d", &cur_br);
  fscanf(max_brightness, "%d", &max_br);
  fclose(max_brightness);
  set_perc = (int)(((float)cur_br / (float)max_br) * 100.0 + 0.5f);
  if (argc < 2) {
    printf("%d\n", set_perc);
    return 0;
  } else if (argc == 2) {
    if (strcmp(argv[1], "-h") == 0) {
      printf("Usage: %s [[{+,-}]PERCENTAGE]\n\t when no parameters are given, "
             "the current percentage is printed out.\n",
             argv[0]);
      return 0;
    } else if (sscanf(argv[1], "%d", &delta_perc) != 0) {
      if (argv[1][0] == '+') {
        set_perc += delta_perc;
        set_perc = (set_perc > 100) ? 100 : set_perc;
      } else if (argv[1][0] == '-') {
        set_perc += delta_perc;
        set_perc = (set_perc < 1) ? 1 : set_perc;
      } else {
        set_perc = delta_perc;
        set_perc = (set_perc > 100) ? 100 : set_perc;
        set_perc = (set_perc < 1) ? 1 : set_perc;
      }
    } else {
      printf("invalid parameter\n");
      return 1;
    }
  }
  set_br = (int)((((float)set_perc) / 100.0) * ((float)max_br));
  set_br = (set_br < 50) ? 50 : set_br;
  fprintf(brightness, "%d\n", set_br);
  fclose(brightness);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
cmp    $0x0,%rax
je     11c4 <main+0x44>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x5,-0x4(%rbp)
jmp    157a <main+0x3fa>
mov    0x2e95(%rip),%rdi
lea    0xe86(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f2 <main+0x72>
movl   $0x2,-0x4(%rbp)
jmp    157a <main+0x3fa>
mov    -0x18(%rbp),%rdi
lea    -0x430(%rbp),%rdx
lea    -0x830(%rbp),%rcx
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x430(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1249 <main+0xc9>
movl   $0x3,-0x4(%rbp)
jmp    157a <main+0x3fa>
lea    -0x830(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1277 <main+0xf7>
movl   $0x4,-0x4(%rbp)
jmp    157a <main+0x3fa>
mov    -0x20(%rbp),%rdi
lea    0xde1(%rip),%rsi
lea    -0x834(%rbp),%rdx
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x28(%rbp),%rdi
lea    0xdc8(%rip),%rsi
lea    -0x838(%rbp),%rdx
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
cvtsi2ssl -0x834(%rbp),%xmm0
ff
cvtsi2ssl -0x838(%rbp),%xmm1
ff
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd2e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd2a(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x840(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1316 <main+0x196>
mov    -0x840(%rbp),%esi
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    157a <main+0x3fa>
cmpl   $0x2,-0x8(%rbp)
jne    14e8 <main+0x368>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd3b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    135f <main+0x1df>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    157a <main+0x3fa>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcf5(%rip),%rsi
lea    -0x83c(%rbp),%rdx
call   1090 <sscanf@plt>
cmp    $0x0,%rax
je     14c4 <main+0x344>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    13e4 <main+0x264>
mov    -0x83c(%rbp),%eax
add    -0x840(%rbp),%eax
mov    %eax,-0x840(%rbp)
cmpl   $0x64,-0x840(%rbp)
jle    13c7 <main+0x247>
mov    $0x64,%eax
mov    %eax,-0x848(%rbp)
jmp    13d3 <main+0x253>
mov    -0x840(%rbp),%eax
mov    %eax,-0x848(%rbp)
mov    -0x848(%rbp),%eax
mov    %eax,-0x840(%rbp)
jmp    14bf <main+0x33f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1444 <main+0x2c4>
mov    -0x83c(%rbp),%eax
add    -0x840(%rbp),%eax
mov    %eax,-0x840(%rbp)
cmpl   $0x1,-0x840(%rbp)
jge    1427 <main+0x2a7>
mov    $0x1,%eax
mov    %eax,-0x84c(%rbp)
jmp    1433 <main+0x2b3>
mov    -0x840(%rbp),%eax
mov    %eax,-0x84c(%rbp)
mov    -0x84c(%rbp),%eax
mov    %eax,-0x840(%rbp)
jmp    14ba <main+0x33a>
mov    -0x83c(%rbp),%eax
mov    %eax,-0x840(%rbp)
cmpl   $0x64,-0x840(%rbp)
jle    146d <main+0x2ed>
mov    $0x64,%eax
mov    %eax,-0x850(%rbp)
jmp    1479 <main+0x2f9>
mov    -0x840(%rbp),%eax
mov    %eax,-0x850(%rbp)
mov    -0x850(%rbp),%eax
mov    %eax,-0x840(%rbp)
cmpl   $0x1,-0x840(%rbp)
jge    14a2 <main+0x322>
mov    $0x1,%eax
mov    %eax,-0x854(%rbp)
jmp    14ae <main+0x32e>
mov    -0x840(%rbp),%eax
mov    %eax,-0x854(%rbp)
mov    -0x854(%rbp),%eax
mov    %eax,-0x840(%rbp)
jmp    14bf <main+0x33f>
jmp    14de <main+0x35e>
lea    0xc08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    157a <main+0x3fa>
jmp    14e3 <main+0x363>
jmp    14e8 <main+0x368>
jmp    14ed <main+0x36d>
cvtsi2ssl -0x840(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  0xaff(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2ssl -0x838(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x844(%rbp)
cmpl   $0x32,-0x844(%rbp)
jge    153c <main+0x3bc>
mov    $0x32,%eax
mov    %eax,-0x858(%rbp)
jmp    1548 <main+0x3c8>
mov    -0x844(%rbp),%eax
mov    %eax,-0x858(%rbp)
mov    -0x858(%rbp),%eax
mov    %eax,-0x844(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x844(%rbp),%edx
lea    0xb01(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x860,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
mov    %rsi,%r12
mov    %edi,%r13d
xor    %eax,%eax
call   1050 <getuid@plt>
test   %rax,%rax
je     11d8 <main+0x48>
lea    0xef8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5,%ebx
mov    %ebx,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe31(%rip),%rdi
lea    0xeca(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12d2 <main+0x142>
mov    %rax,%rbx
lea    0xe29(%rip),%rsi
lea    0x410(%rsp),%rbp
lea    0x10(%rsp),%rcx
mov    %rax,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe06(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12dc <main+0x14c>
mov    %rax,%r14
lea    0xe6e(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12e6 <main+0x156>
mov    %rax,%rbp
lea    0xdd1(%rip),%r15
xor    %ebx,%ebx
lea    0xc(%rsp),%rdx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <fscanf@plt>
lea    0x8(%rsp),%rdx
mov    %rbp,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
cvtsi2ssl 0xc(%rsp),%xmm0
cvtsi2ssl 0x8(%rsp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xd57(%rip),%xmm0
addsd  0xd57(%rip),%xmm0
cvttsd2si %xmm0,%r15d
cmp    $0x1,%r13d
jg     12f0 <main+0x160>
lea    0xd70(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11c4 <main+0x34>
mov    $0x2,%ebx
jmp    11c4 <main+0x34>
mov    $0x3,%ebx
jmp    11c4 <main+0x34>
mov    $0x4,%ebx
jmp    11c4 <main+0x34>
cmp    $0x2,%r13d
jne    13ab <main+0x21b>
mov    0x8(%r12),%rdi
lea    0xd31(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     134e <main+0x1be>
mov    0x8(%r12),%rdi
lea    0xd14(%rip),%rsi
lea    0x4(%rsp),%rdx
call   10a0 <sscanf@plt>
test   %rax,%rax
je     1367 <main+0x1d7>
mov    0x8(%r12),%rax
mov    (%rax),%al
cmp    $0x2d,%al
je     137d <main+0x1ed>
cmp    $0x2b,%al
jne    1390 <main+0x200>
add    0x4(%rsp),%r15d
cmp    $0x64,%r15d
mov    $0x64,%eax
cmovge %eax,%r15d
jmp    13ab <main+0x21b>
mov    (%r12),%rsi
lea    0xce1(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11c4 <main+0x34>
lea    0xd32(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    11c4 <main+0x34>
add    0x4(%rsp),%r15d
test   %r15d,%r15d
mov    $0x1,%eax
cmovle %eax,%r15d
jmp    13ab <main+0x21b>
mov    0x4(%rsp),%eax
cmp    $0x64,%eax
mov    $0x64,%ecx
cmovl  %eax,%ecx
test   %ecx,%ecx
mov    $0x1,%r15d
cmovg  %ecx,%r15d
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0xc41(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
cmp    $0x33,%eax
mov    $0x32,%edx
cmovge %eax,%edx
lea    0xc4d(%rip),%rsi
mov    %r14,%rdi
call   1090 <fprintf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %ebx,%ebx
jmp    11c4 <main+0x34>

LLVM IR (-O0):
@.str = [49 x i8] c"You need to be a superuser to use this program.\0A\00"
@main.CONFIG_PATH = internal global i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0)
@.str.1 = [23 x i8] c"/etc/backlightctl.conf\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [6 x i8] c"%s\0A%s\00"
@.str.4 = [3 x i8] c"r+\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@.str.7 = [3 x i8] c"-h\00"
@.str.8 = [102 x i8] c"Usage: %s [[{+,-}]PERCENTAGE]\0A\09 when no parameters are given, the current percentage is printed out.\0A\00"
@.str.9 = [19 x i8] c"invalid parameter\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*
%9 = alloca [1024 x i8]
%10 = alloca [1024 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = call i64 (...) @getuid()
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32 5, i32* %3
br label %167
20: ; preds = %2
%21 = load i8*, i8** @main.CONFIG_PATH
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %22, i32** %6
%23 = load i32*, i32** %6
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 2, i32* %3
br label %167
26: ; preds = %20
%27 = load i32*, i32** %6
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%30 = call i32 (i32*, i8*, ...) @fscanf(i32* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %28, i8* %29)
%31 = load i32*, i32** %6
%32 = call i32 @fclose(i32* %31)
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %34, i32** %7
%35 = load i32*, i32** %7
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %38
37: ; preds = %26
store i32 3, i32* %3
br label %167
38: ; preds = %26
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%40 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %40, i32** %8
%41 = load i32*, i32** %8
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %44
43: ; preds = %38
store i32 4, i32* %3
br label %167
44: ; preds = %38
%45 = load i32*, i32** %7
%46 = call i32 (i32*, i8*, ...) @fscanf(i32* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %11)
%47 = load i32*, i32** %8
%48 = call i32 (i32*, i8*, ...) @fscanf(i32* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %12)
%49 = load i32*, i32** %8
%50 = call i32 @fclose(i32* %49)
%51 = load i32, i32* %11
%52 = sitofp i32 %51 to float
%53 = load i32, i32* %12
%54 = sitofp i32 %53 to float
%55 = fdiv float %52, %54
%56 = fpext float %55 to double
%57 = call double @llvm.fmuladd.f64(double %56, double 1.000000e+02, double 5.000000e-01)
%58 = fptosi double %57 to i32
store i32 %58, i32* %14
%59 = load i32, i32* %4
%60 = icmp slt i32 %59, 2
br i1 %60, label %61, label %64
61: ; preds = %44
%62 = load i32, i32* %14
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %62)
store i32 0, i32* %3
br label %167
64: ; preds = %44
%65 = load i32, i32* %4
%66 = icmp eq i32 %65, 2
br i1 %66, label %67, label %144
67: ; preds = %64
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 1
%70 = load i8*, i8** %69
%71 = call i64 @strcmp(i8* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %78
73: ; preds = %67
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 0
%76 = load i8*, i8** %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.8, i64 0, i64 0), i8* %76)
store i32 0, i32* %3
br label %167
78: ; preds = %67
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 1
%81 = load i8*, i8** %80
%82 = call i64 @sscanf(i8* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %13)
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %140
84: ; preds = %78
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 1
%87 = load i8*, i8** %86
%88 = getelementptr inbounds i8, i8* %87, i64 0
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
%91 = icmp eq i32 %90, 43
br i1 %91, label %92, label %103
92: ; preds = %84
%93 = load i32, i32* %13
%94 = load i32, i32* %14
%95 = add nsw i32 %94, %93
store i32 %95, i32* %14
%96 = load i32, i32* %14
%97 = icmp sgt i32 %96, 100
br i1 %97, label %98, label %99
98: ; preds = %92
br label %101
99: ; preds = %92
%100 = load i32, i32* %14
br label %101
101: ; preds = %99, %98
%102 = phi i32 [ 100, %98 ], [ %100, %99 ]
store i32 %102, i32* %14
br label %139
103: ; preds = %84
%104 = load i8**, i8*** %5
%105 = getelementptr inbounds i8*, i8** %104, i64 1
%106 = load i8*, i8** %105
%107 = getelementptr inbounds i8, i8* %106, i64 0
%108 = load i8, i8* %107
%109 = sext i8 %108 to i32
%110 = icmp eq i32 %109, 45
br i1 %110, label %111, label %122
111: ; preds = %103
%112 = load i32, i32* %13
%113 = load i32, i32* %14
%114 = add nsw i32 %113, %112
store i32 %114, i32* %14
%115 = load i32, i32* %14
%116 = icmp slt i32 %115, 1
br i1 %116, label %117, label %118
117: ; preds = %111
br label %120
118: ; preds = %111
%119 = load i32, i32* %14
br label %120
120: ; preds = %118, %117
%121 = phi i32 [ 1, %117 ], [ %119, %118 ]
store i32 %121, i32* %14
br label %138
122: ; preds = %103
%123 = load i32, i32* %13
store i32 %123, i32* %14
%124 = load i32, i32* %14
%125 = icmp sgt i32 %124, 100
br i1 %125, label %126, label %127
126: ; preds = %122
br label %129
127: ; preds = %122
%128 = load i32, i32* %14
br label %129
129: ; preds = %127, %126
%130 = phi i32 [ 100, %126 ], [ %128, %127 ]
store i32 %130, i32* %14
%131 = load i32, i32* %14
%132 = icmp slt i32 %131, 1
br i1 %132, label %133, label %134
133: ; preds = %129
br label %136
134: ; preds = %129
%135 = load i32, i32* %14
br label %136
136: ; preds = %134, %133
%137 = phi i32 [ 1, %133 ], [ %135, %134 ]
store i32 %137, i32* %14
br label %138
138: ; preds = %136, %120
br label %139
139: ; preds = %138, %101
br label %142
140: ; preds = %78
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %167
142: ; preds = %139
br label %143
143: ; preds = %142
br label %144
144: ; preds = %143, %64
br label %145
145: ; preds = %144
%146 = load i32, i32* %14
%147 = sitofp i32 %146 to float
%148 = fpext float %147 to double
%149 = fdiv double %148, 1.000000e+02
%150 = load i32, i32* %12
%151 = sitofp i32 %150 to float
%152 = fpext float %151 to double
%153 = fmul double %149, %152
%154 = fptosi double %153 to i32
store i32 %154, i32* %15
%155 = load i32, i32* %15
%156 = icmp slt i32 %155, 50
br i1 %156, label %157, label %158
157: ; preds = %145
br label %160
158: ; preds = %145
%159 = load i32, i32* %15
br label %160
160: ; preds = %158, %157
%161 = phi i32 [ 50, %157 ], [ %159, %158 ]
store i32 %161, i32* %15
%162 = load i32*, i32** %7
%163 = load i32, i32* %15
%164 = call i32 @fprintf(i32* %162, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %163)
%165 = load i32*, i32** %7
%166 = call i32 @fclose(i32* %165)
store i32 0, i32* %3
br label %167
167: ; preds = %160, %140, %73, %61, %43, %37, %25, %18
%168 = load i32, i32* %3
ret i32 %168
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c"/etc/backlightctl.conf\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [6 x i8] c"%s\0A%s\00"
@.str.4 = [3 x i8] c"r+\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@.str.7 = [3 x i8] c"-h\00"
@.str.8 = [102 x i8] c"Usage: %s [[{+,-}]PERCENTAGE]\0A\09 when no parameters are given, the current percentage is printed out.\0A\00"
@str = [18 x i8] c"invalid parameter\00"
@str.10 = [48 x i8] c"You need to be a superuser to use this program.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = tail call i64 (...) @getuid()
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.10, i64 0, i64 0))
br label %94
12: ; preds = %2
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%15 = bitcast i32* %5 to i8*
%16 = bitcast i32* %6 to i8*
%17 = bitcast i32* %7 to i8*
%18 = tail call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %92, label %20
20: ; preds = %12
%21 = call i32 (i32*, i8*, ...) @fscanf(i32* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %13, i8* %14)
%22 = call i32 @fclose(i32* %18)
%23 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %92, label %25
25: ; preds = %20
%26 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %92, label %28
28: ; preds = %25
%29 = call i32 (i32*, i8*, ...) @fscanf(i32* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %5)
%30 = call i32 (i32*, i8*, ...) @fscanf(i32* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %6)
%31 = call i32 @fclose(i32* %26)
%32 = load i32, i32* %5
%33 = sitofp i32 %32 to float
%34 = load i32, i32* %6
%35 = sitofp i32 %34 to float
%36 = fdiv float %33, %35
%37 = fpext float %36 to double
%38 = call double @llvm.fmuladd.f64(double %37, double 1.000000e+02, double 5.000000e-01)
%39 = fptosi double %38 to i32
%40 = icmp slt i32 %0, 2
br i1 %40, label %41, label %43
41: ; preds = %28
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %39)
br label %92
43: ; preds = %28
%44 = icmp eq i32 %0, 2
br i1 %44, label %45, label %78
45: ; preds = %43
%46 = getelementptr inbounds i8*, i8** %1, i64 1
%47 = load i8*, i8** %46
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %45
%51 = load i8*, i8** %1
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([102 x i8], [102 x i8]* @.str.8, i64 0, i64 0), i8* %51)
br label %92
53: ; preds = %45
%54 = load i8*, i8** %46
%55 = call i64 @sscanf(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %7)
%56 = icmp eq i64 %55, 0
br i1 %56, label %76, label %57
57: ; preds = %53
%58 = load i8*, i8** %46
%59 = load i8, i8* %58
switch i8 %59, label %70 [
i8 43, label %60
i8 45, label %65
]
60: ; preds = %57
%61 = load i32, i32* %7
%62 = add nsw i32 %61, %39
%63 = icmp slt i32 %62, 100
%64 = select i1 %63, i32 %62, i32 100
br label %78
65: ; preds = %57
%66 = load i32, i32* %7
%67 = add nsw i32 %66, %39
%68 = icmp sgt i32 %67, 1
%69 = select i1 %68, i32 %67, i32 1
br label %78
70: ; preds = %57
%71 = load i32, i32* %7
%72 = icmp slt i32 %71, 100
%73 = select i1 %72, i32 %71, i32 100
%74 = icmp sgt i32 %73, 1
%75 = select i1 %74, i32 %73, i32 1
br label %78
76: ; preds = %53
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %92
78: ; preds = %43, %65, %70, %60
%79 = phi i32 [ %64, %60 ], [ %69, %65 ], [ %75, %70 ], [ %39, %43 ]
%80 = sitofp i32 %79 to float
%81 = fpext float %80 to double
%82 = fdiv double %81, 1.000000e+02
%83 = load i32, i32* %6
%84 = sitofp i32 %83 to float
%85 = fpext float %84 to double
%86 = fmul double %82, %85
%87 = fptosi double %86 to i32
%88 = icmp sgt i32 %87, 50
%89 = select i1 %88, i32 %87, i32 50
%90 = call i32 @fprintf(i32* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %89)
%91 = call i32 @fclose(i32* %23)
br label %92
92: ; preds = %25, %20, %12, %78, %76, %50, %41
%93 = phi i32 [ 0, %41 ], [ 0, %50 ], [ 0, %78 ], [ 1, %76 ], [ 2, %12 ], [ 3, %20 ], [ 4, %25 ]
br label %94
94: ; preds = %92, %10
%95 = phi i32 [ 5, %10 ], [ %93, %92 ]
ret i32 %95
}