#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;

/* Variables and functions */
scalar_t__ _mkfifo(int, int, char **);
int /*<<< orphan*/ _mode(int /*<<< orphan*/, int *);
int _usage();
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int optind;
int main(int argc, char *argv[]) {
  mode_t mode = 0777;
  int o;
  while ((o = getopt(argc, argv, "m:")) != -1)
    switch (o) {
    case 'm':
      if (_mode(optarg, &mode) != 0)
        return _usage();
      break;
    default:
      return _usage();
    }
  if (argc == optind)
    return _usage();
  return (_mkfifo(mode, argc - optind, &argv[optind]) == 0) ? 0 : 2;
}


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)
movl   $0x1ff,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe95(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     11d0 <main+0x90>
mov    -0x18(%rbp),%eax
sub    $0x6d,%eax
jne    11bc <main+0x7c>
jmp    118d <main+0x4d>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    -0x14(%rbp),%rsi
call   1040 <_mode@plt>
cmp    $0x0,%eax
je     11b7 <main+0x77>
mov    $0x0,%al
call   1030 <_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    122e <main+0xee>
jmp    11cb <main+0x8b>
mov    $0x0,%al
call   1030 <_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    122e <main+0xee>
jmp    115d <main+0x1d>
mov    -0x8(%rbp),%eax
mov    0x2e06(%rip),%rcx
cmp    (%rcx),%eax
jne    11f1 <main+0xb1>
mov    $0x0,%al
call   1030 <_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    122e <main+0xee>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x2de2(%rip),%rax
sub    (%rax),%esi
mov    -0x10(%rbp),%rdx
mov    0x2dd5(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
add    %rax,%rdx
call   1060 <_mkfifo@plt>
mov    %rax,%rdx
mov    $0x2,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
movl   $0x1ff,0xc(%rsp)
lea    0xe9f(%rip),%r15
mov    0x2e90(%rip),%r13
lea    0xc(%rsp),%r12
nopl   (%rax)
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <getopt@plt>
cmp    $0x6d,%eax
jne    1194 <main+0x54>
mov    0x0(%r13),%edi
mov    %r12,%rsi
call   1040 <_mode@plt>
test   %eax,%eax
je     1170 <main+0x30>
jmp    11a7 <main+0x67>
cmp    $0xffffffff,%eax
jne    11a7 <main+0x67>
mov    0x2e40(%rip),%rax
movslq (%rax),%rax
cmp    %ebx,%eax
jne    11bc <main+0x7c>
xor    %eax,%eax
call   1030 <_usage@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0xc(%rsp),%edi
sub    %eax,%ebx
lea    (%r14,%rax,8),%rdx
mov    %ebx,%esi
call   1060 <_mkfifo@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
add    %eax,%eax
jmp    11ae <main+0x6e>

LLVM IR (-O0):
@.str = [3 x i8] c"m:\00"
@optarg = global i32 0
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 511, i32* %6
br label %8
8: ; preds = %24, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %7
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %25
13: ; preds = %8
%14 = load i32, i32* %7
switch i32 %14, label %22 [
i32 109, label %15
]
15: ; preds = %13
%16 = load i32, i32* @optarg
%17 = call i32 @_mode(i32 %16, i32* %6)
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (...) @_usage()
store i32 %20, i32* %3
br label %44
21: ; preds = %15
br label %24
22: ; preds = %13
%23 = call i32 (...) @_usage()
store i32 %23, i32* %3
br label %44
24: ; preds = %21
br label %8
25: ; preds = %8
%26 = load i32, i32* %4
%27 = load i32, i32* @optind
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 (...) @_usage()
store i32 %30, i32* %3
br label %44
31: ; preds = %25
%32 = load i32, i32* %6
%33 = load i32, i32* %4
%34 = load i32, i32* @optind
%35 = sub nsw i32 %33, %34
%36 = load i8**, i8*** %5
%37 = load i32, i32* @optind
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = call i64 @_mkfifo(i32 %32, i32 %35, i8** %39)
%41 = icmp eq i64 %40, 0
%42 = zext i1 %41 to i64
%43 = select i1 %41, i32 0, i32 2
store i32 %43, i32* %3
br label %44
44: ; preds = %31, %29, %22, %19
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [3 x i8] c"m:\00"
@optarg = global i32 0
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 511, i32* %3
br label %5
5: ; preds = %7, %2
%6 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %13 [
i32 -1, label %15
i32 109, label %7
]
7: ; preds = %5
%8 = load i32, i32* @optarg
%9 = call i32 @_mode(i32 %8, i32* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %5, label %11
11: ; preds = %7
%12 = call i32 (...) @_usage()
br label %28
13: ; preds = %5
%14 = call i32 (...) @_usage()
br label %28
15: ; preds = %5
%16 = load i32, i32* @optind
%17 = icmp eq i32 %16, %0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (...) @_usage()
br label %28
20: ; preds = %15
%21 = load i32, i32* %3
%22 = sub nsw i32 %0, %16
%23 = sext i32 %16 to i64
%24 = getelementptr inbounds i8*, i8** %1, i64 %23
%25 = call i64 @_mkfifo(i32 %21, i32 %22, i8** %24)
%26 = icmp eq i64 %25, 0
%27 = select i1 %26, i32 0, i32 2
br label %28
28: ; preds = %20, %18, %13, %11
%29 = phi i32 [ %12, %11 ], [ %14, %13 ], [ %19, %18 ], [ %27, %20 ]
ret i32 %29
}