#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;
};
typedef int mode_t;

/* Variables and functions */
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *args[]) {
  if (argc < 2) {
    fprintf(stderr, "useage error: %s\n", strerror(errno));
    printf("useage:%s <pathname>\n", args[0]);
    exit(1);
  }
  struct stat st;
  if (stat(args[1], &st) < 0) {
    fprintf(stderr, "stat error: %s\n", strerror(errno));
    exit(1);
  }
  mode_t mode = st.st_mode;
  printf(" ");
  if (mode & S_IRUSR) {
    printf("r");
  } else {
    printf("-");
  }
  if (mode & S_IWUSR) {
    printf("w");
  } else {
    printf("-");
  }
  if (mode & S_IXUSR) {
    printf("x");
  } else {
    printf("-");
  }
  if (mode & S_IRGRP) {
    printf("r");
  } else {
    printf("-");
  }
  if (mode & S_IWGRP) {
    printf("w");
  } else {
    printf("-");
  }
  if (mode & S_IXGRP) {
    printf("x");
  } else {
    printf("-");
  }
  if (mode & S_IROTH) {
    printf("r");
  } else {
    printf("-");
  }
  if (mode & S_IWOTH) {
    printf("w");
  } else {
    printf("-");
  }
  if (mode & S_IXOTH) {
    printf("x");
  } else {
    printf("-");
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11bb <main+0x6b>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xe69(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jge    120c <main+0xbc>
mov    0x2ddb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xe2b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    0x2d6e(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1248 <main+0xf8>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1256 <main+0x106>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    0x2d70(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     127e <main+0x12e>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128c <main+0x13c>
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    0x2d4a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12b4 <main+0x164>
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c2 <main+0x172>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    0x2cdc(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12ea <main+0x19a>
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f8 <main+0x1a8>
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    0x2cd6(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1320 <main+0x1d0>
lea    0xd2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132e <main+0x1de>
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    0x2c90(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1356 <main+0x206>
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1364 <main+0x214>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    0x2c32(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     138c <main+0x23c>
lea    0xcba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    139a <main+0x24a>
lea    0xca9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    0x2be4(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     13c2 <main+0x272>
lea    0xc88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13d0 <main+0x280>
lea    0xc73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    0x2c0e(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     13f8 <main+0x2a8>
lea    0xc54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1406 <main+0x2b6>
lea    0xc3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    12a5 <main+0x145>
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
js     12e8 <main+0x188>
mov    0x8(%rsp),%ebp
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x2d,%r12d
mov    $0x72,%r14d
mov    $0x72,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x77,%r15d
mov    $0x77,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x78,%ebx
mov    $0x78,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
mov    0x2da2(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x72,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x77,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x78,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
cmove  %r12d,%r14d
mov    %r14d,%edi
call   1030 <putchar@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
cmove  %r12d,%r15d
mov    %r15d,%edi
call   1030 <putchar@plt>
mov    0x2d69(%rip),%rax
and    (%rax),%ebp
cmove  %r12d,%ebx
mov    %ebx,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d0c(%rip),%rax
mov    (%rax),%ebp
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xd3d(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    (%rbx),%rsi
lea    0xd3b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2cc9(%rip),%rax
mov    (%rax),%ebx
mov    0x2cb8(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xd22(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"useage error: %s\0A\00"
@errno = global i32 0
@.str.1 = [22 x i8] c"useage:%s <pathname>\0A\00"
@.str.2 = [16 x i8] c"stat error: %s\0A\00"
@.str.3 = [2 x i8] c" \00"
@S_IRUSR = global i32 0
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [2 x i8] c"-\00"
@S_IWUSR = global i32 0
@.str.6 = [2 x i8] c"w\00"
@S_IXUSR = global i32 0
@.str.7 = [2 x i8] c"x\00"
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %20
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @stat(i8* %23, %struct.stat* %6)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %20
%27 = load i32, i32* @stderr
%28 = load i32, i32* @errno
%29 = call i8* @strerror(i32 %28)
%30 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %20
%33 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%34 = load i32, i32* %33
store i32 %34, i32* %7
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%36 = load i32, i32* %7
%37 = load i32, i32* @S_IRUSR
%38 = and i32 %36, %37
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %44
42: ; preds = %32
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %44
44: ; preds = %42, %40
%45 = load i32, i32* %7
%46 = load i32, i32* @S_IWUSR
%47 = and i32 %45, %46
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %44
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %53
51: ; preds = %44
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %53
53: ; preds = %51, %49
%54 = load i32, i32* %7
%55 = load i32, i32* @S_IXUSR
%56 = and i32 %54, %55
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %62
60: ; preds = %53
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %62
62: ; preds = %60, %58
%63 = load i32, i32* %7
%64 = load i32, i32* @S_IRGRP
%65 = and i32 %63, %64
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %62
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %71
69: ; preds = %62
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %71
71: ; preds = %69, %67
%72 = load i32, i32* %7
%73 = load i32, i32* @S_IWGRP
%74 = and i32 %72, %73
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %80
78: ; preds = %71
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %80
80: ; preds = %78, %76
%81 = load i32, i32* %7
%82 = load i32, i32* @S_IXGRP
%83 = and i32 %81, %82
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %80
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %89
87: ; preds = %80
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %89
89: ; preds = %87, %85
%90 = load i32, i32* %7
%91 = load i32, i32* @S_IROTH
%92 = and i32 %90, %91
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %89
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %98
96: ; preds = %89
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %98
98: ; preds = %96, %94
%99 = load i32, i32* %7
%100 = load i32, i32* @S_IWOTH
%101 = and i32 %99, %100
%102 = icmp ne i32 %101, 0
br i1 %102, label %103, label %105
103: ; preds = %98
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %107
105: ; preds = %98
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %107
107: ; preds = %105, %103
%108 = load i32, i32* %7
%109 = load i32, i32* @S_IXOTH
%110 = and i32 %108, %109
%111 = icmp ne i32 %110, 0
br i1 %111, label %112, label %114
112: ; preds = %107
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %116
114: ; preds = %107
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %116
116: ; preds = %114, %112
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"useage error: %s\0A\00"
@errno = global i32 0
@.str.1 = [22 x i8] c"useage:%s <pathname>\0A\00"
@.str.2 = [16 x i8] c"stat error: %s\0A\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = bitcast %struct.stat* %3 to i8*
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @stat(i8* %16, %struct.stat* %3)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = call i8* @strerror(i32 %21)
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %13
%26 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%27 = load i32, i32* %26
%28 = call i32 @putchar(i32 32)
%29 = load i32, i32* @S_IRUSR
%30 = and i32 %29, %27
%31 = icmp eq i32 %30, 0
%32 = select i1 %31, i32 45, i32 114
%33 = call i32 @putchar(i32 %32)
%34 = load i32, i32* @S_IWUSR
%35 = and i32 %34, %27
%36 = icmp eq i32 %35, 0
%37 = select i1 %36, i32 45, i32 119
%38 = call i32 @putchar(i32 %37)
%39 = load i32, i32* @S_IXUSR
%40 = and i32 %39, %27
%41 = icmp eq i32 %40, 0
%42 = select i1 %41, i32 45, i32 120
%43 = call i32 @putchar(i32 %42)
%44 = load i32, i32* @S_IRGRP
%45 = and i32 %44, %27
%46 = icmp eq i32 %45, 0
%47 = select i1 %46, i32 45, i32 114
%48 = call i32 @putchar(i32 %47)
%49 = load i32, i32* @S_IWGRP
%50 = and i32 %49, %27
%51 = icmp eq i32 %50, 0
%52 = select i1 %51, i32 45, i32 119
%53 = call i32 @putchar(i32 %52)
%54 = load i32, i32* @S_IXGRP
%55 = and i32 %54, %27
%56 = icmp eq i32 %55, 0
%57 = select i1 %56, i32 45, i32 120
%58 = call i32 @putchar(i32 %57)
%59 = load i32, i32* @S_IROTH
%60 = and i32 %59, %27
%61 = icmp eq i32 %60, 0
%62 = select i1 %61, i32 45, i32 114
%63 = call i32 @putchar(i32 %62)
%64 = load i32, i32* @S_IWOTH
%65 = and i32 %64, %27
%66 = icmp eq i32 %65, 0
%67 = select i1 %66, i32 45, i32 119
%68 = call i32 @putchar(i32 %67)
%69 = load i32, i32* @S_IXOTH
%70 = and i32 %69, %27
%71 = icmp eq i32 %70, 0
%72 = select i1 %71, i32 45, i32 120
%73 = call i32 @putchar(i32 %72)
%74 = call i32 @putchar(i32 10)
ret i32 0
}