#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 atoi(char const *);
char *om_sysfs_swap(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int om_screen_brightness_swap(int val) {
  char sval[20];
  snprintf(sval, 20, "%d", val);
  const char *res = om_sysfs_swap("brightness", sval);
  if (res == NULL)
    return -1;
  return atoi(res);
}


x86 assembly (clang, -O0):
<om_screen_brightness_swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    $0x14,%esi
lea    0xeb2(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x20(%rbp),%rsi
lea    0xea5(%rip),%rdi
call   1040 <om_sysfs_swap@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117e <om_screen_brightness_swap+0x4e>
movl   $0xffffffff,-0x4(%rbp)
jmp    118a <om_screen_brightness_swap+0x5a>
mov    -0x28(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<om_screen_brightness_swap>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ecx
lea    0xec2(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1030 <snprintf@plt>
lea    0xeae(%rip),%rdi
mov    %rbx,%rsi
call   1040 <om_sysfs_swap@plt>
test   %rax,%rax
je     116c <om_screen_brightness_swap+0x3c>
mov    %rax,%rdi
call   1050 <atoi@plt>
jmp    1171 <om_screen_brightness_swap+0x41>
mov    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [11 x i8] c"brightness\00"
define i32 @om_screen_brightness_swap(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = alloca i8*
store i32 %0, i32* %3
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* %3
%8 = call i32 @snprintf(i8* %6, i32 20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%10 = call i8* @om_sysfs_swap(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %9)
store i8* %10, i8** %5
%11 = load i8*, i8** %5
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %1
store i32 -1, i32* %2
br label %17
14: ; preds = %1
%15 = load i8*, i8** %5
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %2
br label %17
17: ; preds = %14, %13
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [11 x i8] c"brightness\00"
define i32 @om_screen_brightness_swap(i32 %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = call i32 @snprintf(i8* %3, i32 20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = call i8* @om_sysfs_swap(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%6 = icmp eq i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @atoi(i8* %5)
br label %9
9: ; preds = %1, %7
%10 = phi i32 [ %8, %7 ], [ -1, %1 ]
ret i32 %10
}