#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_IRGRP;
int S_IROTH;
int S_IRUSR;
scalar_t__ S_ISDIR(int);
scalar_t__ S_ISFIFO(int);
scalar_t__ S_ISLNK(int);
scalar_t__ S_ISSOCK(int);
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void disp_mode(mode_t mode) {
  char m[11];
  strcpy(m, "----------");
  if (S_ISDIR(mode)) {
    m[0] = 'd';
  } else if (S_ISLNK(mode)) {
    m[0] = 'l';
  } else if (S_ISFIFO(mode)) {
    m[0] = 'p';
  } else if (S_ISSOCK(mode)) {
    m[0] = 's';
  }
  if (mode & S_IRUSR) {
    m[1] = 'r';
  }
  if (mode & S_IWUSR) {
    m[2] = 'w';
  }
  if (mode & S_IXUSR) {
    m[3] = 'x';
  }
  if (mode & S_IRGRP) {
    m[4] = 'r';
  }
  if (mode & S_IWGRP) {
    m[5] = 'w';
  }
  if (mode & S_IXGRP) {
    m[6] = 'x';
  }
  if (mode & S_IROTH) {
    m[7] = 'r';
  }
  if (mode & S_IWOTH) {
    m[8] = 'w';
  }
  if (mode & S_IXOTH) {
    m[9] = 'x';
  }
  printf("%s", m);
}


x86 assembly (clang, -O0):
<disp_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0xf(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%edi
call   1080 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1196 <disp_mode+0x36>
movb   $0x64,-0xf(%rbp)
jmp    11f1 <disp_mode+0x91>
mov    -0x4(%rbp),%edi
call   1040 <S_ISLNK@plt>
cmp    $0x0,%rax
je     11b1 <disp_mode+0x51>
movb   $0x6c,-0xf(%rbp)
jmp    11ec <disp_mode+0x8c>
mov    -0x4(%rbp),%edi
call   1050 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     11cc <disp_mode+0x6c>
movb   $0x70,-0xf(%rbp)
jmp    11e7 <disp_mode+0x87>
mov    -0x4(%rbp),%edi
call   1060 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     11e2 <disp_mode+0x82>
movb   $0x73,-0xf(%rbp)
jmp    11e7 <disp_mode+0x87>
jmp    11ec <disp_mode+0x8c>
jmp    11f1 <disp_mode+0x91>
mov    -0x4(%rbp),%eax
mov    0x2dad(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     120a <disp_mode+0xaa>
movb   $0x72,-0xe(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2dbc(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1223 <disp_mode+0xc3>
movb   $0x77,-0xd(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2db3(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     123c <disp_mode+0xdc>
movb   $0x78,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2d72(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1255 <disp_mode+0xf5>
movb   $0x72,-0xb(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2d79(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     126e <disp_mode+0x10e>
movb   $0x77,-0xa(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2d50(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1287 <disp_mode+0x127>
movb   $0x78,-0x9(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2d1f(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12a0 <disp_mode+0x140>
movb   $0x72,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2cee(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12b9 <disp_mode+0x159>
movb   $0x77,-0x7(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2d25(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12d2 <disp_mode+0x172>
movb   $0x78,-0x6(%rbp)
lea    -0xf(%rbp),%rsi
lea    0xd2e(%rip),%rdi
call   1070 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disp_mode>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xe92(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1030 <strcpy@plt>
mov    %ebx,%edi
call   1080 <S_ISDIR@plt>
test   %rax,%rax
je     118b <disp_mode+0x2b>
movb   $0x64,0x5(%rsp)
jmp    11c2 <disp_mode+0x62>
mov    %ebx,%edi
call   1040 <S_ISLNK@plt>
test   %rax,%rax
je     119e <disp_mode+0x3e>
movb   $0x6c,0x5(%rsp)
jmp    11c2 <disp_mode+0x62>
mov    %ebx,%edi
call   1050 <S_ISFIFO@plt>
test   %rax,%rax
je     11b1 <disp_mode+0x51>
movb   $0x70,0x5(%rsp)
jmp    11c2 <disp_mode+0x62>
mov    %ebx,%edi
call   1060 <S_ISSOCK@plt>
test   %rax,%rax
je     11c2 <disp_mode+0x62>
movb   $0x73,0x5(%rsp)
mov    0x2ddf(%rip),%rax
test   %ebx,(%rax)
je     11d2 <disp_mode+0x72>
movb   $0x72,0x6(%rsp)
mov    0x2df7(%rip),%rax
test   %ebx,(%rax)
je     11e2 <disp_mode+0x82>
movb   $0x77,0x7(%rsp)
mov    0x2df7(%rip),%rax
test   %ebx,(%rax)
je     11f2 <disp_mode+0x92>
movb   $0x78,0x8(%rsp)
mov    0x2dbf(%rip),%rax
test   %ebx,(%rax)
je     1202 <disp_mode+0xa2>
movb   $0x72,0x9(%rsp)
mov    0x2dcf(%rip),%rax
test   %ebx,(%rax)
je     1212 <disp_mode+0xb2>
movb   $0x77,0xa(%rsp)
mov    0x2daf(%rip),%rax
test   %ebx,(%rax)
je     1222 <disp_mode+0xc2>
movb   $0x78,0xb(%rsp)
mov    0x2d87(%rip),%rax
test   %ebx,(%rax)
je     1232 <disp_mode+0xd2>
movb   $0x72,0xc(%rsp)
mov    0x2d5f(%rip),%rax
test   %ebx,(%rax)
je     1242 <disp_mode+0xe2>
movb   $0x77,0xd(%rsp)
mov    0x2d9f(%rip),%rax
test   %ebx,(%rax)
je     1252 <disp_mode+0xf2>
movb   $0x78,0xe(%rsp)
lea    0xdb2(%rip),%rdi
lea    0x5(%rsp),%rsi
call   1070 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"----------\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
@.str.1 = [3 x i8] c"%s\00"
define void @disp_mode(i32 %0) {
%2 = alloca i32
%3 = alloca [11 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* %2
%7 = call i64 @S_ISDIR(i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
store i8 100, i8* %10
br label %32
11: ; preds = %1
%12 = load i32, i32* %2
%13 = call i64 @S_ISLNK(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
store i8 108, i8* %16
br label %31
17: ; preds = %11
%18 = load i32, i32* %2
%19 = call i64 @S_ISFIFO(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
store i8 112, i8* %22
br label %30
23: ; preds = %17
%24 = load i32, i32* %2
%25 = call i64 @S_ISSOCK(i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
store i8 115, i8* %28
br label %29
29: ; preds = %27, %23
br label %30
30: ; preds = %29, %21
br label %31
31: ; preds = %30, %15
br label %32
32: ; preds = %31, %9
%33 = load i32, i32* %2
%34 = load i32, i32* @S_IRUSR
%35 = and i32 %33, %34
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 1
store i8 114, i8* %38
br label %39
39: ; preds = %37, %32
%40 = load i32, i32* %2
%41 = load i32, i32* @S_IWUSR
%42 = and i32 %40, %41
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 2
store i8 119, i8* %45
br label %46
46: ; preds = %44, %39
%47 = load i32, i32* %2
%48 = load i32, i32* @S_IXUSR
%49 = and i32 %47, %48
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 3
store i8 120, i8* %52
br label %53
53: ; preds = %51, %46
%54 = load i32, i32* %2
%55 = load i32, i32* @S_IRGRP
%56 = and i32 %54, %55
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 4
store i8 114, i8* %59
br label %60
60: ; preds = %58, %53
%61 = load i32, i32* %2
%62 = load i32, i32* @S_IWGRP
%63 = and i32 %61, %62
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %60
%66 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 5
store i8 119, i8* %66
br label %67
67: ; preds = %65, %60
%68 = load i32, i32* %2
%69 = load i32, i32* @S_IXGRP
%70 = and i32 %68, %69
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %67
%73 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 6
store i8 120, i8* %73
br label %74
74: ; preds = %72, %67
%75 = load i32, i32* %2
%76 = load i32, i32* @S_IROTH
%77 = and i32 %75, %76
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %74
%80 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 7
store i8 114, i8* %80
br label %81
81: ; preds = %79, %74
%82 = load i32, i32* %2
%83 = load i32, i32* @S_IWOTH
%84 = and i32 %82, %83
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %88
86: ; preds = %81
%87 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 8
store i8 119, i8* %87
br label %88
88: ; preds = %86, %81
%89 = load i32, i32* %2
%90 = load i32, i32* @S_IXOTH
%91 = and i32 %89, %90
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %88
%94 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 9
store i8 120, i8* %94
br label %95
95: ; preds = %93, %88
%96 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%97 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %96)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"----------\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
@.str.1 = [3 x i8] c"%s\00"
define void @disp_mode(i32 %0) {
%2 = alloca [11 x i8]
%3 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = call i64 @S_ISDIR(i32 %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i8 100, i8* %3
br label %20
8: ; preds = %1
%9 = call i64 @S_ISLNK(i32 %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %8
store i8 108, i8* %3
br label %20
12: ; preds = %8
%13 = call i64 @S_ISFIFO(i32 %0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %12
store i8 112, i8* %3
br label %20
16: ; preds = %12
%17 = call i64 @S_ISSOCK(i32 %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %16
store i8 115, i8* %3
br label %20
20: ; preds = %11, %16, %19, %15, %7
%21 = load i32, i32* @S_IRUSR
%22 = and i32 %21, %0
%23 = icmp eq i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 1
store i8 114, i8* %25
br label %26
26: ; preds = %24, %20
%27 = load i32, i32* @S_IWUSR
%28 = and i32 %27, %0
%29 = icmp eq i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 2
store i8 119, i8* %31
br label %32
32: ; preds = %30, %26
%33 = load i32, i32* @S_IXUSR
%34 = and i32 %33, %0
%35 = icmp eq i32 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %32
%37 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 3
store i8 120, i8* %37
br label %38
38: ; preds = %36, %32
%39 = load i32, i32* @S_IRGRP
%40 = and i32 %39, %0
%41 = icmp eq i32 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %38
%43 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 4
store i8 114, i8* %43
br label %44
44: ; preds = %42, %38
%45 = load i32, i32* @S_IWGRP
%46 = and i32 %45, %0
%47 = icmp eq i32 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %44
%49 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 5
store i8 119, i8* %49
br label %50
50: ; preds = %48, %44
%51 = load i32, i32* @S_IXGRP
%52 = and i32 %51, %0
%53 = icmp eq i32 %52, 0
br i1 %53, label %56, label %54
54: ; preds = %50
%55 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 6
store i8 120, i8* %55
br label %56
56: ; preds = %54, %50
%57 = load i32, i32* @S_IROTH
%58 = and i32 %57, %0
%59 = icmp eq i32 %58, 0
br i1 %59, label %62, label %60
60: ; preds = %56
%61 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 7
store i8 114, i8* %61
br label %62
62: ; preds = %60, %56
%63 = load i32, i32* @S_IWOTH
%64 = and i32 %63, %0
%65 = icmp eq i32 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %62
%67 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 8
store i8 119, i8* %67
br label %68
68: ; preds = %66, %62
%69 = load i32, i32* @S_IXOTH
%70 = and i32 %69, %0
%71 = icmp eq i32 %70, 0
br i1 %71, label %74, label %72
72: ; preds = %68
%73 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 9
store i8 120, i8* %73
br label %74
74: ; preds = %72, %68
%75 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret void
}