#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;
  int st_uid;
  int st_gid;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_access(struct stat *s, char *name) {
  int j, o, m;
  char access[10];
  access[9] = '\0';
  for (j = 0; j < 3; j++) {
    m = (s->st_mode >> (j * 3)) & 7;
    o = (2 - j) * 3;
    access[0 + o] = ((m & 1) ? 'r' : '-');
    access[1 + o] = ((m & 2) ? 'w' : '-');
    access[2 + o] = ((m & 4) ? 'x' : '-');
  }
  printf("\n");
  printf("Dateiinfirmationen zu: '%s'\n", name);
  printf("Dateibesitzer:         User %d, Gruppe %d\n", s->st_uid, s->st_gid);
  printf("Zugrifsrechte:         %s\n", access);
  printf("\n");
}


x86 assembly (clang, -O0):
<print_access>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x1d(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11cf <print_access+0xbf>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
imul   $0x3,-0x14(%rbp),%ecx
sar    %cl,%eax
and    $0x7,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x2,%eax
sub    -0x14(%rbp),%eax
imul   $0x3,%eax,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%edx
and    $0x1,%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x18(%rbp),%eax
add    $0x0,%eax
cltq
mov    %cl,-0x26(%rbp,%rax,1)
mov    -0x1c(%rbp),%edx
and    $0x2,%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x18(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x26(%rbp,%rax,1)
mov    -0x1c(%rbp),%edx
and    $0x4,%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x18(%rbp),%eax
add    $0x2,%eax
cltq
mov    %cl,-0x26(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112b <print_access+0x1b>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edx
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x26(%rbp),%rsi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_access>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movb   $0x0,0xf(%rsp)
mov    (%rdi),%edx
test   $0x1,%dl
mov    $0x2d,%eax
mov    $0x72,%ecx
mov    $0x72,%esi
cmove  %eax,%esi
mov    %sil,0xc(%rsp)
movd   %edx,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xe9f(%rip),%xmm1
pand   %xmm0,%xmm1
pand   0xea3(%rip),%xmm0
pxor   %xmm2,%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm1
packssdw %xmm0,%xmm1
packsswb %xmm1,%xmm1
pmovmskb %xmm1,%edx
test   $0x80,%dl
mov    $0x77,%esi
mov    $0x77,%edi
cmovne %eax,%edi
mov    %dil,0xd(%rsp)
test   $0x40,%dl
mov    $0x78,%edi
cmovne %eax,%edi
mov    %dil,0xe(%rsp)
test   $0x20,%dl
mov    $0x72,%edi
cmovne %eax,%edi
mov    $0x78,%ebx
mov    %dil,0x9(%rsp)
test   $0x10,%dl
mov    $0x77,%edi
cmovne %eax,%edi
mov    %dil,0xa(%rsp)
test   $0x8,%dl
mov    $0x78,%edi
cmovne %eax,%edi
mov    %dil,0xb(%rsp)
test   $0x4,%dl
cmovne %eax,%ecx
mov    %cl,0x6(%rsp)
test   $0x2,%dl
cmovne %eax,%esi
mov    %sil,0x7(%rsp)
test   $0x1,%dl
cmovne %eax,%ebx
mov    %bl,0x8(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe11(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%r15),%esi
mov    0x8(%r15),%edx
lea    0xe15(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe32(%rip),%rdi
lea    0x6(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32 }
@.str = [2 x i8] c"\0A\00"
@.str.1 = [29 x i8] c"Dateiinfirmationen zu: '%s'\0A\00"
@.str.2 = [43 x i8] c"Dateibesitzer: User %d, Gruppe %d\0A\00"
@.str.3 = [27 x i8] c"Zugrifsrechte: %s\0A\00"
define void @print_access(%struct.stat* %0, i8* %1) {
%3 = alloca %struct.stat*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [10 x i8]
store %struct.stat* %0, %struct.stat** %3
store i8* %1, i8** %4
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 9
store i8 0, i8* %9
store i32 0, i32* %5
br label %10
10: ; preds = %54, %2
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %57
13: ; preds = %10
%14 = load %struct.stat*, %struct.stat** %3
%15 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = load i32, i32* %5
%18 = mul nsw i32 %17, 3
%19 = ashr i32 %16, %18
%20 = and i32 %19, 7
store i32 %20, i32* %7
%21 = load i32, i32* %5
%22 = sub nsw i32 2, %21
%23 = mul nsw i32 %22, 3
store i32 %23, i32* %6
%24 = load i32, i32* %7
%25 = and i32 %24, 1
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i32 114, i32 45
%29 = trunc i32 %28 to i8
%30 = load i32, i32* %6
%31 = add nsw i32 0, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 %32
store i8 %29, i8* %33
%34 = load i32, i32* %7
%35 = and i32 %34, 2
%36 = icmp ne i32 %35, 0
%37 = zext i1 %36 to i64
%38 = select i1 %36, i32 119, i32 45
%39 = trunc i32 %38 to i8
%40 = load i32, i32* %6
%41 = add nsw i32 1, %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 %42
store i8 %39, i8* %43
%44 = load i32, i32* %7
%45 = and i32 %44, 4
%46 = icmp ne i32 %45, 0
%47 = zext i1 %46 to i64
%48 = select i1 %46, i32 120, i32 45
%49 = trunc i32 %48 to i8
%50 = load i32, i32* %6
%51 = add nsw i32 2, %50
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 %52
store i8 %49, i8* %53
br label %54
54: ; preds = %13
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %5
br label %10
57: ; preds = %10
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%59 = load i8*, i8** %4
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %59)
%61 = load %struct.stat*, %struct.stat** %3
%62 = getelementptr inbounds %struct.stat, %struct.stat* %61, i32 0, i32 1
%63 = load i32, i32* %62
%64 = load %struct.stat*, %struct.stat** %3
%65 = getelementptr inbounds %struct.stat, %struct.stat* %64, i32 0, i32 2
%66 = load i32, i32* %65
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %63, i32 %66)
%68 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %68)
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
@.str.1 = [29 x i8] c"Dateiinfirmationen zu: '%s'\0A\00"
@.str.2 = [43 x i8] c"Dateibesitzer: User %d, Gruppe %d\0A\00"
@.str.3 = [27 x i8] c"Zugrifsrechte: %s\0A\00"
define void @print_access(%struct.stat* nocapture %0, i8* %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 9
store i8 0, i8* %5
%6 = getelementptr inbounds %struct.stat, %struct.stat* %0, i64 0, i32 0
%7 = load i32, i32* %6
%8 = and i32 %7, 1
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8 45, i8 114
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 6
store i8 %10, i8* %11
%12 = insertelement <8 x i32> poison, i32 %7, i64 0
%13 = shufflevector <8 x i32> %12, <8 x i32> poison, <8 x i32> zeroinitializer
%14 = and <8 x i32> %13, <i32 256, i32 128, i32 64, i32 32, i32 16, i32 8, i32 4, i32 2>
%15 = icmp eq <8 x i32> %14, zeroinitializer
%16 = extractelement <8 x i1> %15, i64 7
%17 = select i1 %16, i8 45, i8 119
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 7
store i8 %17, i8* %18
%19 = extractelement <8 x i1> %15, i64 6
%20 = select i1 %19, i8 45, i8 120
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 8
store i8 %20, i8* %21
%22 = extractelement <8 x i1> %15, i64 5
%23 = select i1 %22, i8 45, i8 114
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
store i8 %23, i8* %24
%25 = extractelement <8 x i1> %15, i64 4
%26 = select i1 %25, i8 45, i8 119
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 4
store i8 %26, i8* %27
%28 = extractelement <8 x i1> %15, i64 3
%29 = select i1 %28, i8 45, i8 120
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 5
store i8 %29, i8* %30
%31 = extractelement <8 x i1> %15, i64 2
%32 = select i1 %31, i8 45, i8 114
store i8 %32, i8* %4
%33 = extractelement <8 x i1> %15, i64 1
%34 = select i1 %33, i8 45, i8 119
%35 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 1
store i8 %34, i8* %35
%36 = extractelement <8 x i1> %15, i64 0
%37 = select i1 %36, i8 45, i8 120
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 2
store i8 %37, i8* %38
%39 = tail call i32 @putchar(i32 10)
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%41 = getelementptr inbounds %struct.stat, %struct.stat* %0, i64 0, i32 1
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.stat, %struct.stat* %0, i64 0, i32 2
%44 = load i32, i32* %43
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %42, i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%47 = call i32 @putchar(i32 10)
ret void
}