#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void display_permission(const struct stat *stat) {
  int number = stat->st_mode;
  int x = 0;
  while (number) {
    if (x == 9)
      break;
    if ((x % 3) == 0 && x > 2)
      fprintf(stderr, " ");
    if (number & 1)
      fprintf(stderr, "1");
    else
      fprintf(stderr, "0");
    number >>= 1;
    x++;
  }
  fprintf(stderr, "\n\t\t\t   O   G   U\n");
}


x86 assembly (clang, -O0):
<display_permission>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11cd <display_permission+0xbd>
cmpl   $0x9,-0x10(%rbp)
jne    1145 <display_permission+0x35>
jmp    11cd <display_permission+0xbd>
mov    -0x10(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1178 <display_permission+0x68>
cmpl   $0x2,-0x10(%rbp)
jle    1178 <display_permission+0x68>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a1 <display_permission+0x91>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11b6 <display_permission+0xa6>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112c <display_permission+0x1c>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_permission>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%ebp
test   %ebp,%ebp
je     118b <display_permission+0x7b>
xor    %ebx,%ebx
mov    $0xaaaaaaab,%r15d
mov    0x2eb0(%rip),%r12
lea    0xecd(%rip),%r13
lea    0xec4(%rip),%r14
xchg   %ax,%ax
cmp    $0x3,%ebx
jb     1166 <display_permission+0x56>
mov    %ebx,%eax
imul   %r15,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%eax
cmp    %ebx,%eax
jne    1166 <display_permission+0x56>
mov    (%r12),%edi
lea    0xe9f(%rip),%rsi
call   1030 <fprintf@plt>
test   $0x1,%bpl
mov    (%r12),%edi
mov    %r14,%rsi
cmove  %r13,%rsi
call   1030 <fprintf@plt>
cmp    $0x2,%ebp
jb     118b <display_permission+0x7b>
sar    %ebp
lea    0x1(%rbx),%eax
cmp    $0x8,%ebx
mov    %eax,%ebx
jne    1140 <display_permission+0x30>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [18 x i8] c"\0A\09\09\09 O G U\0A\00"
define void @display_permission(%struct.stat* %0) {
%2 = alloca %struct.stat*
%3 = alloca i32
%4 = alloca i32
store %struct.stat* %0, %struct.stat** %2
%5 = load %struct.stat*, %struct.stat** %2
%6 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%7 = load i32, i32* %6
store i32 %7, i32* %3
store i32 0, i32* %4
br label %8
8: ; preds = %35, %1
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %40
11: ; preds = %8
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 9
br i1 %13, label %14, label %15
14: ; preds = %11
br label %40
15: ; preds = %11
%16 = load i32, i32* %4
%17 = srem i32 %16, 3
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 2
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %22, %19, %15
%26 = load i32, i32* %3
%27 = and i32 %26, 1
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %35
32: ; preds = %25
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %32, %29
%36 = load i32, i32* %3
%37 = ashr i32 %36, 1
store i32 %37, i32* %3
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %8
40: ; preds = %14, %8
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [18 x i8] c"\0A\09\09\09 O G U\0A\00"
define void @display_permission(%struct.stat* nocapture %0) {
%2 = getelementptr inbounds %struct.stat, %struct.stat* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 0
br i1 %4, label %26, label %5
5: ; preds = %1, %15
%6 = phi i32 [ %22, %15 ], [ 0, %1 ]
%7 = phi i32 [ %21, %15 ], [ %3, %1 ]
%8 = urem i32 %6, 3
%9 = icmp eq i32 %8, 0
%10 = icmp ugt i32 %6, 2
%11 = and i1 %10, %9
br i1 %11, label %12, label %15
12: ; preds = %5
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %12, %5
%16 = and i32 %7, 1
%17 = icmp eq i32 %16, 0
%18 = load i32, i32* @stderr
%19 = select i1 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%20 = tail call i32 @fprintf(i32 %18, i8* %19)
%21 = ashr i32 %7, 1
%22 = add nuw nsw i32 %6, 1
%23 = icmp ult i32 %7, 2
%24 = icmp eq i32 %22, 9
%25 = select i1 %23, i1 true, i1 %24
br i1 %25, label %26, label %5
26: ; preds = %15, %1
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
ret void
}