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


x86 assembly (clang, -O0):
<send_control_ioctlcmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%esi
lea    0xe94(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1194 <send_control_ioctlcmd+0x44>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <ioctl@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_control_ioctlcmd>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
lea    0xe9a(%rip),%rdi
call   1060 <open@plt>
test   %eax,%eax
je     1188 <send_control_ioctlcmd+0x38>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <ioctl@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <close@plt>
lea    0xe83(%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_control_ioctlcmd(i64 %0) {
%2 = alloca i64
%3 = alloca i32
store i64 %0, i64* %2
%4 = load i32, i32* @O_RDONLY
%5 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @exit(i32 -1)
unreachable
11: ; preds = %1
%12 = load i32, i32* %3
%13 = load i64, i64* %2
%14 = call i32 @ioctl(i32 %12, i64 %13)
%15 = load i32, i32* %3
%16 = call i32 @close(i32 %15)
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_control_ioctlcmd(i64 %0) {
%2 = load i32, i32* @O_RDONLY
%3 = tail call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %1
%9 = tail call i32 @ioctl(i32 %3, i64 %0)
%10 = tail call i32 @close(i32 %3)
ret void
}