#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int /*<<< orphan*/ usage(int /*<<< orphan*/, int, char **);
int main(int argc, char *argv[]) {
  int value, err;
  FILE *fh;
  if (argc < 2) {
    fprintf(stderr, "Command line option missing\n\n");
    usage(stderr, argc, argv);
    return EXIT_FAILURE;
  }
  if (sscanf(argv[1], "%d", &value) != 1) {
    fprintf(stderr, "Command line option missing\n\n");
    usage(stderr, argc, argv);
    return EXIT_FAILURE;
  }
  if ((fh = fopen("/sys/class/backlight/intel_backlight/brightness", "w")) ==
      NULL) {
    err = errno;
    fprintf(stderr, "Can't open %s: %s (%d)\n",
            "/sys/class/backlight/intel_backlight/brightness", strerror(err),
            err);
    return EXIT_FAILURE;
  }
  fprintf(fh, "%d\n", value);
  fclose(fh);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11be <main+0x5e>
mov    0x2e59(%rip),%rax
movslq (%rax),%rdi
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1060 <usage@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12bb <main+0x15b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe51(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     121d <main+0xbd>
mov    0x2dfa(%rip),%rax
movslq (%rax),%rdi
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1060 <usage@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12bb <main+0x15b>
lea    0xdfd(%rip),%rdi
lea    0xe26(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1291 <main+0x131>
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d8f(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%edi
call   1080 <strerror@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rcx
mov    -0x18(%rbp),%r8d
lea    0xde1(%rip),%rsi
lea    0xda8(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12bb <main+0x15b>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2d12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x1,%edi
jle    11dd <main+0x6d>
mov    0x8(%rbx),%rdi
lea    0xe91(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    11dd <main+0x6d>
lea    0xe7e(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     121c <main+0xac>
mov    %rax,%rbx
mov    0xc(%rsp),%edx
lea    0xea9(%rip),%rsi
mov    %rax,%rdi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2ded(%rip),%rax
jmp    1211 <main+0xa1>
mov    0x2dfc(%rip),%r14
movslq (%r14),%rcx
lea    0xe12(%rip),%rdi
mov    $0x1d,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    (%r14),%edi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1060 <usage@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2db5(%rip),%rax
mov    (%rax),%ebx
mov    0x2db4(%rip),%rax
movslq (%rax),%rbp
mov    %ebx,%edi
call   1090 <strerror@plt>
lea    0xe16(%rip),%rsi
lea    0xddd(%rip),%rdx
mov    %rbp,%rdi
mov    %rax,%rcx
mov    %ebx,%r8d
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    120a <main+0x9a>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Command line option missing\0A\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [48 x i8] c"/sys/class/backlight/intel_backlight/brightness\00"
@.str.3 = [2 x i8] c"w\00"
@errno = global i32 0
@.str.4 = [24 x i8] c"Can't open %s: %s (%d)\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
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 %11, label %21
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i32*
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @stderr
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call i32 @usage(i32 %16, i32 %17, i8** %18)
%20 = load i32, i32* @EXIT_FAILURE
store i32 %20, i32* %3
br label %57
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%26 = icmp ne i32 %25, 1
br i1 %26, label %27, label %37
27: ; preds = %21
%28 = load i32, i32* @stderr
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i32*
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%32 = load i32, i32* @stderr
%33 = load i32, i32* %4
%34 = load i8**, i8*** %5
%35 = call i32 @usage(i32 %32, i32 %33, i8** %34)
%36 = load i32, i32* @EXIT_FAILURE
store i32 %36, i32* %3
br label %57
37: ; preds = %21
%38 = call i32* @fopen(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %38, i32** %8
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %50
40: ; preds = %37
%41 = load i32, i32* @errno
store i32 %41, i32* %7
%42 = load i32, i32* @stderr
%43 = sext i32 %42 to i64
%44 = inttoptr i64 %43 to i32*
%45 = load i32, i32* %7
%46 = call i8* @strerror(i32 %45)
%47 = load i32, i32* %7
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %44, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %46, i32 %47)
%49 = load i32, i32* @EXIT_FAILURE
store i32 %49, i32* %3
br label %57
50: ; preds = %37
%51 = load i32*, i32** %8
%52 = load i32, i32* %6
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %52)
%54 = load i32*, i32** %8
%55 = call i32 @fclose(i32* %54)
%56 = load i32, i32* @EXIT_SUCCESS
store i32 %56, i32* %3
br label %57
57: ; preds = %50, %40, %27, %11
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Command line option missing\0A\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [48 x i8] c"/sys/class/backlight/intel_backlight/brightness\00"
@.str.3 = [2 x i8] c"w\00"
@errno = global i32 0
@.str.4 = [24 x i8] c"Can't open %s: %s (%d)\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 29, i64 1, i32* %9)
%11 = load i32, i32* @stderr
%12 = tail call i32 @usage(i32 %11, i32 %0, i8** %1)
br label %39
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%17 = icmp eq i32 %16, 1
br i1 %17, label %25, label %18
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = sext i32 %19 to i64
%21 = inttoptr i64 %20 to i32*
%22 = call i64 @fwrite(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 29, i64 1, i32* %21)
%23 = load i32, i32* @stderr
%24 = call i32 @usage(i32 %23, i32 %0, i8** %1)
br label %39
25: ; preds = %13
%26 = call i32* @fopen(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = load i32, i32* @errno
%30 = load i32, i32* @stderr
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i32*
%33 = call i8* @strerror(i32 %29)
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %33, i32 %29)
br label %39
35: ; preds = %25
%36 = load i32, i32* %3
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = call i32 @fclose(i32* %26)
br label %39
39: ; preds = %35, %28, %18, %6
%40 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_FAILURE, %18 ], [ @EXIT_FAILURE, %28 ], [ @EXIT_SUCCESS, %35 ]
%41 = load i32, i32* %40
ret i32 %41
}