#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_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ ioctl(int, unsigned long, char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
void send_read_write_ioctlcmd(unsigned long ioctlcmd, char *buffer) {
  int fd;
  fd = open("/proc/parallelled", O_RDONLY);
  if (!fd) {
    printf("/proc/parallelled is not available\n");
    exit(-1);
  }
  ioctl(fd, ioctlcmd, buffer);
  close(fd);
}


x86 assembly (clang, -O0):
<send_read_write_ioctlcmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
lea    0xe90(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1198 <send_read_write_ioctlcmd+0x48>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_read_write_ioctlcmd>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e87(%rip),%rax
mov    (%rax),%esi
lea    0xe96(%rip),%rdi
call   1060 <open@plt>
test   %eax,%eax
je     118d <send_read_write_ioctlcmd+0x3d>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <ioctl@plt>
mov    %ebp,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <close@plt>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"/proc/parallelled\00"
@O_RDONLY = global i32 0
@.str.1 = [36 x i8] c"/proc/parallelled is not available\0A\00"
define void @send_read_write_ioctlcmd(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32
store i64 %0, i64* %3
store i8* %1, i8** %4
%6 = load i32, i32* @O_RDONLY
%7 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
%14 = load i32, i32* %5
%15 = load i64, i64* %3
%16 = load i8*, i8** %4
%17 = call i32 @ioctl(i32 %14, i64 %15, i8* %16)
%18 = load i32, i32* %5
%19 = call i32 @close(i32 %18)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"/proc/parallelled\00"
@O_RDONLY = global i32 0
@str = [35 x i8] c"/proc/parallelled is not available\00"
define void @send_read_write_ioctlcmd(i64 %0, i8* %1) {
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %2
%10 = tail call i32 @ioctl(i32 %4, i64 %0, i8* %1)
%11 = tail call i32 @close(i32 %4)
ret void
}