#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*/ int64_t;

/* Variables and functions */
scalar_t__ EINVAL;
scalar_t__ ENOSYS;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ parrot_mkalloc(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int /*<<< orphan*/ string_metric_parse(char *);
int main(int argc, char *argv[]) {
  int64_t size;
  if (argc != 3) {
    printf("use: parrot_mkalloc <path> <size>\n");
    return 0;
  }
  size = string_metric_parse(argv[2]);
  if (parrot_mkalloc(argv[1], size, 0777) == 0) {
    return 0;
  } else {
    if (errno == ENOSYS || errno == EINVAL) {
      fprintf(
          stderr,
          "parrot_mkalloc: This filesystem does not support allocations.\n");
    } else {
      fprintf(stderr, "parrot_mkalloc: %s\n", strerror(errno));
    }
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1188 <main+0x38>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1249 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <string_metric_parse@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
mov    $0x1ff,%edx
call   1070 <parrot_mkalloc@plt>
cmp    $0x0,%rax
jne    11c3 <main+0x73>
movl   $0x0,-0x4(%rbp)
jmp    1249 <main+0xf9>
mov    0x2e06(%rip),%rax
mov    (%rax),%rax
mov    0x2e14(%rip),%rcx
cmp    (%rcx),%rax
je     11f7 <main+0xa7>
mov    0x2dec(%rip),%rax
mov    (%rax),%rax
mov    0x2dda(%rip),%rcx
cmp    (%rcx),%rax
jne    1213 <main+0xc3>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1242 <main+0xf2>
mov    0x2dbe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2daa(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rdx
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x3,%edi
jne    11bc <main+0x6c>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
call   1060 <string_metric_parse@plt>
mov    0x8(%rbx),%rdi
mov    %eax,%esi
mov    $0x1ff,%edx
call   1070 <parrot_mkalloc@plt>
test   %rax,%rax
je     11c8 <main+0x78>
mov    0x2e52(%rip),%rax
mov    (%rax),%rdi
mov    0x2e60(%rip),%rax
mov    0x2e49(%rip),%rcx
mov    (%rcx),%ebx
cmp    (%rax),%rdi
je     11cc <main+0x7c>
mov    0x2e2b(%rip),%rax
cmp    (%rax),%rdi
je     11cc <main+0x7c>
call   1050 <strerror@plt>
lea    0xe91(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11dc <main+0x8c>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe2d(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"use: parrot_mkalloc <path> <size>\0A\00"
@errno = global i64 0
@ENOSYS = global i64 0
@EINVAL = global i64 0
@stderr = global i32 0
@.str.1 = [63 x i8] c"parrot_mkalloc: This filesystem does not support allocations.\0A\00"
@.str.2 = [20 x i8] c"parrot_mkalloc: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 3
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %40
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = call i32 @string_metric_parse(i8* %14)
store i32 %15, i32* %6
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = load i32, i32* %6
%20 = call i64 @parrot_mkalloc(i8* %18, i32 %19, i32 511)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %11
store i32 0, i32* %3
br label %40
23: ; preds = %11
%24 = load i64, i64* @errno
%25 = load i64, i64* @ENOSYS
%26 = icmp eq i64 %24, %25
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i64, i64* @errno
%29 = load i64, i64* @EINVAL
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %34
31: ; preds = %27, %23
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
br label %39
34: ; preds = %27
%35 = load i32, i32* @stderr
%36 = load i64, i64* @errno
%37 = call i8* @strerror(i64 %36)
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %34, %31
store i32 1, i32* %3
br label %40
40: ; preds = %39, %22, %9
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@errno = global i64 0
@ENOSYS = global i64 0
@EINVAL = global i64 0
@stderr = global i32 0
@.str.1 = [63 x i8] c"parrot_mkalloc: This filesystem does not support allocations.\0A\00"
@.str.2 = [20 x i8] c"parrot_mkalloc: %s\0A\00"
@str = [34 x i8] c"use: parrot_mkalloc <path> <size>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %27
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 @string_metric_parse(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i64 @parrot_mkalloc(i8* %11, i32 %9, i32 511)
%13 = icmp eq i64 %12, 0
br i1 %13, label %27, label %14
14: ; preds = %6
%15 = load i64, i64* @errno
%16 = load i64, i64* @ENOSYS
%17 = icmp eq i64 %15, %16
%18 = load i64, i64* @EINVAL
%19 = icmp eq i64 %15, %18
%20 = select i1 %17, i1 true, i1 %19
%21 = load i32, i32* @stderr
br i1 %20, label %22, label %24
22: ; preds = %14
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
br label %27
24: ; preds = %14
%25 = tail call i8* @strerror(i64 %15)
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %22, %24, %6, %4
%28 = phi i32 [ 0, %4 ], [ 0, %6 ], [ 1, %24 ], [ 1, %22 ]
ret i32 %28
}