#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 *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int strtol(char *, char **, int);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int current, change, next, maxval;
  FILE *file;
  if (argc < 2) {
    usage();
  }
  if (!(file = fopen("/sys/class/leds/smc::kbd_backlight"
                     "/brightness",
                     "r"))) {
    perror("failed to open the keyboard backlight file: "
           "/sys/class/leds/smc::kbd_backlight"
           "/brightness");
    return 1;
  }
  fscanf(file, "%d", &current);
  fclose(file);
  if ((file = fopen("/sys/class/leds/smc::kbd_backlight"
                    "/max_brightness",
                    "r"))) {
    fscanf(file, "%d", &maxval);
    fclose(file);
  } else {
    maxval = 255;
  }
  if (!strcmp(argv[1], "up") || !strcmp(argv[1], "down")) {
    if (argv[2]) {
      char *endp;
      change = strtol(argv[2], &endp, 10);
      if (endp == argv[2]) {
        fprintf(stderr, "percentage must be a number from 0 to 100.\n");
        return 1;
      }
      change = change * 0.01 * maxval;
    } else {
      change = 16;
    }
  }
  if (!strcmp(argv[1], "up"))
    next = current >= maxval - change ? maxval : current + change;
  else if (!strcmp(argv[1], "down"))
    next = current <= change ? 0 : current - change;
  else if (!strcmp(argv[1], "off"))
    next = 0;
  else if (!strcmp(argv[1], "max"))
    next = maxval;
  else if (!strcmp(argv[1], "set")) {
    char *endp;
    if (!argv[2] || (next = strtol(argv[2], &endp, 10), endp == argv[2])) {
      fprintf(stderr, "set must be followed by a number from 0 to %d\n",
              maxval);
      return 1;
    }
  } else if (!strcmp(argv[1], "get")) {
    printf("%d\n", current);
    return 0;
  } else
    usage();
  if ((file = fopen("/sys/class/leds/smc::kbd_backlight"
                    "/brightness",
                    "w"))) {
    fprintf(file, "%d", next);
    fclose(file);
  } else {
    perror("failed to write to the keyboard backlight file: "
           "/sys/class/leds/smc::kbd_backlight"
           "/brightness");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b7 <main+0x27>
mov    $0x0,%al
call   1090 <usage@plt>
lea    0xe78(%rip),%rdi
lea    0xe43(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11f0 <main+0x60>
lea    0xe2b(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1538 <main+0x3a8>
mov    -0x28(%rbp),%rdi
lea    0xe69(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe53(%rip),%rdi
lea    0xded(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1250 <main+0xc0>
mov    -0x28(%rbp),%rdi
lea    0xe2b(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1257 <main+0xc7>
movl   $0xff,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe33(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     1291 <main+0x101>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe19(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1321 <main+0x191>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1315 <main+0x185>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    0x10(%rcx),%rax
jne    12ef <main+0x15f>
mov    0x2d0e(%rip),%rax
mov    (%rax),%rdi
lea    0xdc5(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1538 <main+0x3a8>
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xd04(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
jmp    131c <main+0x18c>
movl   $0x10,-0x18(%rbp)
jmp    1321 <main+0x191>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd69(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    136e <main+0x1de>
mov    -0x14(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jl     135a <main+0x1ca>
mov    -0x20(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    1363 <main+0x1d3>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    14e1 <main+0x351>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd1f(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    13b5 <main+0x225>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     13a1 <main+0x211>
xor    %eax,%eax
mov    %eax,-0x40(%rbp)
jmp    13aa <main+0x21a>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    14dc <main+0x34c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd09(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    13de <main+0x24e>
movl   $0x0,-0x1c(%rbp)
jmp    14d7 <main+0x347>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xce4(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1406 <main+0x276>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    14d2 <main+0x342>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcc0(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1489 <main+0x2f9>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     145d <main+0x2cd>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    0x10(%rcx),%rax
jne    1484 <main+0x2f4>
mov    0x2b7c(%rip),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%edx
lea    0xc68(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1538 <main+0x3a8>
jmp    14cd <main+0x33d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc70(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    14c1 <main+0x331>
mov    -0x14(%rbp),%esi
lea    0xc54(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1538 <main+0x3a8>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    14cd <main+0x33d>
jmp    14d2 <main+0x342>
jmp    14d7 <main+0x347>
jmp    14dc <main+0x34c>
jmp    14e1 <main+0x351>
lea    0xb4e(%rip),%rdi
lea    0xc1d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1525 <main+0x395>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xb54(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1531 <main+0x3a1>
lea    0xbe2(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
cmp    $0x1,%edi
jg     11b9 <main+0x19>
xor    %eax,%eax
call   1090 <usage@plt>
lea    0xe76(%rip),%rdi
lea    0xe41(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     13de <main+0x23e>
mov    %rax,%rbx
lea    0xe85(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe6c(%rip),%rdi
lea    0xe06(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     122d <main+0x8d>
mov    %rax,%rbx
lea    0xe4e(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    1235 <main+0x95>
movl   $0xff,0x8(%rsp)
mov    0x8(%r14),%rbx
lea    0xe59(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1261 <main+0xc1>
lea    0xe49(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1261 <main+0xc1>
jmp    12af <main+0x10f>
mov    0x10(%r14),%rdi
test   %rdi,%rdi
je     12a9 <main+0x109>
lea    0x10(%rsp),%rsi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    0x10(%rsp),%rcx
cmp    0x10(%r14),%rcx
je     1363 <main+0x1c3>
cvtsi2sd %eax,%xmm0
mulsd  0xd6c(%rip),%xmm0
cvtsi2sdl 0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%r15d
mov    0x8(%r14),%rbx
jmp    12af <main+0x10f>
mov    $0x10,%r15d
lea    0xde3(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     133a <main+0x19a>
lea    0xdd3(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1352 <main+0x1b2>
lea    0xdf1(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     138a <main+0x1ea>
lea    0xdde(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     138f <main+0x1ef>
lea    0xdcb(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     13f1 <main+0x251>
lea    0xde7(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     144c <main+0x2ac>
xor    %eax,%eax
call   1090 <usage@plt>
jmp    1394 <main+0x1f4>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ecx
mov    %ecx,%edx
sub    %r15d,%edx
add    %eax,%r15d
cmp    %edx,%eax
cmovge %ecx,%r15d
jmp    1394 <main+0x1f4>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
sub    %r15d,%eax
cmovle %ecx,%eax
mov    %eax,%r15d
jmp    1394 <main+0x1f4>
mov    0x2c76(%rip),%rax
mov    (%rax),%rcx
lea    0xd2d(%rip),%rdi
mov    $0x2b,%esi
mov    $0x1,%edx
call   10c0 <fwrite@plt>
mov    $0x1,%ebx
jmp    13d1 <main+0x231>
xor    %r15d,%r15d
jmp    1394 <main+0x1f4>
mov    0x8(%rsp),%r15d
lea    0xc9b(%rip),%rdi
lea    0xd6a(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     143e <main+0x29e>
mov    %rax,%rbp
lea    0xcaa(%rip),%rsi
xor    %ebx,%ebx
mov    %rax,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc25(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%ebx
jmp    13d1 <main+0x231>
mov    0x10(%r14),%rdi
test   %rdi,%rdi
je     141b <main+0x27b>
lea    0x10(%rsp),%rsi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,%r15d
mov    0x10(%rsp),%rax
cmp    0x10(%r14),%rax
jne    1394 <main+0x1f4>
mov    0x2bbe(%rip),%rax
mov    (%rax),%rdi
mov    0x8(%rsp),%edx
lea    0xca9(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%ebx
jmp    13d1 <main+0x231>
lea    0xcc9(%rip),%rdi
call   10b0 <perror@plt>
jmp    145c <main+0x2bc>
mov    0xc(%rsp),%esi
lea    0xcad(%rip),%rdi
call   1040 <printf@plt>
xor    %ebx,%ebx
jmp    13d1 <main+0x231>

LLVM IR (-O0):
@.str = [46 x i8] c"/sys/class/leds/smc::kbd_backlight/brightness\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [90 x i8] c"failed to open the keyboard backlight file: /sys/class/leds/smc::kbd_backlight/brightness\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [50 x i8] c"/sys/class/leds/smc::kbd_backlight/max_brightness\00"
@.str.5 = [3 x i8] c"up\00"
@.str.6 = [5 x i8] c"down\00"
@stderr = global i32* null
@.str.7 = [44 x i8] c"percentage must be a number from 0 to 100.\0A\00"
@.str.8 = [4 x i8] c"off\00"
@.str.9 = [4 x i8] c"max\00"
@.str.10 = [4 x i8] c"set\00"
@.str.11 = [47 x i8] c"set must be followed by a number from 0 to %d\0A\00"
@.str.12 = [4 x i8] c"get\00"
@.str.13 = [4 x i8] c"%d\0A\00"
@.str.14 = [2 x i8] c"w\00"
@.str.15 = [94 x i8] c"failed to write to the keyboard backlight file: /sys/class/leds/smc::kbd_backlight/brightness\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 i32
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (...) @usage()
br label %17
17: ; preds = %15, %2
%18 = call i32* @fopen(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %10
%19 = icmp ne i32* %18, null
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 @perror(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %181
22: ; preds = %17
%23 = load i32*, i32** %10
%24 = call i32 @fscanf(i32* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%25 = load i32*, i32** %10
%26 = call i32 @fclose(i32* %25)
%27 = call i32* @fopen(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %10
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %34
29: ; preds = %22
%30 = load i32*, i32** %10
%31 = call i32 @fscanf(i32* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%32 = load i32*, i32** %10
%33 = call i32 @fclose(i32* %32)
br label %35
34: ; preds = %22
store i32 255, i32* %9
br label %35
35: ; preds = %34, %29
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %35
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i32 @strcmp(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%46 = icmp ne i32 %45, 0
br i1 %46, label %75, label %47
47: ; preds = %41, %35
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %73
52: ; preds = %47
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = call i32 @strtol(i8* %55, i8** %11, i32 10)
store i32 %56, i32* %7
%57 = load i8*, i8** %11
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 2
%60 = load i8*, i8** %59
%61 = icmp eq i8* %57, %60
br i1 %61, label %62, label %65
62: ; preds = %52
%63 = load i32*, i32** @stderr
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %181
65: ; preds = %52
%66 = load i32, i32* %7
%67 = sitofp i32 %66 to double
%68 = fmul double %67, 1.000000e-02
%69 = load i32, i32* %9
%70 = sitofp i32 %69 to double
%71 = fmul double %68, %70
%72 = fptosi double %71 to i32
store i32 %72, i32* %7
br label %74
73: ; preds = %47
store i32 16, i32* %7
br label %74
74: ; preds = %73, %65
br label %75
75: ; preds = %74, %41
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 1
%78 = load i8*, i8** %77
%79 = call i32 @strcmp(i8* %78, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%80 = icmp ne i32 %79, 0
br i1 %80, label %95, label %81
81: ; preds = %75
%82 = load i32, i32* %6
%83 = load i32, i32* %9
%84 = load i32, i32* %7
%85 = sub nsw i32 %83, %84
%86 = icmp sge i32 %82, %85
br i1 %86, label %87, label %89
87: ; preds = %81
%88 = load i32, i32* %9
br label %93
89: ; preds = %81
%90 = load i32, i32* %6
%91 = load i32, i32* %7
%92 = add nsw i32 %90, %91
br label %93
93: ; preds = %89, %87
%94 = phi i32 [ %88, %87 ], [ %92, %89 ]
store i32 %94, i32* %8
br label %169
95: ; preds = %75
%96 = load i8**, i8*** %5
%97 = getelementptr inbounds i8*, i8** %96, i64 1
%98 = load i8*, i8** %97
%99 = call i32 @strcmp(i8* %98, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%100 = icmp ne i32 %99, 0
br i1 %100, label %112, label %101
101: ; preds = %95
%102 = load i32, i32* %6
%103 = load i32, i32* %7
%104 = icmp sle i32 %102, %103
br i1 %104, label %105, label %106
105: ; preds = %101
br label %110
106: ; preds = %101
%107 = load i32, i32* %6
%108 = load i32, i32* %7
%109 = sub nsw i32 %107, %108
br label %110
110: ; preds = %106, %105
%111 = phi i32 [ 0, %105 ], [ %109, %106 ]
store i32 %111, i32* %8
br label %168
112: ; preds = %95
%113 = load i8**, i8*** %5
%114 = getelementptr inbounds i8*, i8** %113, i64 1
%115 = load i8*, i8** %114
%116 = call i32 @strcmp(i8* %115, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%117 = icmp ne i32 %116, 0
br i1 %117, label %119, label %118
118: ; preds = %112
store i32 0, i32* %8
br label %167
119: ; preds = %112
%120 = load i8**, i8*** %5
%121 = getelementptr inbounds i8*, i8** %120, i64 1
%122 = load i8*, i8** %121
%123 = call i32 @strcmp(i8* %122, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%124 = icmp ne i32 %123, 0
br i1 %124, label %127, label %125
125: ; preds = %119
%126 = load i32, i32* %9
store i32 %126, i32* %8
br label %166
127: ; preds = %119
%128 = load i8**, i8*** %5
%129 = getelementptr inbounds i8*, i8** %128, i64 1
%130 = load i8*, i8** %129
%131 = call i32 @strcmp(i8* %130, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%132 = icmp ne i32 %131, 0
br i1 %132, label %153, label %133
133: ; preds = %127
%134 = load i8**, i8*** %5
%135 = getelementptr inbounds i8*, i8** %134, i64 2
%136 = load i8*, i8** %135
%137 = icmp ne i8* %136, null
br i1 %137, label %138, label %148
138: ; preds = %133
%139 = load i8**, i8*** %5
%140 = getelementptr inbounds i8*, i8** %139, i64 2
%141 = load i8*, i8** %140
%142 = call i32 @strtol(i8* %141, i8** %12, i32 10)
store i32 %142, i32* %8
%143 = load i8*, i8** %12
%144 = load i8**, i8*** %5
%145 = getelementptr inbounds i8*, i8** %144, i64 2
%146 = load i8*, i8** %145
%147 = icmp eq i8* %143, %146
br i1 %147, label %148, label %152
148: ; preds = %138, %133
%149 = load i32*, i32** @stderr
%150 = load i32, i32* %9
%151 = call i32 (i32*, i8*, ...) @fprintf(i32* %149, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.11, i64 0, i64 0), i32 %150)
store i32 1, i32* %3
br label %181
152: ; preds = %138
br label %165
153: ; preds = %127
%154 = load i8**, i8*** %5
%155 = getelementptr inbounds i8*, i8** %154, i64 1
%156 = load i8*, i8** %155
%157 = call i32 @strcmp(i8* %156, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%158 = icmp ne i32 %157, 0
br i1 %158, label %162, label %159
159: ; preds = %153
%160 = load i32, i32* %6
%161 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %160)
store i32 0, i32* %3
br label %181
162: ; preds = %153
%163 = call i32 (...) @usage()
br label %164
164: ; preds = %162
br label %165
165: ; preds = %164, %152
br label %166
166: ; preds = %165, %125
br label %167
167: ; preds = %166, %118
br label %168
168: ; preds = %167, %110
br label %169
169: ; preds = %168, %93
%170 = call i32* @fopen(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i32* %170, i32** %10
%171 = icmp ne i32* %170, null
br i1 %171, label %172, label %178
172: ; preds = %169
%173 = load i32*, i32** %10
%174 = load i32, i32* %8
%175 = call i32 (i32*, i8*, ...) @fprintf(i32* %173, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %174)
%176 = load i32*, i32** %10
%177 = call i32 @fclose(i32* %176)
br label %180
178: ; preds = %169
%179 = call i32 @perror(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.15, i64 0, i64 0))
br label %180
180: ; preds = %178, %172
store i32 0, i32* %3
br label %181
181: ; preds = %180, %159, %148, %62, %20
%182 = load i32, i32* %3
ret i32 %182
}

LLVM IR (-O2):
@.str = [46 x i8] c"/sys/class/leds/smc::kbd_backlight/brightness\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [90 x i8] c"failed to open the keyboard backlight file: /sys/class/leds/smc::kbd_backlight/brightness\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [50 x i8] c"/sys/class/leds/smc::kbd_backlight/max_brightness\00"
@.str.5 = [3 x i8] c"up\00"
@.str.6 = [5 x i8] c"down\00"
@stderr = global i32* null
@.str.7 = [44 x i8] c"percentage must be a number from 0 to 100.\0A\00"
@.str.8 = [4 x i8] c"off\00"
@.str.9 = [4 x i8] c"max\00"
@.str.10 = [4 x i8] c"set\00"
@.str.11 = [47 x i8] c"set must be followed by a number from 0 to %d\0A\00"
@.str.12 = [4 x i8] c"get\00"
@.str.13 = [4 x i8] c"%d\0A\00"
@.str.14 = [2 x i8] c"w\00"
@.str.15 = [94 x i8] c"failed to write to the keyboard backlight file: /sys/class/leds/smc::kbd_backlight/brightness\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = icmp slt i32 %0, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 (...) @usage()
br label %12
12: ; preds = %10, %2
%13 = tail call i32* @fopen(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @perror(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.2, i64 0, i64 0))
br label %118
17: ; preds = %12
%18 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%19 = call i32 @fclose(i32* %13)
%20 = call i32* @fopen(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = call i32 @fscanf(i32* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%24 = call i32 @fclose(i32* %20)
br label %26
25: ; preds = %17
store i32 255, i32* %4
br label %26
26: ; preds = %25, %22
%27 = getelementptr inbounds i8*, i8** %1, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @strcmp(i8* dereferenceable(1) %28, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %26
%32 = call i32 @strcmp(i8* dereferenceable(1) %28, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %55
34: ; preds = %31, %26
%35 = getelementptr inbounds i8*, i8** %1, i64 2
%36 = load i8*, i8** %35
%37 = icmp eq i8* %36, null
br i1 %37, label %55, label %38
38: ; preds = %34
%39 = bitcast i8** %5 to i8*
%40 = call i32 @strtol(i8* %36, i8** %5, i32 10)
%41 = load i8*, i8** %5
%42 = load i8*, i8** %35
%43 = icmp eq i8* %41, %42
br i1 %43, label %44, label %47
44: ; preds = %38
%45 = load i32*, i32** @stderr
%46 = call i64 @fwrite(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i64 43, i64 1, i32* %45)
br label %118
47: ; preds = %38
%48 = sitofp i32 %40 to double
%49 = fmul double %48, 1.000000e-02
%50 = load i32, i32* %4
%51 = sitofp i32 %50 to double
%52 = fmul double %49, %51
%53 = fptosi double %52 to i32
%54 = load i8*, i8** %27
br label %55
55: ; preds = %47, %34, %31
%56 = phi i8* [ %28, %31 ], [ %54, %47 ], [ %28, %34 ]
%57 = phi i32 [ undef, %31 ], [ %53, %47 ], [ 16, %34 ]
%58 = call i32 @strcmp(i8* dereferenceable(1) %56, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %67
60: ; preds = %55
%61 = load i32, i32* %3
%62 = load i32, i32* %4
%63 = sub nsw i32 %62, %57
%64 = icmp slt i32 %61, %63
%65 = add nsw i32 %61, %57
%66 = select i1 %64, i32 %65, i32 %62
br label %109
67: ; preds = %55
%68 = call i32 @strcmp(i8* dereferenceable(1) %56, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %75
70: ; preds = %67
%71 = load i32, i32* %3
%72 = icmp sgt i32 %71, %57
%73 = sub nsw i32 %71, %57
%74 = select i1 %72, i32 %73, i32 0
br label %109
75: ; preds = %67
%76 = call i32 @strcmp(i8* dereferenceable(1) %56, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%77 = icmp eq i32 %76, 0
br i1 %77, label %109, label %78
78: ; preds = %75
%79 = call i32 @strcmp(i8* dereferenceable(1) %56, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = load i32, i32* %4
br label %109
83: ; preds = %78
%84 = call i32 @strcmp(i8* dereferenceable(1) %56, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %101
86: ; preds = %83
%87 = bitcast i8** %6 to i8*
%88 = getelementptr inbounds i8*, i8** %1, i64 2
%89 = load i8*, i8** %88
%90 = icmp eq i8* %89, null
br i1 %90, label %97, label %91
91: ; preds = %86
%92 = call i32 @strtol(i8* %89, i8** %6, i32 10)
%93 = load i8*, i8** %6
%94 = load i8*, i8** %88
%95 = icmp eq i8* %93, %94
br i1 %95, label %97, label %96
96: ; preds = %91
br label %109
97: ; preds = %86, %91
%98 = load i32*, i32** @stderr
%99 = load i32, i32* %4
%100 = call i32 (i32*, i8*, ...) @fprintf(i32* %98, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.11, i64 0, i64 0), i32 %99)
br label %118
101: ; preds = %83
%102 = call i32 @strcmp(i8* dereferenceable(1) %56, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%103 = icmp eq i32 %102, 0
br i1 %103, label %104, label %107
104: ; preds = %101
%105 = load i32, i32* %3
%106 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %105)
br label %118
107: ; preds = %101
%108 = call i32 (...) @usage()
br label %109
109: ; preds = %96, %75, %70, %81, %107, %60
%110 = phi i32 [ undef, %107 ], [ %82, %81 ], [ %74, %70 ], [ %66, %60 ], [ 0, %75 ], [ %92, %96 ]
%111 = call i32* @fopen(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%112 = icmp eq i32* %111, null
br i1 %112, label %116, label %113
113: ; preds = %109
%114 = call i32 (i32*, i8*, ...) @fprintf(i32* %111, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %110)
%115 = call i32 @fclose(i32* %111)
br label %118
116: ; preds = %109
%117 = call i32 @perror(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.15, i64 0, i64 0))
br label %118
118: ; preds = %97, %44, %113, %116, %104, %15
%119 = phi i32 [ 0, %104 ], [ 1, %97 ], [ 1, %15 ], [ 0, %116 ], [ 0, %113 ], [ 1, %44 ]
ret i32 %119
}