#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 O_APPEND;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dprintf(int, char *, int);
int open(char *, int);
void setGraphValue(char *dev, int pourcentage) {
  int fd;
  int value;
  fd = open(dev, O_WRONLY | O_APPEND);
  if (fd > 0) {
    value = pourcentage * 255 / 100;
    dprintf(fd, "%d", value);
    close(fd);
  }
}


x86 assembly (clang, -O0):
<setGraphValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e8e(%rip),%rax
mov    (%rax),%esi
mov    0x2e7d(%rip),%rax
or     (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1193 <setGraphValue+0x63>
imul   $0xff,-0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%edx
lea    0xe7a(%rip),%rsi
call   1040 <dprintf@plt>
mov    -0x10(%rbp),%edi
call   1030 <close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setGraphValue>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    0x2e9c(%rip),%rax
mov    0x2e8d(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
call   1050 <open@plt>
test   %eax,%eax
jle    118a <setGraphValue+0x5a>
mov    %eax,%ebx
mov    %ebp,%eax
shl    $0x8,%eax
sub    %ebp,%eax
cltq
imul   $0x51eb851f,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x25,%rdx
add    %eax,%edx
lea    0xe8a(%rip),%rsi
mov    %ebx,%edi
call   1040 <dprintf@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <close@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@O_WRONLY = global i32 0
@O_APPEND = global i32 0
@.str = [3 x i8] c"%d\00"
define void @setGraphValue(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = load i32, i32* @O_WRONLY
%9 = load i32, i32* @O_APPEND
%10 = or i32 %8, %9
%11 = call i32 @open(i8* %7, i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %23
14: ; preds = %2
%15 = load i32, i32* %4
%16 = mul nsw i32 %15, 255
%17 = sdiv i32 %16, 100
store i32 %17, i32* %6
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call i32 @dprintf(i32 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %5
%22 = call i32 @close(i32 %21)
br label %23
23: ; preds = %14, %2
ret void
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
@O_APPEND = global i32 0
@.str = [3 x i8] c"%d\00"
define void @setGraphValue(i8* nocapture %0, i32 %1) {
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_APPEND
%5 = or i32 %4, %3
%6 = tail call i32 @open(i8* %0, i32 %5)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = mul nsw i32 %1, 255
%10 = sdiv i32 %9, 100
%11 = tail call i32 @dprintf(i32 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = tail call i32 @close(i32 %6)
br label %13
13: ; preds = %8, %2
ret void
}