#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ tv_sec;
};
struct stat {
  int st_mode;
  int st_gid;
  int st_uid;
  int st_blocks;
  int /*<<< orphan*/ st_size;
  scalar_t__ st_nlink;
  int /*<<< orphan*/ st_ino;
  TYPE_1__ st_mtim;
};
struct passwd {
  char *pw_name;
};
struct group {
  char *gr_name;
};

/* Variables and functions */
#define S_IFBLK 134
#define S_IFCHR 133
#define S_IFDIR 132
#define S_IFIFO 131
#define S_IFLNK 130
int S_IFMT;
#define S_IFREG 129
#define S_IFSOCK 128
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_ISGID;
scalar_t__ S_ISLNK(int);
int S_ISUID;
int S_ISVTX;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
char *alloca(int);
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *get_smlink(char const *, struct stat const *);
struct group *getgrgid(int);
struct passwd *getpwuid(int);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, long long, char *,
                          unsigned long, char *, char *, int /*<<< orphan*/,
                          char *, char const *, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char, ...);
int strlen(char *);
void print_ls(const char *filename, const struct stat *sb) {
  struct group *gp;
  struct passwd *pd;
  char *username;
  char *groupname;
  char ftpe;
  switch (sb->st_mode & S_IFMT) {
  case S_IFREG:
    ftpe = '-';
    break;
  case S_IFDIR:
    ftpe = 'd';
    break;
  case S_IFBLK:
    ftpe = 'b';
    break;
  case S_IFCHR:
    ftpe = 'c';
    break;
  case S_IFIFO:
    ftpe = 'p';
    break;
  case S_IFLNK:
    ftpe = 'l';
    break;
  case S_IFSOCK:
    ftpe = 's';
    break;
  default:
    ftpe = '?';
  }
  gp = getgrgid(sb->st_gid);
  pd = getpwuid(sb->st_uid);
  if (pd == NULL) {
    username = alloca(12);
    snprintf(username, 12, "%u", sb->st_uid);
  } else {
    username = pd->pw_name;
  }
  if (gp == NULL) {
    groupname = alloca(12);
    snprintf(groupname, 12, "%u", sb->st_gid);
  } else {
    groupname = gp->gr_name;
  }
  char *ntime = ctime(&sb->st_mtim.tv_sec) + 4;
  ntime[strlen(ntime) - 9] = '\0';
  char *permstr = alloca(sizeof(char) * 12);
  snprintf(
      permstr, 12, "%c%c%c%c%c%c%c%c%c%c", ftpe,
      (sb->st_mode & S_IRUSR) ? 'r' : '-', (sb->st_mode & S_IWUSR) ? 'w' : '-',
      (sb->st_mode & S_ISUID) ? (sb->st_mode & S_IXUSR ? 's' : 'S')
                              : (sb->st_mode & S_IXUSR ? 'x' : '-'),
      (sb->st_mode & S_IRGRP) ? 'r' : '-', (sb->st_mode & S_IWGRP) ? 'w' : '-',
      (sb->st_mode & S_ISGID) ? (sb->st_mode & S_IXGRP ? 's' : 'S')
                              : (sb->st_mode & S_IXGRP ? 'x' : '-'),
      (sb->st_mode & S_IROTH) ? 'r' : '-', (sb->st_mode & S_IWOTH) ? 'w' : '-',
      (sb->st_mode & S_ISVTX) ? (sb->st_mode & S_IXOTH ? 't' : 'T')
                              : (sb->st_mode & S_IXOTH ? 'x' : '-'));
  char *symlink = get_smlink(filename, sb);
  long long nblks = S_ISLNK(sb->st_mode) ? 0 : sb->st_blocks / 2;
  printf("%7lu %8lld %10s %3lu %-8s %-8s %8lu %12s  %s %s %s\n", sb->st_ino,
         nblks, permstr, (unsigned long)sb->st_nlink, username, groupname,
         sb->st_size, ntime, filename, (symlink ? "->" : ""),
         (symlink ? symlink : ""));
  free(symlink);
}


x86 assembly (clang, -O0):
<print_ls>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x140,%rsp
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    0x2de1(%rip),%rcx
mov    (%rcx),%ecx
and    %ecx,%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x80(%rbp)
sub    $0x6,%eax
ja     1230 <print_ls+0x90>
mov    -0x80(%rbp),%rax
lea    0xe18(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x2d,-0x51(%rbp)
jmp    1234 <print_ls+0x94>
movb   $0x64,-0x51(%rbp)
jmp    1234 <print_ls+0x94>
movb   $0x62,-0x51(%rbp)
jmp    1234 <print_ls+0x94>
movb   $0x63,-0x51(%rbp)
jmp    1234 <print_ls+0x94>
movb   $0x70,-0x51(%rbp)
jmp    1234 <print_ls+0x94>
movb   $0x6c,-0x51(%rbp)
jmp    1234 <print_ls+0x94>
movb   $0x73,-0x51(%rbp)
jmp    1234 <print_ls+0x94>
movb   $0x3f,-0x51(%rbp)
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%edi
call   1090 <getgrgid@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%edi
call   1050 <getpwuid@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1293 <print_ls+0xf3>
mov    $0xc,%edi
call   10c0 <alloca@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0xc,%esi
lea    0xd98(%rip),%rdx
movsbl %al,%ecx
mov    $0x0,%al
call   10a0 <snprintf@plt>
jmp    129e <print_ls+0xfe>
mov    -0x40(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12dd <print_ls+0x13d>
mov    $0xc,%edi
call   10c0 <alloca@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%eax
mov    $0xc,%esi
lea    0xd4e(%rip),%rdx
movsbl %al,%ecx
mov    $0x0,%al
call   10a0 <snprintf@plt>
jmp    12e8 <print_ls+0x148>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rdi
add    $0x24,%rdi
call   1060 <ctime@plt>
add    $0x4,%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x60(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0xa0(%rbp),%rax
sub    $0x9,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    $0xc,%edi
call   10c0 <alloca@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x51(%rbp),%al
mov    %al,-0x89(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x2c35(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x88(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x2c48(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x84(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    0x2c33(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     13d2 <print_ls+0x232>
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x2c23(%rip),%rax
and    (%rax),%edx
mov    $0x53,%eax
mov    $0x73,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xa4(%rbp)
jmp    13f7 <print_ls+0x257>
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x2bf9(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
mov    %eax,-0xb0(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x2b88(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xac(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x2b93(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xa8(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    0x2b46(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     148f <print_ls+0x2ef>
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x2b46(%rip),%rax
and    (%rax),%edx
mov    $0x53,%eax
mov    $0x73,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xb4(%rbp)
jmp    14b4 <print_ls+0x314>
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x2b1c(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
mov    %eax,-0xc0(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x2ac3(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xbc(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x2a86(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xb8(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    0x2ad1(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     154c <print_ls+0x3ac>
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x2ab1(%rip),%rax
and    (%rax),%edx
mov    $0x54,%eax
mov    $0x74,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xc4(%rbp)
jmp    1571 <print_ls+0x3d1>
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x2a87(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xc4(%rbp)
mov    -0xb8(%rbp),%r10d
mov    -0xbc(%rbp),%r11d
mov    -0xc0(%rbp),%ebx
mov    -0xa8(%rbp),%r14d
mov    -0xac(%rbp),%r15d
mov    -0xb0(%rbp),%r12d
mov    -0x84(%rbp),%r9d
mov    -0x88(%rbp),%r8d
mov    -0x89(%rbp),%cl
mov    -0x98(%rbp),%rdi
mov    -0xc4(%rbp),%eax
mov    $0xc,%esi
lea    0xa58(%rip),%rdx
movsbl %cl,%ecx
mov    %r12d,(%rsp)
mov    %r15d,0x8(%rsp)
mov    %r14d,0x10(%rsp)
mov    %ebx,0x18(%rsp)
mov    %r11d,0x20(%rsp)
mov    %r10d,0x28(%rsp)
mov    %eax,0x30(%rsp)
mov    $0x0,%al
call   10a0 <snprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10b0 <get_smlink@plt>
mov    %rax,-0x70(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%edi
call   1040 <S_ISLNK@plt>
cmp    $0x0,%rax
je     1624 <print_ls+0x484>
xor    %eax,%eax
mov    %eax,-0xc8(%rbp)
jmp    1639 <print_ls+0x499>
mov    -0x30(%rbp),%rax
mov    0xc(%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc8(%rbp)
mov    -0xc8(%rbp),%eax
cltq
mov    %rax,-0x78(%rbp)
mov    -0x30(%rbp),%rax
mov    0x20(%rax),%eax
mov    %eax,-0x114(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    -0x30(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x100(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0x30(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0xe4(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x70(%rbp),%rdx
lea    0x9ac(%rip),%rax
lea    0x9a6(%rip),%rcx
cmp    $0x0,%rdx
cmovne %rcx,%rax
mov    %rax,-0xd0(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     16ec <print_ls+0x54c>
mov    -0x70(%rbp),%rax
mov    %rax,-0x120(%rbp)
jmp    16ff <print_ls+0x55f>
lea    0x974(%rip),%rax
mov    %rax,-0x120(%rbp)
jmp    16ff <print_ls+0x55f>
mov    -0xd0(%rbp),%r10
mov    -0xd8(%rbp),%r11
mov    -0xe0(%rbp),%rbx
mov    -0xe4(%rbp),%r14d
mov    -0xf0(%rbp),%r15
mov    -0xf8(%rbp),%r9
mov    -0x100(%rbp),%r8
mov    -0x108(%rbp),%rcx
mov    -0x110(%rbp),%rdx
mov    -0x114(%rbp),%esi
mov    -0x120(%rbp),%rax
lea    0x8e2(%rip),%rdi
mov    %r15,(%rsp)
mov    %r14d,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1080 <printf@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
add    $0x140,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_ls>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    0x2df0(%rip),%rax
mov    (%rax),%eax
and    (%rsi),%eax
mov    %rdi,%r14
lea    -0x400(,%rax,8),%ecx
add    $0xffffff80,%eax
movabs $0x626364706c2d73,%rdx
shr    %cl,%rdx
cmp    $0x7,%eax
mov    $0x3f,%eax
cmovb  %edx,%eax
mov    %eax,(%rsp)
mov    0x4(%rsi),%edi
call   1090 <getgrgid@plt>
mov    %rax,%rbp
mov    0x8(%rbx),%edi
call   1050 <getpwuid@plt>
test   %rax,%rax
je     1206 <print_ls+0x66>
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
jmp    122f <print_ls+0x8f>
mov    $0xc,%edi
call   10c0 <alloca@plt>
movsbl 0x8(%rbx),%ecx
lea    0xde5(%rip),%rdx
mov    %rax,0x10(%rsp)
mov    %rax,%rdi
mov    $0xc,%esi
xor    %eax,%eax
call   10a0 <snprintf@plt>
test   %rbp,%rbp
mov    %r14,0x20(%rsp)
je     1244 <print_ls+0xa4>
mov    0x0(%rbp),%rax
mov    %rax,0x8(%rsp)
jmp    126d <print_ls+0xcd>
mov    $0xc,%edi
call   10c0 <alloca@plt>
movsbl 0x4(%rbx),%ecx
lea    0xda7(%rip),%rdx
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
mov    $0xc,%esi
xor    %eax,%eax
call   10a0 <snprintf@plt>
lea    0x24(%rbx),%rdi
call   1060 <ctime@plt>
mov    %rax,%rbp
lea    0x4(%rax),%rdi
mov    %rdi,0x18(%rsp)
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x5(%rax,%rbp,1)
mov    $0xc,%edi
call   10c0 <alloca@plt>
mov    %rax,%rdi
mov    (%rbx),%eax
mov    0x2ce4(%rip),%rcx
mov    (%rcx),%ecx
and    %eax,%ecx
mov    $0x2d,%ecx
mov    $0x72,%r10d
mov    $0x72,%r8d
cmove  %ecx,%r8d
mov    0x2cfc(%rip),%rdx
mov    (%rdx),%edx
and    %eax,%edx
mov    $0x77,%r11d
mov    $0x77,%r9d
cmove  %ecx,%r9d
mov    0x2cf1(%rip),%rdx
mov    (%rdx),%edx
and    %eax,%edx
mov    0x2cee(%rip),%rsi
xor    %ebp,%ebp
mov    (%rsi),%esi
and    %eax,%esi
mov    $0x78,%esi
cmove  %ecx,%esi
setne  %bpl
shl    $0x5,%ebp
or     $0x53,%ebp
test   %edx,%edx
cmove  %esi,%ebp
mov    0x2c8a(%rip),%rdx
mov    (%rdx),%edx
and    %eax,%edx
mov    $0x72,%r12d
cmove  %ecx,%r12d
mov    0x2ca5(%rip),%rdx
mov    (%rdx),%edx
and    %eax,%edx
mov    $0x77,%r13d
cmove  %ecx,%r13d
mov    0x2c68(%rip),%rdx
mov    (%rdx),%edx
and    %eax,%edx
mov    0x2c75(%rip),%rsi
xor    %r14d,%r14d
mov    (%rsi),%esi
and    %eax,%esi
mov    $0x78,%esi
cmove  %ecx,%esi
setne  %r14b
shl    $0x5,%r14d
or     $0x53,%r14d
test   %edx,%edx
cmove  %esi,%r14d
mov    0x2c25(%rip),%rdx
mov    (%rdx),%edx
and    %eax,%edx
cmove  %ecx,%r10d
mov    0x2bfe(%rip),%rdx
mov    (%rdx),%edx
and    %eax,%edx
cmove  %ecx,%r11d
mov    0x2c5f(%rip),%rdx
mov    (%rdx),%edx
and    %eax,%edx
mov    0x2c4c(%rip),%rsi
xor    %r15d,%r15d
and    (%rsi),%eax
mov    $0x78,%eax
cmove  %ecx,%eax
setne  %r15b
shl    $0x5,%r15d
or     $0x54,%r15d
test   %edx,%edx
cmove  %eax,%r15d
sub    $0x8,%rsp
movsbl 0x8(%rsp),%ecx
lea    0xc40(%rip),%rdx
mov    %rdi,0x8(%rsp)
mov    $0xc,%esi
xor    %eax,%eax
push   %r15
push   %r11
push   %r10
push   %r14
push   %r13
push   %r12
push   %rbp
call   10a0 <snprintf@plt>
add    $0x40,%rsp
mov    0x20(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   10b0 <get_smlink@plt>
mov    %rax,%r12
mov    (%rbx),%edi
call   1040 <S_ISLNK@plt>
test   %rax,%rax
je     1408 <print_ls+0x268>
xor    %edx,%edx
jmp    1417 <print_ls+0x277>
mov    0xc(%rbx),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
movslq %ecx,%rdx
mov    0x20(%rbx),%esi
mov    0x18(%rbx),%r8
mov    0x10(%rbx),%eax
test   %r12,%r12
lea    0xc20(%rip),%rcx
lea    0xc1a(%rip),%rbp
cmove  %rcx,%rbp
mov    %r12,%rbx
cmove  %rcx,%rbx
lea    0xbd4(%rip),%rdi
mov    (%rsp),%rcx
mov    0x10(%rsp),%r9
push   %rbx
push   %rbp
push   %r14
push   0x30(%rsp)
push   %rax
push   0x30(%rsp)
call   1080 <printf@plt>
add    $0x30,%rsp
mov    %r12,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32, i32, i32, i64, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.group = type { i8* }
%struct.passwd = type { i8* }
@S_IFMT = global i32 0
@.str = [3 x i8] c"%u\00"
@.str.1 = [21 x i8] c"%c%c%c%c%c%c%c%c%c%c\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_ISUID = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_ISGID = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_ISVTX = global i32 0
@S_IXOTH = global i32 0
@.str.2 = [52 x i8] c"%7lu %8lld %10s %3lu %-8s %-8s %8lu %12s %s %s %s\0A\00"
@.str.3 = [3 x i8] c"->\00"
@.str.4 = [1 x i8] zeroinitializer
define void @print_ls(i8* %0, %struct.stat* %1) {
%3 = alloca i8*
%4 = alloca %struct.stat*
%5 = alloca %struct.group*
%6 = alloca %struct.passwd*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i64
store i8* %0, i8** %3
store %struct.stat* %1, %struct.stat** %4
%14 = load %struct.stat*, %struct.stat** %4
%15 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = load i32, i32* @S_IFMT
%18 = and i32 %16, %17
switch i32 %18, label %26 [
i32 129, label %19
i32 132, label %20
i32 134, label %21
i32 133, label %22
i32 131, label %23
i32 130, label %24
i32 128, label %25
]
19: ; preds = %2
store i8 45, i8* %9
br label %27
20: ; preds = %2
store i8 100, i8* %9
br label %27
21: ; preds = %2
store i8 98, i8* %9
br label %27
22: ; preds = %2
store i8 99, i8* %9
br label %27
23: ; preds = %2
store i8 112, i8* %9
br label %27
24: ; preds = %2
store i8 108, i8* %9
br label %27
25: ; preds = %2
store i8 115, i8* %9
br label %27
26: ; preds = %2
store i8 63, i8* %9
br label %27
27: ; preds = %26, %25, %24, %23, %22, %21, %20, %19
%28 = load %struct.stat*, %struct.stat** %4
%29 = getelementptr inbounds %struct.stat, %struct.stat* %28, i32 0, i32 1
%30 = load i32, i32* %29
%31 = call %struct.group* @getgrgid(i32 %30)
store %struct.group* %31, %struct.group** %5
%32 = load %struct.stat*, %struct.stat** %4
%33 = getelementptr inbounds %struct.stat, %struct.stat* %32, i32 0, i32 2
%34 = load i32, i32* %33
%35 = call %struct.passwd* @getpwuid(i32 %34)
store %struct.passwd* %35, %struct.passwd** %6
%36 = load %struct.passwd*, %struct.passwd** %6
%37 = icmp eq %struct.passwd* %36, null
br i1 %37, label %38, label %46
38: ; preds = %27
%39 = call i8* @alloca(i32 12)
store i8* %39, i8** %7
%40 = load i8*, i8** %7
%41 = load %struct.stat*, %struct.stat** %4
%42 = getelementptr inbounds %struct.stat, %struct.stat* %41, i32 0, i32 2
%43 = load i32, i32* %42
%44 = trunc i32 %43 to i8
%45 = call i32 (i8*, i32, i8*, i8, ...) @snprintf(i8* %40, i32 12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %44)
br label %50
46: ; preds = %27
%47 = load %struct.passwd*, %struct.passwd** %6
%48 = getelementptr inbounds %struct.passwd, %struct.passwd* %47, i32 0, i32 0
%49 = load i8*, i8** %48
store i8* %49, i8** %7
br label %50
50: ; preds = %46, %38
%51 = load %struct.group*, %struct.group** %5
%52 = icmp eq %struct.group* %51, null
br i1 %52, label %53, label %61
53: ; preds = %50
%54 = call i8* @alloca(i32 12)
store i8* %54, i8** %8
%55 = load i8*, i8** %8
%56 = load %struct.stat*, %struct.stat** %4
%57 = getelementptr inbounds %struct.stat, %struct.stat* %56, i32 0, i32 1
%58 = load i32, i32* %57
%59 = trunc i32 %58 to i8
%60 = call i32 (i8*, i32, i8*, i8, ...) @snprintf(i8* %55, i32 12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %59)
br label %65
61: ; preds = %50
%62 = load %struct.group*, %struct.group** %5
%63 = getelementptr inbounds %struct.group, %struct.group* %62, i32 0, i32 0
%64 = load i8*, i8** %63
store i8* %64, i8** %8
br label %65
65: ; preds = %61, %53
%66 = load %struct.stat*, %struct.stat** %4
%67 = getelementptr inbounds %struct.stat, %struct.stat* %66, i32 0, i32 7
%68 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %67, i32 0, i32 0
%69 = call i8* @ctime(i32* %68)
%70 = getelementptr inbounds i8, i8* %69, i64 4
store i8* %70, i8** %10
%71 = load i8*, i8** %10
%72 = load i8*, i8** %10
%73 = call i32 @strlen(i8* %72)
%74 = sub nsw i32 %73, 9
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %71, i64 %75
store i8 0, i8* %76
%77 = call i8* @alloca(i32 12)
store i8* %77, i8** %11
%78 = load i8*, i8** %11
%79 = load i8, i8* %9
%80 = load %struct.stat*, %struct.stat** %4
%81 = getelementptr inbounds %struct.stat, %struct.stat* %80, i32 0, i32 0
%82 = load i32, i32* %81
%83 = load i32, i32* @S_IRUSR
%84 = and i32 %82, %83
%85 = icmp ne i32 %84, 0
%86 = zext i1 %85 to i64
%87 = select i1 %85, i32 114, i32 45
%88 = load %struct.stat*, %struct.stat** %4
%89 = getelementptr inbounds %struct.stat, %struct.stat* %88, i32 0, i32 0
%90 = load i32, i32* %89
%91 = load i32, i32* @S_IWUSR
%92 = and i32 %90, %91
%93 = icmp ne i32 %92, 0
%94 = zext i1 %93 to i64
%95 = select i1 %93, i32 119, i32 45
%96 = load %struct.stat*, %struct.stat** %4
%97 = getelementptr inbounds %struct.stat, %struct.stat* %96, i32 0, i32 0
%98 = load i32, i32* %97
%99 = load i32, i32* @S_ISUID
%100 = and i32 %98, %99
%101 = icmp ne i32 %100, 0
br i1 %101, label %102, label %111
102: ; preds = %65
%103 = load %struct.stat*, %struct.stat** %4
%104 = getelementptr inbounds %struct.stat, %struct.stat* %103, i32 0, i32 0
%105 = load i32, i32* %104
%106 = load i32, i32* @S_IXUSR
%107 = and i32 %105, %106
%108 = icmp ne i32 %107, 0
%109 = zext i1 %108 to i64
%110 = select i1 %108, i32 115, i32 83
br label %120
111: ; preds = %65
%112 = load %struct.stat*, %struct.stat** %4
%113 = getelementptr inbounds %struct.stat, %struct.stat* %112, i32 0, i32 0
%114 = load i32, i32* %113
%115 = load i32, i32* @S_IXUSR
%116 = and i32 %114, %115
%117 = icmp ne i32 %116, 0
%118 = zext i1 %117 to i64
%119 = select i1 %117, i32 120, i32 45
br label %120
120: ; preds = %111, %102
%121 = phi i32 [ %110, %102 ], [ %119, %111 ]
%122 = load %struct.stat*, %struct.stat** %4
%123 = getelementptr inbounds %struct.stat, %struct.stat* %122, i32 0, i32 0
%124 = load i32, i32* %123
%125 = load i32, i32* @S_IRGRP
%126 = and i32 %124, %125
%127 = icmp ne i32 %126, 0
%128 = zext i1 %127 to i64
%129 = select i1 %127, i32 114, i32 45
%130 = load %struct.stat*, %struct.stat** %4
%131 = getelementptr inbounds %struct.stat, %struct.stat* %130, i32 0, i32 0
%132 = load i32, i32* %131
%133 = load i32, i32* @S_IWGRP
%134 = and i32 %132, %133
%135 = icmp ne i32 %134, 0
%136 = zext i1 %135 to i64
%137 = select i1 %135, i32 119, i32 45
%138 = load %struct.stat*, %struct.stat** %4
%139 = getelementptr inbounds %struct.stat, %struct.stat* %138, i32 0, i32 0
%140 = load i32, i32* %139
%141 = load i32, i32* @S_ISGID
%142 = and i32 %140, %141
%143 = icmp ne i32 %142, 0
br i1 %143, label %144, label %153
144: ; preds = %120
%145 = load %struct.stat*, %struct.stat** %4
%146 = getelementptr inbounds %struct.stat, %struct.stat* %145, i32 0, i32 0
%147 = load i32, i32* %146
%148 = load i32, i32* @S_IXGRP
%149 = and i32 %147, %148
%150 = icmp ne i32 %149, 0
%151 = zext i1 %150 to i64
%152 = select i1 %150, i32 115, i32 83
br label %162
153: ; preds = %120
%154 = load %struct.stat*, %struct.stat** %4
%155 = getelementptr inbounds %struct.stat, %struct.stat* %154, i32 0, i32 0
%156 = load i32, i32* %155
%157 = load i32, i32* @S_IXGRP
%158 = and i32 %156, %157
%159 = icmp ne i32 %158, 0
%160 = zext i1 %159 to i64
%161 = select i1 %159, i32 120, i32 45
br label %162
162: ; preds = %153, %144
%163 = phi i32 [ %152, %144 ], [ %161, %153 ]
%164 = load %struct.stat*, %struct.stat** %4
%165 = getelementptr inbounds %struct.stat, %struct.stat* %164, i32 0, i32 0
%166 = load i32, i32* %165
%167 = load i32, i32* @S_IROTH
%168 = and i32 %166, %167
%169 = icmp ne i32 %168, 0
%170 = zext i1 %169 to i64
%171 = select i1 %169, i32 114, i32 45
%172 = load %struct.stat*, %struct.stat** %4
%173 = getelementptr inbounds %struct.stat, %struct.stat* %172, i32 0, i32 0
%174 = load i32, i32* %173
%175 = load i32, i32* @S_IWOTH
%176 = and i32 %174, %175
%177 = icmp ne i32 %176, 0
%178 = zext i1 %177 to i64
%179 = select i1 %177, i32 119, i32 45
%180 = load %struct.stat*, %struct.stat** %4
%181 = getelementptr inbounds %struct.stat, %struct.stat* %180, i32 0, i32 0
%182 = load i32, i32* %181
%183 = load i32, i32* @S_ISVTX
%184 = and i32 %182, %183
%185 = icmp ne i32 %184, 0
br i1 %185, label %186, label %195
186: ; preds = %162
%187 = load %struct.stat*, %struct.stat** %4
%188 = getelementptr inbounds %struct.stat, %struct.stat* %187, i32 0, i32 0
%189 = load i32, i32* %188
%190 = load i32, i32* @S_IXOTH
%191 = and i32 %189, %190
%192 = icmp ne i32 %191, 0
%193 = zext i1 %192 to i64
%194 = select i1 %192, i32 116, i32 84
br label %204
195: ; preds = %162
%196 = load %struct.stat*, %struct.stat** %4
%197 = getelementptr inbounds %struct.stat, %struct.stat* %196, i32 0, i32 0
%198 = load i32, i32* %197
%199 = load i32, i32* @S_IXOTH
%200 = and i32 %198, %199
%201 = icmp ne i32 %200, 0
%202 = zext i1 %201 to i64
%203 = select i1 %201, i32 120, i32 45
br label %204
204: ; preds = %195, %186
%205 = phi i32 [ %194, %186 ], [ %203, %195 ]
%206 = call i32 (i8*, i32, i8*, i8, ...) @snprintf(i8* %78, i32 12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8 signext %79, i32 %87, i32 %95, i32 %121, i32 %129, i32 %137, i32 %163, i32 %171, i32 %179, i32 %205)
%207 = load i8*, i8** %3
%208 = load %struct.stat*, %struct.stat** %4
%209 = call i8* @get_smlink(i8* %207, %struct.stat* %208)
store i8* %209, i8** %12
%210 = load %struct.stat*, %struct.stat** %4
%211 = getelementptr inbounds %struct.stat, %struct.stat* %210, i32 0, i32 0
%212 = load i32, i32* %211
%213 = call i64 @S_ISLNK(i32 %212)
%214 = icmp ne i64 %213, 0
br i1 %214, label %215, label %216
215: ; preds = %204
br label %221
216: ; preds = %204
%217 = load %struct.stat*, %struct.stat** %4
%218 = getelementptr inbounds %struct.stat, %struct.stat* %217, i32 0, i32 3
%219 = load i32, i32* %218
%220 = sdiv i32 %219, 2
br label %221
221: ; preds = %216, %215
%222 = phi i32 [ 0, %215 ], [ %220, %216 ]
%223 = sext i32 %222 to i64
store i64 %223, i64* %13
%224 = load %struct.stat*, %struct.stat** %4
%225 = getelementptr inbounds %struct.stat, %struct.stat* %224, i32 0, i32 6
%226 = load i32, i32* %225
%227 = load i64, i64* %13
%228 = load i8*, i8** %11
%229 = load %struct.stat*, %struct.stat** %4
%230 = getelementptr inbounds %struct.stat, %struct.stat* %229, i32 0, i32 5
%231 = load i64, i64* %230
%232 = load i8*, i8** %7
%233 = load i8*, i8** %8
%234 = load %struct.stat*, %struct.stat** %4
%235 = getelementptr inbounds %struct.stat, %struct.stat* %234, i32 0, i32 4
%236 = load i32, i32* %235
%237 = load i8*, i8** %10
%238 = load i8*, i8** %3
%239 = load i8*, i8** %12
%240 = icmp ne i8* %239, null
%241 = zext i1 %240 to i64
%242 = select i1 %240, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%243 = load i8*, i8** %12
%244 = icmp ne i8* %243, null
br i1 %244, label %245, label %247
245: ; preds = %221
%246 = load i8*, i8** %12
br label %248
247: ; preds = %221
br label %248
248: ; preds = %247, %245
%249 = phi i8* [ %246, %245 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), %247 ]
%250 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %226, i64 %227, i8* %228, i64 %231, i8* %232, i8* %233, i32 %236, i8* %237, i8* %238, i8* %242, i8* %249)
%251 = load i8*, i8** %12
%252 = call i32 @free(i8* %251)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32, i32, i64, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.group = type { i8* }
%struct.passwd = type { i8* }
@S_IFMT = global i32 0
@.str = [3 x i8] c"%u\00"
@.str.1 = [21 x i8] c"%c%c%c%c%c%c%c%c%c%c\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_ISUID = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_ISGID = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_ISVTX = global i32 0
@S_IXOTH = global i32 0
@.str.2 = [52 x i8] c"%7lu %8lld %10s %3lu %-8s %-8s %8lu %12s %s %s %s\0A\00"
@.str.3 = [3 x i8] c"->\00"
@.str.4 = [1 x i8] zeroinitializer
define void @print_ls(i8* %0, %struct.stat* %1) {
%3 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%4 = load i32, i32* %3
%5 = load i32, i32* @S_IFMT
%6 = and i32 %5, %4
%7 = add i32 %6, -128
%8 = icmp ult i32 %7, 7
%9 = zext i32 %7 to i56
%10 = shl nuw nsw i56 %9, 3
%11 = lshr i56 27693830751661427, %10
%12 = trunc i56 %11 to i8
%13 = select i1 %8, i8 %12, i8 63
%14 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%15 = load i32, i32* %14
%16 = tail call %struct.group* @getgrgid(i32 %15)
%17 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 2
%18 = load i32, i32* %17
%19 = tail call %struct.passwd* @getpwuid(i32 %18)
%20 = icmp eq %struct.passwd* %19, null
br i1 %20, label %21, label %26
21: ; preds = %2
%22 = tail call i8* @alloca(i32 12)
%23 = load i32, i32* %17
%24 = trunc i32 %23 to i8
%25 = tail call i32 (i8*, i32, i8*, i8, ...) @snprintf(i8* %22, i32 12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %24)
br label %29
26: ; preds = %2
%27 = getelementptr inbounds %struct.passwd, %struct.passwd* %19, i64 0, i32 0
%28 = load i8*, i8** %27
br label %29
29: ; preds = %26, %21
%30 = phi i8* [ %22, %21 ], [ %28, %26 ]
%31 = icmp eq %struct.group* %16, null
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = tail call i8* @alloca(i32 12)
%34 = load i32, i32* %14
%35 = trunc i32 %34 to i8
%36 = tail call i32 (i8*, i32, i8*, i8, ...) @snprintf(i8* %33, i32 12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %35)
br label %40
37: ; preds = %29
%38 = getelementptr inbounds %struct.group, %struct.group* %16, i64 0, i32 0
%39 = load i8*, i8** %38
br label %40
40: ; preds = %37, %32
%41 = phi i8* [ %33, %32 ], [ %39, %37 ]
%42 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 7, i32 0
%43 = tail call i8* @ctime(i32* %42)
%44 = getelementptr inbounds i8, i8* %43, i64 4
%45 = tail call i32 @strlen(i8* %44)
%46 = add nsw i32 %45, -9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %44, i64 %47
store i8 0, i8* %48
%49 = tail call i8* @alloca(i32 12)
%50 = load i32, i32* %3
%51 = load i32, i32* @S_IRUSR
%52 = and i32 %51, %50
%53 = icmp eq i32 %52, 0
%54 = select i1 %53, i32 45, i32 114
%55 = load i32, i32* @S_IWUSR
%56 = and i32 %55, %50
%57 = icmp eq i32 %56, 0
%58 = select i1 %57, i32 45, i32 119
%59 = load i32, i32* @S_ISUID
%60 = and i32 %59, %50
%61 = icmp eq i32 %60, 0
%62 = load i32, i32* @S_IXUSR
%63 = and i32 %62, %50
%64 = icmp eq i32 %63, 0
%65 = select i1 %64, i32 83, i32 115
%66 = select i1 %64, i32 45, i32 120
%67 = select i1 %61, i32 %66, i32 %65
%68 = load i32, i32* @S_IRGRP
%69 = and i32 %68, %50
%70 = icmp eq i32 %69, 0
%71 = select i1 %70, i32 45, i32 114
%72 = load i32, i32* @S_IWGRP
%73 = and i32 %72, %50
%74 = icmp eq i32 %73, 0
%75 = select i1 %74, i32 45, i32 119
%76 = load i32, i32* @S_ISGID
%77 = and i32 %76, %50
%78 = icmp eq i32 %77, 0
%79 = load i32, i32* @S_IXGRP
%80 = and i32 %79, %50
%81 = icmp eq i32 %80, 0
%82 = select i1 %81, i32 83, i32 115
%83 = select i1 %81, i32 45, i32 120
%84 = select i1 %78, i32 %83, i32 %82
%85 = load i32, i32* @S_IROTH
%86 = and i32 %85, %50
%87 = icmp eq i32 %86, 0
%88 = select i1 %87, i32 45, i32 114
%89 = load i32, i32* @S_IWOTH
%90 = and i32 %89, %50
%91 = icmp eq i32 %90, 0
%92 = select i1 %91, i32 45, i32 119
%93 = load i32, i32* @S_ISVTX
%94 = and i32 %93, %50
%95 = icmp eq i32 %94, 0
%96 = load i32, i32* @S_IXOTH
%97 = and i32 %96, %50
%98 = icmp eq i32 %97, 0
%99 = select i1 %98, i32 84, i32 116
%100 = select i1 %98, i32 45, i32 120
%101 = select i1 %95, i32 %100, i32 %99
%102 = tail call i32 (i8*, i32, i8*, i8, ...) @snprintf(i8* %49, i32 12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8 signext %13, i32 %54, i32 %58, i32 %67, i32 %71, i32 %75, i32 %84, i32 %88, i32 %92, i32 %101)
%103 = tail call i8* @get_smlink(i8* %0, %struct.stat* %1)
%104 = load i32, i32* %3
%105 = tail call i64 @S_ISLNK(i32 %104)
%106 = icmp eq i64 %105, 0
br i1 %106, label %107, label %112
107: ; preds = %40
%108 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 3
%109 = load i32, i32* %108
%110 = sdiv i32 %109, 2
%111 = sext i32 %110 to i64
br label %112
112: ; preds = %40, %107
%113 = phi i64 [ %111, %107 ], [ 0, %40 ]
%114 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 6
%115 = load i32, i32* %114
%116 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 5
%117 = load i64, i64* %116
%118 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 4
%119 = load i32, i32* %118
%120 = icmp eq i8* %103, null
%121 = select i1 %120, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%122 = select i1 %120, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* %103
%123 = tail call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %115, i64 %113, i8* %49, i64 %117, i8* %30, i8* %41, i32 %119, i8* %44, i8* %0, i8* %121, i8* %122)
%124 = tail call i32 @free(i8* %103)
ret void
}