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

/* Variables and functions */
int /*<<< orphan*/ fsfr_fsetxattr_int(int, char *, int);
int getgid();
int getuid();
void frfs_mknod_helper(int fd, mode_t mode, dev_t dev) {
  int mask = 00777;
  fsfr_fsetxattr_int(fd,
                     "user.fsfr."
                     "uid",
                     getuid());
  fsfr_fsetxattr_int(fd,
                     "user.fsfr."
                     "gid",
                     getgid());
  fsfr_fsetxattr_int(fd,
                     "user.fsfr."
                     "rdev",
                     dev);
  fsfr_fsetxattr_int(fd,
                     "user.fsfr."
                     "mode",
                     mode & ~mask);
  fsfr_fsetxattr_int(fd,
                     "user.fsfr."
                     "modemask",
                     ~mask);
}


x86 assembly (clang, -O0):
<frfs_mknod_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x1ff,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <getuid@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%edx
lea    0xe9f(%rip),%rsi
call   1050 <fsfr_fsetxattr_int@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <getgid@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%edx
lea    0xe8f(%rip),%rsi
call   1050 <fsfr_fsetxattr_int@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%edx
lea    0xe8b(%rip),%rsi
call   1050 <fsfr_fsetxattr_int@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%eax
xor    $0xffffffff,%eax
and    %eax,%edx
lea    0xe80(%rip),%rsi
call   1050 <fsfr_fsetxattr_int@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%edx
xor    $0xffffffff,%edx
lea    0xe7a(%rip),%rsi
call   1050 <fsfr_fsetxattr_int@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frfs_mknod_helper>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <getuid@plt>
lea    0xeb7(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1050 <fsfr_fsetxattr_int@plt>
xor    %eax,%eax
call   1040 <getgid@plt>
lea    0xeae(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1050 <fsfr_fsetxattr_int@plt>
lea    0xeac(%rip),%rsi
mov    %ebx,%edi
mov    %r14d,%edx
call   1050 <fsfr_fsetxattr_int@plt>
and    $0xfffffe00,%ebp
lea    0xea4(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
call   1050 <fsfr_fsetxattr_int@plt>
lea    0xea3(%rip),%rsi
mov    %ebx,%edi
mov    $0xfffffe00,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <fsfr_fsetxattr_int@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"user.fsfr.uid\00"
@.str.1 = [14 x i8] c"user.fsfr.gid\00"
@.str.2 = [15 x i8] c"user.fsfr.rdev\00"
@.str.3 = [15 x i8] c"user.fsfr.mode\00"
@.str.4 = [19 x i8] c"user.fsfr.modemask\00"
define void @frfs_mknod_helper(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 511, i32* %7
%8 = load i32, i32* %4
%9 = call i32 (...) @getuid()
%10 = call i32 @fsfr_fsetxattr_int(i32 %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %4
%12 = call i32 (...) @getgid()
%13 = call i32 @fsfr_fsetxattr_int(i32 %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %4
%15 = load i32, i32* %6
%16 = call i32 @fsfr_fsetxattr_int(i32 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = load i32, i32* %7
%20 = xor i32 %19, -1
%21 = and i32 %18, %20
%22 = call i32 @fsfr_fsetxattr_int(i32 %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %4
%24 = load i32, i32* %7
%25 = xor i32 %24, -1
%26 = call i32 @fsfr_fsetxattr_int(i32 %23, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %25)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"user.fsfr.uid\00"
@.str.1 = [14 x i8] c"user.fsfr.gid\00"
@.str.2 = [15 x i8] c"user.fsfr.rdev\00"
@.str.3 = [15 x i8] c"user.fsfr.mode\00"
@.str.4 = [19 x i8] c"user.fsfr.modemask\00"
define void @frfs_mknod_helper(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 (...) @getuid()
%5 = tail call i32 @fsfr_fsetxattr_int(i32 %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 (...) @getgid()
%7 = tail call i32 @fsfr_fsetxattr_int(i32 %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = tail call i32 @fsfr_fsetxattr_int(i32 %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%9 = and i32 %1, -512
%10 = tail call i32 @fsfr_fsetxattr_int(i32 %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = tail call i32 @fsfr_fsetxattr_int(i32 %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 -512)
ret void
}