#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 S_IFIFO;
int S_IFREG;
int S_IRWXG;
int S_IRWXO;
int S_IRWXU;
int mknod(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int main(void) {
  int result;
  result = mknod("test.txt", S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO, 0);
  if (result == 0) {
    printf("create test.txt success!\n");
  } else {
    printf("create test.txt failed!\n");
  }
  result = mknod("TEST1", S_IFIFO | S_IRWXU | S_IRWXG | S_IRWXO, 0);
  if (result == 0) {
    printf("create TEST1 success!\n");
  } else {
    printf("create TEST1 failed!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%esi
mov    0x2ea1(%rip),%rax
or     (%rax),%esi
mov    0x2e90(%rip),%rax
or     (%rax),%esi
mov    0x2e9f(%rip),%rax
or     (%rax),%esi
lea    0xea6(%rip),%rdi
xor    %edx,%edx
call   1040 <mknod@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    117f <main+0x5f>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
jmp    118b <main+0x6b>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
mov    0x2e45(%rip),%rax
or     (%rax),%esi
mov    0x2e34(%rip),%rax
or     (%rax),%esi
mov    0x2e43(%rip),%rax
or     (%rax),%esi
lea    0xe86(%rip),%rdi
xor    %edx,%edx
call   1040 <mknod@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11db <main+0xbb>
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
jmp    11e7 <main+0xc7>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2ea4(%rip),%rax
mov    0x2ead(%rip),%r15
mov    (%r15),%esi
or     (%rax),%esi
mov    0x2e99(%rip),%r14
or     (%r14),%esi
mov    0x2ea7(%rip),%rbx
or     (%rbx),%esi
lea    0xeae(%rip),%rdi
xor    %edx,%edx
call   1040 <mknod@plt>
test   %eax,%eax
lea    0xef0(%rip),%rax
lea    0xea6(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    0x2e47(%rip),%rax
mov    (%r15),%esi
or     (%rax),%esi
or     (%r14),%esi
or     (%rbx),%esi
lea    0xe7f(%rip),%rdi
xor    %edx,%edx
call   1040 <mknod@plt>
test   %eax,%eax
lea    0xea2(%rip),%rax
lea    0xe86(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"test.txt\00"
@S_IFREG = global i32 0
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
@.str.1 = [26 x i8] c"create test.txt success!\0A\00"
@.str.2 = [25 x i8] c"create test.txt failed!\0A\00"
@.str.3 = [6 x i8] c"TEST1\00"
@S_IFIFO = global i32 0
@.str.4 = [23 x i8] c"create TEST1 success!\0A\00"
@.str.5 = [22 x i8] c"create TEST1 failed!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @S_IFREG
%4 = load i32, i32* @S_IRWXU
%5 = or i32 %3, %4
%6 = load i32, i32* @S_IRWXG
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IRWXO
%9 = or i32 %7, %8
%10 = call i32 @mknod(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %9, i32 0)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %17
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
%18 = load i32, i32* @S_IFIFO
%19 = load i32, i32* @S_IRWXU
%20 = or i32 %18, %19
%21 = load i32, i32* @S_IRWXG
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IRWXO
%24 = or i32 %22, %23
%25 = call i32 @mknod(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 0)
store i32 %25, i32* %2
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %17
%29 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %32
30: ; preds = %17
%31 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.txt\00"
@S_IFREG = global i32 0
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
@.str.3 = [6 x i8] c"TEST1\00"
@S_IFIFO = global i32 0
@str = [24 x i8] c"create test.txt failed!\00"
@str.6 = [21 x i8] c"create TEST1 failed!\00"
@str.7 = [22 x i8] c"create TEST1 success!\00"
@str.8 = [25 x i8] c"create test.txt success!\00"
define i32 @main() {
%1 = load i32, i32* @S_IFREG
%2 = load i32, i32* @S_IRWXU
%3 = or i32 %2, %1
%4 = load i32, i32* @S_IRWXG
%5 = or i32 %3, %4
%6 = load i32, i32* @S_IRWXO
%7 = or i32 %5, %6
%8 = tail call i32 @mknod(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %7, i32 0)
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0)
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
%12 = load i32, i32* @S_IFIFO
%13 = load i32, i32* @S_IRWXU
%14 = or i32 %13, %12
%15 = load i32, i32* @S_IRWXG
%16 = or i32 %14, %15
%17 = load i32, i32* @S_IRWXO
%18 = or i32 %16, %17
%19 = tail call i32 @mknod(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 0)
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.6, i64 0, i64 0)
%22 = tail call i32 @puts(i8* dereferenceable(1) %21)
ret i32 0
}