#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*/ O_RDWR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fsync(int);
int open(char *, int /*<<< orphan*/);
int sprintf(char *, char *, int, int);
int /*<<< orphan*/ write(int, char *, int);
int driver_set_operation(char *drv, int op, int val) {
  int sim_fd = open("/sys/devices/platform/brtablet/operation", O_RDWR);
  char buff[50];
  int s = sprintf(buff, "%d %d", op, val);
  write(sim_fd, buff, s);
  fsync(sim_fd);
  close(sim_fd);
}


x86 assembly (clang, -O0):
<driver_set_operation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
lea    0xe8e(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe9e(%rip),%rsi
call   1070 <sprintf@plt>
mov    %eax,-0x54(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%edx
call   1030 <write@plt>
mov    -0x1c(%rbp),%edi
call   1050 <fsync@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<driver_set_operation>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
lea    0xe91(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
lea    0xeac(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1070 <sprintf@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1050 <fsync@plt>
mov    %ebx,%edi
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <close@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"/sys/devices/platform/brtablet/operation\00"
@O_RDWR = global i32 0
@.str.1 = [6 x i8] c"%d %d\00"
define i32 @driver_set_operation(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [50 x i8]
%10 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%11 = load i32, i32* @O_RDWR
%12 = call i32 @open(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 %12, i32* %8
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %15)
store i32 %16, i32* %10
%17 = load i32, i32* %8
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%19 = load i32, i32* %10
%20 = call i32 @write(i32 %17, i8* %18, i32 %19)
%21 = load i32, i32* %8
%22 = call i32 @fsync(i32 %21)
%23 = load i32, i32* %8
%24 = call i32 @close(i32 %23)
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
@.str = [41 x i8] c"/sys/devices/platform/brtablet/operation\00"
@O_RDWR = global i32 0
@.str.1 = [6 x i8] c"%d %d\00"
define i32 @driver_set_operation(i8* nocapture readnone %0, i32 %1, i32 %2) {
%4 = alloca [50 x i8]
%5 = load i32, i32* @O_RDWR
%6 = tail call i32 @open(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%8 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2)
%9 = call i32 @write(i32 %6, i8* %7, i32 %8)
%10 = tail call i32 @fsync(i32 %6)
%11 = tail call i32 @close(i32 %6)
ret i32 undef
}