#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 S_IRGRP;
int S_IROTH;
int S_IRUSR;
scalar_t__ S_ISBLK(int);
scalar_t__ S_ISCHR(int);
scalar_t__ S_ISDIR(int);
scalar_t__ S_ISFIFO(int);
int S_ISGID;
scalar_t__ S_ISLNK(int);
scalar_t__ S_ISREG(int);
scalar_t__ S_ISSOCK(int);
int S_ISUID;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
void ls(char *path) {
  static struct stat buff;
  if (lstat(path, &buff) < 0) {
    perror("lstat error");
    return;
  }
  printf("%s: ", path);
  if (S_ISREG(buff.st_mode))
    printf("REGULAR");
  else if (S_ISDIR(buff.st_mode))
    printf("DIRECTORY");
  else if (S_ISLNK(buff.st_mode))
    printf("SYMLINK");
  else if (S_ISFIFO(buff.st_mode))
    printf("FIFO");
  else if (S_ISBLK(buff.st_mode))
    printf("BLOCK");
  else if (S_ISCHR(buff.st_mode))
    printf("CHAR");
  else if (S_ISSOCK(buff.st_mode))
    printf("SOCKET");
  else
    printf("*UNKNOW*");
  if (buff.st_mode & S_ISUID)
    printf(" SETUID");
  if (buff.st_mode & S_ISGID)
    printf(" SETGID");
  printf(" ");
  if (S_IRUSR & buff.st_mode)
    printf("r");
  else
    printf("-");
  if (S_IWUSR & buff.st_mode)
    printf("w");
  else
    printf("-");
  if (S_IXUSR & buff.st_mode)
    printf("x");
  else
    printf("-");
  if (S_IRGRP & buff.st_mode)
    printf("r");
  else
    printf("-");
  if (S_IWGRP & buff.st_mode)
    printf("w");
  else
    printf("-");
  if (S_IXGRP & buff.st_mode)
    printf("x");
  else
    printf("-");
  if (S_IROTH & buff.st_mode)
    printf("r");
  else
    printf("-");
  if (S_IWOTH & buff.st_mode)
    printf("w");
  else
    printf("-");
  if (S_IXOTH & buff.st_mode)
    printf("x");
  else
    printf("-");
  printf("\n");
}


x86 assembly (clang, -O0):
<ls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0x2ebd(%rip),%rsi
call   1080 <lstat@plt>
cmp    $0x0,%rax
jge    11d7 <ls+0x37>
lea    0xe33(%rip),%rdi
call   10c0 <perror@plt>
jmp    1596 <ls+0x3f6>
mov    -0x8(%rbp),%rsi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2e85(%rip),%edi
call   1090 <S_ISREG@plt>
cmp    $0x0,%rax
je     1211 <ls+0x71>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    132d <ls+0x18d>
mov    0x2e5d(%rip),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1239 <ls+0x99>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1328 <ls+0x188>
mov    0x2e35(%rip),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     1261 <ls+0xc1>
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1323 <ls+0x183>
mov    0x2e0d(%rip),%edi
call   1040 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     1289 <ls+0xe9>
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    131e <ls+0x17e>
mov    0x2de5(%rip),%edi
call   10b0 <S_ISBLK@plt>
cmp    $0x0,%rax
je     12b1 <ls+0x111>
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1319 <ls+0x179>
mov    0x2dbd(%rip),%edi
call   10a0 <S_ISCHR@plt>
cmp    $0x0,%rax
je     12d9 <ls+0x139>
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1314 <ls+0x174>
mov    0x2d95(%rip),%edi
call   1050 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     1301 <ls+0x161>
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    130f <ls+0x16f>
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1314 <ls+0x174>
jmp    1319 <ls+0x179>
jmp    131e <ls+0x17e>
jmp    1323 <ls+0x183>
jmp    1328 <ls+0x188>
jmp    132d <ls+0x18d>
mov    0x2d41(%rip),%eax
mov    0x2c9e(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1353 <ls+0x1b3>
lea    0xcff(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d1b(%rip),%eax
mov    0x2c50(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1379 <ls+0x1d9>
lea    0xce1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc8f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2c0a(%rip),%rax
mov    (%rax),%eax
and    0x2cde(%rip),%eax
cmp    $0x0,%eax
je     13b2 <ls+0x212>
lea    0xc64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13c0 <ls+0x220>
lea    0xca2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2c01(%rip),%rax
mov    (%rax),%eax
and    0x2ca5(%rip),%eax
cmp    $0x0,%eax
je     13eb <ls+0x24b>
lea    0xc7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13f9 <ls+0x259>
lea    0xc69(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2be0(%rip),%rax
mov    (%rax),%eax
and    0x2c6c(%rip),%eax
cmp    $0x0,%eax
je     1424 <ls+0x284>
lea    0xc47(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1432 <ls+0x292>
lea    0xc30(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2b6f(%rip),%rax
mov    (%rax),%eax
and    0x2c33(%rip),%eax
cmp    $0x0,%eax
je     145d <ls+0x2bd>
lea    0xbb9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    146b <ls+0x2cb>
lea    0xbf7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2b5e(%rip),%rax
mov    (%rax),%eax
and    0x2bfa(%rip),%eax
cmp    $0x0,%eax
je     1496 <ls+0x2f6>
lea    0xbd3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14a4 <ls+0x304>
lea    0xbbe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2b15(%rip),%rax
mov    (%rax),%eax
and    0x2bc1(%rip),%eax
cmp    $0x0,%eax
je     14cf <ls+0x32f>
lea    0xb9c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14dd <ls+0x33d>
lea    0xb85(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2abc(%rip),%rax
mov    (%rax),%eax
and    0x2b88(%rip),%eax
cmp    $0x0,%eax
je     1508 <ls+0x368>
lea    0xb0e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1516 <ls+0x376>
lea    0xb4c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2a6b(%rip),%rax
mov    (%rax),%eax
and    0x2b4f(%rip),%eax
cmp    $0x0,%eax
je     1541 <ls+0x3a1>
lea    0xb28(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    154f <ls+0x3af>
lea    0xb13(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2a92(%rip),%rax
mov    (%rax),%eax
and    0x2b16(%rip),%eax
cmp    $0x0,%eax
je     157a <ls+0x3da>
lea    0xaf1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1588 <ls+0x3e8>
lea    0xada(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xad2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ls>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x2ebb(%rip),%rsi
call   1090 <lstat@plt>
test   %rax,%rax
js     1230 <ls+0x80>
lea    0xe3a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2e9a(%rip),%edi
call   10a0 <S_ISREG@plt>
test   %rax,%rax
je     11f8 <ls+0x48>
lea    0xe1e(%rip),%rdi
jmp    12b1 <ls+0x101>
mov    0x2e7e(%rip),%edi
call   1080 <S_ISDIR@plt>
test   %rax,%rax
je     1214 <ls+0x64>
lea    0xe0a(%rip),%rdi
jmp    12b1 <ls+0x101>
mov    0x2e62(%rip),%edi
call   1040 <S_ISLNK@plt>
test   %rax,%rax
je     1246 <ls+0x96>
lea    0xdf8(%rip),%rdi
jmp    12b1 <ls+0x101>
lea    0xdc9(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    10d0 <perror@plt>
mov    0x2e30(%rip),%edi
call   1050 <S_ISFIFO@plt>
test   %rax,%rax
je     125f <ls+0xaf>
lea    0xdce(%rip),%rdi
jmp    12b1 <ls+0x101>
mov    0x2e17(%rip),%edi
call   10c0 <S_ISBLK@plt>
test   %rax,%rax
je     1278 <ls+0xc8>
lea    0xdba(%rip),%rdi
jmp    12b1 <ls+0x101>
mov    0x2dfe(%rip),%edi
call   10b0 <S_ISCHR@plt>
test   %rax,%rax
je     1291 <ls+0xe1>
lea    0xda7(%rip),%rdi
jmp    12b1 <ls+0x101>
mov    0x2de5(%rip),%edi
call   1060 <S_ISSOCK@plt>
test   %rax,%rax
lea    0xd9c(%rip),%rax
lea    0xd8e(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2dbe(%rip),%eax
mov    0x2d13(%rip),%rcx
test   %eax,(%rcx)
je     12dd <ls+0x12d>
lea    0xd7b(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d9f(%rip),%eax
mov    0x2ccc(%rip),%rcx
test   %eax,(%rcx)
je     12f6 <ls+0x146>
lea    0xd64(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    0x2c91(%rip),%rax
mov    0x2d6f(%rip),%ecx
and    (%rax),%ecx
mov    $0x2d,%ebp
mov    $0x72,%r14d
mov    $0x72,%edi
cmove  %ebp,%edi
call   1030 <putchar@plt>
mov    0x2c9a(%rip),%rax
mov    0x2d48(%rip),%ecx
and    (%rax),%ecx
mov    $0x77,%r15d
mov    $0x77,%edi
cmove  %ebp,%edi
call   1030 <putchar@plt>
mov    0x2c90(%rip),%rax
mov    0x2d26(%rip),%ecx
and    (%rax),%ecx
mov    $0x78,%ebx
mov    $0x78,%edi
cmove  %ebp,%edi
call   1030 <putchar@plt>
mov    0x2c37(%rip),%rax
mov    0x2d05(%rip),%ecx
and    (%rax),%ecx
mov    $0x72,%edi
cmove  %ebp,%edi
call   1030 <putchar@plt>
mov    0x2c43(%rip),%rax
mov    0x2ce9(%rip),%ecx
and    (%rax),%ecx
mov    $0x77,%edi
cmove  %ebp,%edi
call   1030 <putchar@plt>
mov    0x2c17(%rip),%rax
mov    0x2ccd(%rip),%ecx
and    (%rax),%ecx
mov    $0x78,%edi
cmove  %ebp,%edi
call   1030 <putchar@plt>
mov    0x2bdb(%rip),%rax
mov    0x2cb1(%rip),%ecx
and    (%rax),%ecx
cmove  %ebp,%r14d
mov    %r14d,%edi
call   1030 <putchar@plt>
mov    0x2ba8(%rip),%rax
mov    0x2c96(%rip),%ecx
and    (%rax),%ecx
cmove  %ebp,%r15d
mov    %r15d,%edi
call   1030 <putchar@plt>
mov    0x2bed(%rip),%rax
mov    0x2c7b(%rip),%ecx
and    (%rax),%ecx
cmove  %ebp,%ebx
mov    %ebx,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@ls.buff = internal global %struct.stat zeroinitializer
@.str = [12 x i8] c"lstat error\00"
@.str.1 = [5 x i8] c"%s: \00"
@.str.2 = [8 x i8] c"REGULAR\00"
@.str.3 = [10 x i8] c"DIRECTORY\00"
@.str.4 = [8 x i8] c"SYMLINK\00"
@.str.5 = [5 x i8] c"FIFO\00"
@.str.6 = [6 x i8] c"BLOCK\00"
@.str.7 = [5 x i8] c"CHAR\00"
@.str.8 = [7 x i8] c"SOCKET\00"
@.str.9 = [9 x i8] c"*UNKNOW*\00"
@S_ISUID = global i32 0
@.str.10 = [8 x i8] c" SETUID\00"
@S_ISGID = global i32 0
@.str.11 = [8 x i8] c" SETGID\00"
@.str.12 = [2 x i8] c" \00"
@S_IRUSR = global i32 0
@.str.13 = [2 x i8] c"r\00"
@.str.14 = [2 x i8] c"-\00"
@S_IWUSR = global i32 0
@.str.15 = [2 x i8] c"w\00"
@S_IXUSR = global i32 0
@.str.16 = [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.17 = [2 x i8] c"\0A\00"
define void @ls(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i64 @lstat(i8* %3, %struct.stat* @ls.buff)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %158
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%12 = call i64 @S_ISREG(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %60
16: ; preds = %8
%17 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%18 = call i64 @S_ISDIR(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %59
22: ; preds = %16
%23 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%24 = call i64 @S_ISLNK(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %58
28: ; preds = %22
%29 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%30 = call i64 @S_ISFIFO(i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %57
34: ; preds = %28
%35 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%36 = call i64 @S_ISBLK(i32 %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %56
40: ; preds = %34
%41 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%42 = call i64 @S_ISCHR(i32 %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %55
46: ; preds = %40
%47 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%48 = call i64 @S_ISSOCK(i32 %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %54
52: ; preds = %46
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %54
54: ; preds = %52, %50
br label %55
55: ; preds = %54, %44
br label %56
56: ; preds = %55, %38
br label %57
57: ; preds = %56, %32
br label %58
58: ; preds = %57, %26
br label %59
59: ; preds = %58, %20
br label %60
60: ; preds = %59, %14
%61 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%62 = load i32, i32* @S_ISUID
%63 = and i32 %61, %62
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %60
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
br label %67
67: ; preds = %65, %60
%68 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%69 = load i32, i32* @S_ISGID
%70 = and i32 %68, %69
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %67
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
br label %74
74: ; preds = %72, %67
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%76 = load i32, i32* @S_IRUSR
%77 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%78 = and i32 %76, %77
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %74
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
br label %84
82: ; preds = %74
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %84
84: ; preds = %82, %80
%85 = load i32, i32* @S_IWUSR
%86 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%87 = and i32 %85, %86
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %84
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
br label %93
91: ; preds = %84
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %93
93: ; preds = %91, %89
%94 = load i32, i32* @S_IXUSR
%95 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%96 = and i32 %94, %95
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %100
98: ; preds = %93
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
br label %102
100: ; preds = %93
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %102
102: ; preds = %100, %98
%103 = load i32, i32* @S_IRGRP
%104 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%105 = and i32 %103, %104
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %109
107: ; preds = %102
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
br label %111
109: ; preds = %102
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %111
111: ; preds = %109, %107
%112 = load i32, i32* @S_IWGRP
%113 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%114 = and i32 %112, %113
%115 = icmp ne i32 %114, 0
br i1 %115, label %116, label %118
116: ; preds = %111
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
br label %120
118: ; preds = %111
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %120
120: ; preds = %118, %116
%121 = load i32, i32* @S_IXGRP
%122 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%123 = and i32 %121, %122
%124 = icmp ne i32 %123, 0
br i1 %124, label %125, label %127
125: ; preds = %120
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
br label %129
127: ; preds = %120
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %129
129: ; preds = %127, %125
%130 = load i32, i32* @S_IROTH
%131 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%132 = and i32 %130, %131
%133 = icmp ne i32 %132, 0
br i1 %133, label %134, label %136
134: ; preds = %129
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
br label %138
136: ; preds = %129
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %138
138: ; preds = %136, %134
%139 = load i32, i32* @S_IWOTH
%140 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%141 = and i32 %139, %140
%142 = icmp ne i32 %141, 0
br i1 %142, label %143, label %145
143: ; preds = %138
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
br label %147
145: ; preds = %138
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %147
147: ; preds = %145, %143
%148 = load i32, i32* @S_IXOTH
%149 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i32 0, i32 0)
%150 = and i32 %148, %149
%151 = icmp ne i32 %150, 0
br i1 %151, label %152, label %154
152: ; preds = %147
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
br label %156
154: ; preds = %147
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %156
156: ; preds = %154, %152
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0))
br label %158
158: ; preds = %156, %6
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@ls.buff = internal global %struct.stat zeroinitializer
@.str = [12 x i8] c"lstat error\00"
@.str.1 = [5 x i8] c"%s: \00"
@.str.2 = [8 x i8] c"REGULAR\00"
@.str.3 = [10 x i8] c"DIRECTORY\00"
@.str.4 = [8 x i8] c"SYMLINK\00"
@.str.5 = [5 x i8] c"FIFO\00"
@.str.6 = [6 x i8] c"BLOCK\00"
@.str.7 = [5 x i8] c"CHAR\00"
@.str.8 = [7 x i8] c"SOCKET\00"
@.str.9 = [9 x i8] c"*UNKNOW*\00"
@S_ISUID = global i32 0
@.str.10 = [8 x i8] c" SETUID\00"
@S_ISGID = global i32 0
@.str.11 = [8 x i8] c" SETGID\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 void @ls(i8* %0) {
%2 = tail call i64 @lstat(i8* %0, %struct.stat* @ls.buff)
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %110
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%8 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%9 = tail call i64 @S_ISREG(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %36
11: ; preds = %6
%12 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%13 = tail call i64 @S_ISDIR(i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %36
15: ; preds = %11
%16 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%17 = tail call i64 @S_ISLNK(i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %36
19: ; preds = %15
%20 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%21 = tail call i64 @S_ISFIFO(i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %36
23: ; preds = %19
%24 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%25 = tail call i64 @S_ISBLK(i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%29 = tail call i64 @S_ISCHR(i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%33 = tail call i64 @S_ISSOCK(i32 %32)
%34 = icmp eq i64 %33, 0
%35 = select i1 %34, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0)
br label %36
36: ; preds = %31, %27, %23, %19, %15, %11, %6
%37 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %11 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %15 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %19 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), %23 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), %27 ], [ %35, %31 ]
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %37)
%39 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%40 = load i32, i32* @S_ISUID
%41 = and i32 %40, %39
%42 = icmp eq i32 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %36
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%45 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
br label %46
46: ; preds = %43, %36
%47 = phi i32 [ %45, %43 ], [ %39, %36 ]
%48 = load i32, i32* @S_ISGID
%49 = and i32 %48, %47
%50 = icmp eq i32 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %46
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
br label %53
53: ; preds = %51, %46
%54 = tail call i32 @putchar(i32 32)
%55 = load i32, i32* @S_IRUSR
%56 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%57 = and i32 %56, %55
%58 = icmp eq i32 %57, 0
%59 = select i1 %58, i32 45, i32 114
%60 = tail call i32 @putchar(i32 %59)
%61 = load i32, i32* @S_IWUSR
%62 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%63 = and i32 %62, %61
%64 = icmp eq i32 %63, 0
%65 = select i1 %64, i32 45, i32 119
%66 = tail call i32 @putchar(i32 %65)
%67 = load i32, i32* @S_IXUSR
%68 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%69 = and i32 %68, %67
%70 = icmp eq i32 %69, 0
%71 = select i1 %70, i32 45, i32 120
%72 = tail call i32 @putchar(i32 %71)
%73 = load i32, i32* @S_IRGRP
%74 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%75 = and i32 %74, %73
%76 = icmp eq i32 %75, 0
%77 = select i1 %76, i32 45, i32 114
%78 = tail call i32 @putchar(i32 %77)
%79 = load i32, i32* @S_IWGRP
%80 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%81 = and i32 %80, %79
%82 = icmp eq i32 %81, 0
%83 = select i1 %82, i32 45, i32 119
%84 = tail call i32 @putchar(i32 %83)
%85 = load i32, i32* @S_IXGRP
%86 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%87 = and i32 %86, %85
%88 = icmp eq i32 %87, 0
%89 = select i1 %88, i32 45, i32 120
%90 = tail call i32 @putchar(i32 %89)
%91 = load i32, i32* @S_IROTH
%92 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%93 = and i32 %92, %91
%94 = icmp eq i32 %93, 0
%95 = select i1 %94, i32 45, i32 114
%96 = tail call i32 @putchar(i32 %95)
%97 = load i32, i32* @S_IWOTH
%98 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%99 = and i32 %98, %97
%100 = icmp eq i32 %99, 0
%101 = select i1 %100, i32 45, i32 119
%102 = tail call i32 @putchar(i32 %101)
%103 = load i32, i32* @S_IXOTH
%104 = load i32, i32* getelementptr inbounds (%struct.stat, %struct.stat* @ls.buff, i64 0, i32 0)
%105 = and i32 %104, %103
%106 = icmp eq i32 %105, 0
%107 = select i1 %106, i32 45, i32 120
%108 = tail call i32 @putchar(i32 %107)
%109 = tail call i32 @putchar(i32 10)
br label %110
110: ; preds = %53, %4
ret void
}