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

/* Variables and functions */
int S_IFIFO;
int S_IRWXU;
int S_IWGRP;
int S_IWOTH;
int mknod(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int umask(int);
int create_pipe(char *pipename) {
  mode_t old_umask;
  int created;
  old_umask = umask(000);
  created = mknod(pipename, S_IFIFO | S_IRWXU | S_IWGRP | S_IWOTH, (dev_t)NULL);
  (void)umask(old_umask);
  if (-1 == created) {
    perror("unable to create pipe");
  }
  return (created);
}


x86 assembly (clang, -O0):
<create_pipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
call   1030 <umask@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
mov    0x2e8e(%rip),%rax
or     (%rax),%esi
mov    0x2e7d(%rip),%rax
or     (%rax),%esi
mov    0x2e54(%rip),%rax
or     (%rax),%esi
xor    %edx,%edx
call   1040 <mknod@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <umask@plt>
mov    $0xffffffff,%eax
cmp    -0x10(%rbp),%eax
jne    119a <create_pipe+0x6a>
lea    0xe6b(%rip),%rdi
call   1050 <perror@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_pipe>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %edi,%edi
call   1030 <umask@plt>
mov    0x2e8c(%rip),%rcx
mov    0x2e9d(%rip),%rdx
mov    (%rdx),%esi
or     (%rcx),%esi
mov    0x2e8a(%rip),%rcx
or     (%rcx),%esi
mov    %eax,%ebp
mov    0x2e5f(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
xor    %edx,%edx
call   1040 <mknod@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <umask@plt>
cmp    $0xffffffff,%ebx
je     1184 <create_pipe+0x54>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe75(%rip),%rdi
call   1050 <perror@plt>
jmp    117b <create_pipe+0x4b>

LLVM IR (-O0):
@S_IFIFO = global i32 0
@S_IRWXU = global i32 0
@S_IWGRP = global i32 0
@S_IWOTH = global i32 0
@.str = [22 x i8] c"unable to create pipe\00"
define i32 @create_pipe(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 @umask(i32 0)
store i32 %5, i32* %3
%6 = load i8*, i8** %2
%7 = load i32, i32* @S_IFIFO
%8 = load i32, i32* @S_IRWXU
%9 = or i32 %7, %8
%10 = load i32, i32* @S_IWGRP
%11 = or i32 %9, %10
%12 = load i32, i32* @S_IWOTH
%13 = or i32 %11, %12
%14 = call i32 @mknod(i8* %6, i32 %13, i32 0)
store i32 %14, i32* %4
%15 = load i32, i32* %3
%16 = call i32 @umask(i32 %15)
%17 = load i32, i32* %4
%18 = icmp eq i32 -1, %17
br i1 %18, label %19, label %21
19: ; preds = %1
%20 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %1
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
@S_IFIFO = global i32 0
@S_IRWXU = global i32 0
@S_IWGRP = global i32 0
@S_IWOTH = global i32 0
@.str = [22 x i8] c"unable to create pipe\00"
define i32 @create_pipe(i8* %0) {
%2 = tail call i32 @umask(i32 0)
%3 = load i32, i32* @S_IFIFO
%4 = load i32, i32* @S_IRWXU
%5 = or i32 %4, %3
%6 = load i32, i32* @S_IWGRP
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IWOTH
%9 = or i32 %7, %8
%10 = tail call i32 @mknod(i8* %0, i32 %9, i32 0)
%11 = tail call i32 @umask(i32 %2)
%12 = icmp eq i32 %10, -1
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %1
ret i32 %10
}