#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 */
typedef int /*<<< orphan*/ infile;

/* Variables and functions */
int /*<<< orphan*/ F_OK;
int O_NONBLOCK;
int O_RDONLY;
int /*<<< orphan*/ S_IRWXU;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ create_filepath(char *, int, char *, char *);
int /*<<< orphan*/ mkfifo(char *, int /*<<< orphan*/);
int open(char *, int, int /*<<< orphan*/);
int open_channel(char *name) {
  static char infile[256];
  create_filepath(infile, sizeof(infile), name, "in");
  if (access(infile, F_OK) == -1)
    mkfifo(infile, S_IRWXU);
  return open(infile, O_RDONLY | O_NONBLOCK, 0);
}


x86 assembly (clang, -O0):
<open_channel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdx
lea    0x2ef9(%rip),%rdi
mov    $0x100,%esi
lea    0xe9d(%rip),%rcx
call   1030 <create_filepath@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
lea    0x2ed8(%rip),%rdi
call   1060 <access@plt>
cmp    $0xffffffff,%eax
jne    119b <open_channel+0x5b>
mov    0x2e5b(%rip),%rax
mov    (%rax),%esi
lea    0x2eba(%rip),%rdi
call   1040 <mkfifo@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%esi
mov    0x2e35(%rip),%rax
or     (%rax),%esi
lea    0x2e9c(%rip),%rdi
xor    %edx,%edx
call   1050 <open@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_channel>:
push   %rbx
mov    %rdi,%rdx
lea    0x2f05(%rip),%rbx
lea    0xeae(%rip),%rcx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1030 <create_filepath@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <access@plt>
cmp    $0xffffffff,%eax
jne    118a <open_channel+0x4a>
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
lea    0x2ecb(%rip),%rdi
call   1040 <mkfifo@plt>
mov    0x2e47(%rip),%rax
mov    0x2e48(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0x2ead(%rip),%rdi
xor    %edx,%edx
pop    %rbx
jmp    1050 <open@plt>

LLVM IR (-O0):
@open_channel.infile = internal global [256 x i8] zeroinitializer
@.str = [3 x i8] c"in\00"
@F_OK = global i32 0
@S_IRWXU = global i32 0
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
define i32 @open_channel(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @create_filepath(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @open_channel.infile, i64 0, i64 0), i32 256, i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @F_OK
%6 = call i32 @access(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @open_channel.infile, i64 0, i64 0), i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* @S_IRWXU
%10 = call i32 @mkfifo(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @open_channel.infile, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %8, %1
%12 = load i32, i32* @O_RDONLY
%13 = load i32, i32* @O_NONBLOCK
%14 = or i32 %12, %13
%15 = call i32 @open(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @open_channel.infile, i64 0, i64 0), i32 %14, i32 0)
ret i32 %15
}

LLVM IR (-O2):
@open_channel.infile = internal global [256 x i8] zeroinitializer
@.str = [3 x i8] c"in\00"
@F_OK = global i32 0
@S_IRWXU = global i32 0
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
define i32 @open_channel(i8* %0) {
%2 = tail call i32 @create_filepath(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @open_channel.infile, i64 0, i64 0), i32 256, i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @F_OK
%4 = tail call i32 @access(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @open_channel.infile, i64 0, i64 0), i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @S_IRWXU
%8 = tail call i32 @mkfifo(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @open_channel.infile, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %6, %1
%10 = load i32, i32* @O_RDONLY
%11 = load i32, i32* @O_NONBLOCK
%12 = or i32 %11, %10
%13 = tail call i32 @open(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @open_channel.infile, i64 0, i64 0), i32 %12, i32 0)
ret i32 %13
}