#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 */
int S_IRWXG;
int S_IRWXO;
int S_IRWXU;
int S_ISGID;
int S_ISUID;
int S_ISVTX;
int /*<<< orphan*/ errno;
scalar_t__ lchmod(char *, int);
int /*<<< orphan*/ syswarn(int, int /*<<< orphan*/, char *, char *);
void set_pmode(char *fnm, mode_t mode) {
  mode &= ((S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) | (S_ISUID | S_ISGID));
  if (lchmod(fnm, mode) < 0)
    syswarn(1, errno, "Could not set permissions on %s", fnm);
  return;
}


x86 assembly (clang, -O0):
<set_pmode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%eax
mov    0x2ea1(%rip),%rcx
or     (%rcx),%eax
mov    0x2e88(%rip),%rcx
or     (%rcx),%eax
mov    0x2e9f(%rip),%rcx
or     (%rcx),%eax
mov    0x2e6e(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2e55(%rip),%rdx
or     (%rdx),%ecx
or     %ecx,%eax
and    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <lchmod@plt>
cmp    $0x0,%rax
jge    11a1 <set_pmode+0x81>
mov    0x2e26(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rcx
mov    $0x1,%edi
lea    0xe64(%rip),%rdx
call   1040 <syswarn@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_pmode>:
push   %rbx
mov    %rdi,%rbx
mov    0x2ead(%rip),%rax
mov    0x2eae(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2e95(%rip),%rdx
mov    0x2eae(%rip),%rdi
mov    0x2e7f(%rip),%r8
or     (%rax),%ecx
or     (%rdx),%ecx
or     (%rdi),%ecx
or     (%r8),%ecx
mov    0x2e5f(%rip),%rax
or     (%rax),%ecx
and    %ecx,%esi
mov    %rbx,%rdi
call   1030 <lchmod@plt>
test   %rax,%rax
js     116c <set_pmode+0x4c>
pop    %rbx
ret
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
lea    0xe84(%rip),%rdx
mov    $0x1,%edi
mov    %rbx,%rcx
pop    %rbx
jmp    1040 <syswarn@plt>

LLVM IR (-O0):
@S_ISVTX = global i32 0
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
@S_ISUID = global i32 0
@S_ISGID = global i32 0
@errno = global i32 0
@.str = [32 x i8] c"Could not set permissions on %s\00"
define void @set_pmode(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* @S_ISVTX
%6 = load i32, i32* @S_IRWXU
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IRWXG
%9 = or i32 %7, %8
%10 = load i32, i32* @S_IRWXO
%11 = or i32 %9, %10
%12 = load i32, i32* @S_ISUID
%13 = load i32, i32* @S_ISGID
%14 = or i32 %12, %13
%15 = or i32 %11, %14
%16 = load i32, i32* %4
%17 = and i32 %16, %15
store i32 %17, i32* %4
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = call i64 @lchmod(i8* %18, i32 %19)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i32, i32* @errno
%24 = load i8*, i8** %3
%25 = call i32 @syswarn(i32 1, i32 %23, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %22, %2
ret void
}

LLVM IR (-O2):
@S_ISVTX = global i32 0
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
@S_ISUID = global i32 0
@S_ISGID = global i32 0
@errno = global i32 0
@.str = [32 x i8] c"Could not set permissions on %s\00"
define void @set_pmode(i8* %0, i32 %1) {
%3 = load i32, i32* @S_ISVTX
%4 = load i32, i32* @S_IRWXU
%5 = load i32, i32* @S_IRWXG
%6 = load i32, i32* @S_IRWXO
%7 = load i32, i32* @S_ISUID
%8 = load i32, i32* @S_ISGID
%9 = or i32 %4, %3
%10 = or i32 %9, %5
%11 = or i32 %10, %6
%12 = or i32 %11, %7
%13 = or i32 %12, %8
%14 = and i32 %13, %1
%15 = tail call i64 @lchmod(i8* %0, i32 %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i32, i32* @errno
%19 = tail call i32 @syswarn(i32 1, i32 %18, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %20
20: ; preds = %17, %2
ret void
}