#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 */
struct stat {
  int st_mode;
};

/* Variables and functions */
int S_IRWXG;
int S_IRWXO;
int S_IRWXU;
int /*<<< orphan*/ print_rights(int);
int /*<<< orphan*/ stat(char *, struct stat *);
int main(int argc, char *argv[]) {
  int owner, gr, others;
  struct stat st;
  stat(argv[1], &st);
  owner = st.st_mode & S_IRWXU;
  gr = st.st_mode & S_IRWXG;
  others = st.st_mode & S_IRWXO;
  print_rights(owner >> 6);
  print_rights(gr >> 3);
  print_rights(others);
  return 0;
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <stat@plt>
mov    -0x20(%rbp),%eax
mov    0x2e8f(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2e78(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2e81(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
sar    $0x6,%edi
call   1030 <print_rights@plt>
mov    -0x18(%rbp),%edi
sar    $0x3,%edi
call   1030 <print_rights@plt>
mov    -0x1c(%rbp),%edi
call   1030 <print_rights@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
call   1040 <stat@plt>
mov    (%rsp),%ebx
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
and    %ebx,%edi
mov    0x2e94(%rip),%rax
mov    (%rax),%ebp
and    %ebx,%ebp
mov    0x2ea1(%rip),%rax
and    (%rax),%ebx
sar    $0x6,%edi
call   1030 <print_rights@plt>
sar    $0x3,%ebp
mov    %ebp,%edi
call   1030 <print_rights@plt>
mov    %ebx,%edi
call   1030 <print_rights@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = 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
%8 = alloca i32
%9 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @stat(i8* %12, %struct.stat* %9)
%14 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%15 = load i32, i32* %14
%16 = load i32, i32* @S_IRWXU
%17 = and i32 %15, %16
store i32 %17, i32* %6
%18 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%19 = load i32, i32* %18
%20 = load i32, i32* @S_IRWXG
%21 = and i32 %19, %20
store i32 %21, i32* %7
%22 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%23 = load i32, i32* %22
%24 = load i32, i32* @S_IRWXO
%25 = and i32 %23, %24
store i32 %25, i32* %8
%26 = load i32, i32* %6
%27 = ashr i32 %26, 6
%28 = call i32 @print_rights(i32 %27)
%29 = load i32, i32* %7
%30 = ashr i32 %29, 3
%31 = call i32 @print_rights(i32 %30)
%32 = load i32, i32* %8
%33 = call i32 @print_rights(i32 %32)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = call i32 @stat(i8* %6, %struct.stat* %3)
%8 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%9 = load i32, i32* %8
%10 = load i32, i32* @S_IRWXU
%11 = and i32 %10, %9
%12 = load i32, i32* @S_IRWXG
%13 = and i32 %12, %9
%14 = load i32, i32* @S_IRWXO
%15 = and i32 %14, %9
%16 = ashr i32 %11, 6
%17 = tail call i32 @print_rights(i32 %16)
%18 = ashr i32 %13, 3
%19 = tail call i32 @print_rights(i32 %18)
%20 = tail call i32 @print_rights(i32 %15)
ret i32 0
}