#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 dummy;
};
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
int lstat(char *, struct stat *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int setxattr(char *, char *, char *, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
scalar_t__ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
void kse_setcon(char *name) {
  char *buf;
  ssize_t size;
  int ret;
  struct stat stat_buf;
  if (name == NULL) {
    perror("name ");
    exit(-1);
  }
  ret = lstat(name, &stat_buf);
  if (ret == -1) {
    printf("%s lstat error: %s\n", name, strerror(errno));
    return;
  }
  size = 255;
  buf = malloc(size);
  if (buf == NULL) {
    perror("malloc ");
    exit(-1);
  }
  memset(buf, 0, size);
  if (strncmp(name, "/bin", 4) == 0 || strncmp(name, "/sbin", 5) == 0 ||
      strncmp(name, "/usr/bin", 8) == 0 || strncmp(name, "/usr/sbin", 9) == 0 ||
      strncmp(name, "/usr/local/bin", 14) == 0 ||
      strncmp(name, "/usr/local/sbin", 15) == 0)
    sprintf(buf, "%s", "4:0:c0:15\0");
  else if (strncmp(name, "/dev/null", 9) == 0 ||
           strncmp(name, "/dev/zero", 9) == 0 ||
           strncmp(name, "/dev/random", 11) == 0 ||
           strncmp(name, "/dev/fd/0", 9) == 0 ||
           strncmp(name, "/dev/fd/1", 9) == 0 ||
           strncmp(name, "/dev/fd/2", 9) == 0 ||
           strncmp(name, "/dev/fd/3", 9) == 0)
    sprintf(buf, "%s", "4:0:c0:8\0");
  else if (strncmp(name, "/root", 5) == 0)
    sprintf(buf, "%s", "1:2:c0,c1:8\0");
  else if (strncmp(name, "/home", 5) == 0) {
    if (strncmp(name, "/home/secadm", 12) == 0)
      sprintf(buf, "%s", "1:2:c0,c2:8\0");
    else if (strncmp(name, "/home/audadm", 12) == 0)
      sprintf(buf, "%s", "1:2:c0,c3:8\0");
    else {
      if (strcmp(name, "/home") == 0)
        sprintf(buf, "%s", "4:0:c0:8\0");
      else
        sprintf(buf, "%s", "1:1:c4:8\0");
    }
  } else if (strncmp(name, "/tmp", 4) == 0)
    sprintf(buf, "%s", "0:0:c0:8\0");
  else
    sprintf(buf, "%s", "2:1:c0:8\0");
  ret = setxattr(name, "security.kse", buf, strlen(buf) + 1, 0);
  if (ret < 0) {
  }
  free(buf);
}


x86 assembly (clang, -O0):
<kse_setcon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11fd <kse_setcon+0x2d>
lea    0xe12(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <lstat@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1245 <kse_setcon+0x75>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
lea    0xdcb(%rip),%rdi
call   1060 <printf@plt>
jmp    1636 <kse_setcon+0x466>
movl   $0xff,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1279 <kse_setcon+0xa9>
lea    0xdb0(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    0xdad(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1341 <kse_setcon+0x171>
mov    -0x8(%rbp),%rdi
lea    0xd9d(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1341 <kse_setcon+0x171>
mov    -0x8(%rbp),%rdi
lea    0xd52(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1341 <kse_setcon+0x171>
mov    -0x8(%rbp),%rdi
lea    0xd3c(%rip),%rsi
mov    $0x9,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1341 <kse_setcon+0x171>
mov    -0x8(%rbp),%rdi
lea    0xd27(%rip),%rsi
mov    $0xe,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1341 <kse_setcon+0x171>
mov    -0x8(%rbp),%rdi
lea    0xd17(%rip),%rsi
mov    $0xf,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    135d <kse_setcon+0x18d>
mov    -0x10(%rbp),%rdi
lea    0xd08(%rip),%rsi
lea    0xd84(%rip),%rdx
call   10c0 <sprintf@plt>
jmp    15e4 <kse_setcon+0x414>
mov    -0x8(%rbp),%rdi
lea    0xcef(%rip),%rsi
mov    $0x9,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1436 <kse_setcon+0x266>
mov    -0x8(%rbp),%rdi
lea    0xcda(%rip),%rsi
mov    $0x9,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1436 <kse_setcon+0x266>
mov    -0x8(%rbp),%rdi
lea    0xcc5(%rip),%rsi
mov    $0xb,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1436 <kse_setcon+0x266>
mov    -0x8(%rbp),%rdi
lea    0xcb2(%rip),%rsi
mov    $0x9,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1436 <kse_setcon+0x266>
mov    -0x8(%rbp),%rdi
lea    0xc9d(%rip),%rsi
mov    $0x9,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1436 <kse_setcon+0x266>
mov    -0x8(%rbp),%rdi
lea    0xc88(%rip),%rsi
mov    $0x9,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1436 <kse_setcon+0x266>
mov    -0x8(%rbp),%rdi
lea    0xc73(%rip),%rsi
mov    $0x9,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1452 <kse_setcon+0x282>
mov    -0x10(%rbp),%rdi
lea    0xc13(%rip),%rsi
lea    0xc9a(%rip),%rdx
call   10c0 <sprintf@plt>
jmp    15df <kse_setcon+0x40f>
mov    -0x8(%rbp),%rdi
lea    0xc42(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    148d <kse_setcon+0x2bd>
mov    -0x10(%rbp),%rdi
lea    0xbd8(%rip),%rsi
lea    0xc69(%rip),%rdx
call   10c0 <sprintf@plt>
jmp    15da <kse_setcon+0x40a>
mov    -0x8(%rbp),%rdi
lea    0xc0d(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    157e <kse_setcon+0x3ae>
mov    -0x8(%rbp),%rdi
lea    0xbf4(%rip),%rsi
mov    $0xc,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    14e7 <kse_setcon+0x317>
mov    -0x10(%rbp),%rdi
lea    0xb7e(%rip),%rsi
lea    0xc1c(%rip),%rdx
call   10c0 <sprintf@plt>
jmp    1579 <kse_setcon+0x3a9>
mov    -0x8(%rbp),%rdi
lea    0xbc6(%rip),%rsi
mov    $0xc,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1522 <kse_setcon+0x352>
mov    -0x10(%rbp),%rdi
lea    0xb43(%rip),%rsi
lea    0xbee(%rip),%rdx
call   10c0 <sprintf@plt>
jmp    1574 <kse_setcon+0x3a4>
mov    -0x8(%rbp),%rdi
lea    0xb78(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1558 <kse_setcon+0x388>
mov    -0x10(%rbp),%rdi
lea    0xb0d(%rip),%rsi
lea    0xb94(%rip),%rdx
call   10c0 <sprintf@plt>
jmp    156f <kse_setcon+0x39f>
mov    -0x10(%rbp),%rdi
lea    0xaf1(%rip),%rsi
lea    0xba9(%rip),%rdx
call   10c0 <sprintf@plt>
jmp    1574 <kse_setcon+0x3a4>
jmp    1579 <kse_setcon+0x3a9>
jmp    15d5 <kse_setcon+0x405>
mov    -0x8(%rbp),%rdi
lea    0xb3c(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    15b9 <kse_setcon+0x3e9>
mov    -0x10(%rbp),%rdi
lea    0xaac(%rip),%rsi
lea    0xb6e(%rip),%rdx
call   10c0 <sprintf@plt>
jmp    15d0 <kse_setcon+0x400>
mov    -0x10(%rbp),%rdi
lea    0xa90(%rip),%rsi
lea    0xb5c(%rip),%rdx
call   10c0 <sprintf@plt>
jmp    15d5 <kse_setcon+0x405>
jmp    15da <kse_setcon+0x40a>
jmp    15df <kse_setcon+0x40f>
jmp    15e4 <kse_setcon+0x414>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
add    $0x1,%rcx
lea    0xab7(%rip),%rsi
xor    %r8d,%r8d
call   10e0 <setxattr@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    162d <kse_setcon+0x45d>
jmp    162d <kse_setcon+0x45d>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kse_setcon>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1510 <kse_setcon+0x350>
mov    %rdi,%rbx
mov    %rsp,%rsi
call   1080 <lstat@plt>
cmp    $0xffffffff,%eax
je     1429 <kse_setcon+0x269>
mov    $0xff,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1519 <kse_setcon+0x359>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1070 <memset@plt>
lea    0xe32(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     13e5 <kse_setcon+0x225>
lea    0xe24(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     13e5 <kse_setcon+0x225>
lea    0xddb(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     13e5 <kse_setcon+0x225>
lea    0xdc7(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     13e5 <kse_setcon+0x225>
lea    0xdb4(%rip),%rsi
mov    %rbx,%rdi
mov    $0xe,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     13e5 <kse_setcon+0x225>
lea    0xda6(%rip),%rsi
mov    %rbx,%rdi
mov    $0xf,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     13e5 <kse_setcon+0x225>
lea    0xd99(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     14b9 <kse_setcon+0x2f9>
lea    0xd86(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     14b9 <kse_setcon+0x2f9>
lea    0xd73(%rip),%rsi
mov    %rbx,%rdi
mov    $0xb,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     14b9 <kse_setcon+0x2f9>
lea    0xd62(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     14b9 <kse_setcon+0x2f9>
lea    0xd4f(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     14b9 <kse_setcon+0x2f9>
lea    0xd3c(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     14b9 <kse_setcon+0x2f9>
lea    0xd29(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     14b9 <kse_setcon+0x2f9>
lea    0xd16(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1450 <kse_setcon+0x290>
lea    0xcff(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1467 <kse_setcon+0x2a7>
lea    0xd02(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     14d0 <kse_setcon+0x310>
movabs $0x383a30633a313a32,%rax
30 3a 38
jmp    14c3 <kse_setcon+0x303>
movabs $0x313a30633a303a34,%rax
30 3a 31
mov    %rax,(%r14)
movw   $0x35,0x8(%r14)
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rcx
lea    0xcbb(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %r8d,%r8d
call   10d0 <setxattr@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
mov    0x2bb0(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xbc8(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <printf@plt>
movabs $0x632c30633a323a31,%rax
30 2c 63
mov    %rax,(%r14)
movl   $0x383a31,0x8(%r14)
jmp    13f9 <kse_setcon+0x239>
lea    0xc3a(%rip),%rsi
mov    %rbx,%rdi
mov    $0xc,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     14dc <kse_setcon+0x31c>
lea    0xc2e(%rip),%rsi
mov    %rbx,%rdi
mov    $0xc,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     14f6 <kse_setcon+0x336>
lea    0xc02(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcmp@plt>
test   %rax,%rax
je     14b9 <kse_setcon+0x2f9>
movabs $0x383a34633a313a31,%rax
34 3a 38
jmp    14c3 <kse_setcon+0x303>
movabs $0x383a30633a303a34,%rax
30 3a 38
mov    %rax,(%r14)
movb   $0x0,0x8(%r14)
jmp    13f9 <kse_setcon+0x239>
movabs $0x383a30633a303a30,%rax
30 3a 38
jmp    14c3 <kse_setcon+0x303>
movabs $0x632c30633a323a31,%rax
30 2c 63
mov    %rax,(%r14)
movl   $0x383a32,0x8(%r14)
jmp    13f9 <kse_setcon+0x239>
movabs $0x632c30633a323a31,%rax
30 2c 63
mov    %rax,(%r14)
movl   $0x383a33,0x8(%r14)
jmp    13f9 <kse_setcon+0x239>
lea    0xae9(%rip),%rdi
jmp    1520 <kse_setcon+0x360>
lea    0xafa(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [6 x i8] c"name \00"
@.str.1 = [20 x i8] c"%s lstat error: %s\0A\00"
@errno = global i32 0
@.str.2 = [8 x i8] c"malloc \00"
@.str.3 = [5 x i8] c"/bin\00"
@.str.4 = [6 x i8] c"/sbin\00"
@.str.5 = [9 x i8] c"/usr/bin\00"
@.str.6 = [10 x i8] c"/usr/sbin\00"
@.str.7 = [15 x i8] c"/usr/local/bin\00"
@.str.8 = [16 x i8] c"/usr/local/sbin\00"
@.str.9 = [3 x i8] c"%s\00"
@.str.10 = [11 x i8] c"4:0:c0:15\00\00"
@.str.11 = [10 x i8] c"/dev/null\00"
@.str.12 = [10 x i8] c"/dev/zero\00"
@.str.13 = [12 x i8] c"/dev/random\00"
@.str.14 = [10 x i8] c"/dev/fd/0\00"
@.str.15 = [10 x i8] c"/dev/fd/1\00"
@.str.16 = [10 x i8] c"/dev/fd/2\00"
@.str.17 = [10 x i8] c"/dev/fd/3\00"
@.str.18 = [10 x i8] c"4:0:c0:8\00\00"
@.str.19 = [6 x i8] c"/root\00"
@.str.20 = [13 x i8] c"1:2:c0,c1:8\00\00"
@.str.21 = [6 x i8] c"/home\00"
@.str.22 = [13 x i8] c"/home/secadm\00"
@.str.23 = [13 x i8] c"1:2:c0,c2:8\00\00"
@.str.24 = [13 x i8] c"/home/audadm\00"
@.str.25 = [13 x i8] c"1:2:c0,c3:8\00\00"
@.str.26 = [10 x i8] c"1:1:c4:8\00\00"
@.str.27 = [5 x i8] c"/tmp\00"
@.str.28 = [10 x i8] c"0:0:c0:8\00\00"
@.str.29 = [10 x i8] c"2:1:c0:8\00\00"
@.str.30 = [13 x i8] c"security.kse\00"
define void @kse_setcon(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.stat
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i32 @lstat(i8* %13, %struct.stat* %6)
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i8*, i8** %2
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %20)
br label %156
22: ; preds = %12
store i32 255, i32* %4
%23 = load i32, i32* %4
%24 = call i8* @malloc(i32 %23)
store i8* %24, i8** %3
%25 = load i8*, i8** %3
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @exit(i32 -1)
unreachable
30: ; preds = %22
%31 = load i8*, i8** %3
%32 = load i32, i32* %4
%33 = call i32 @memset(i8* %31, i32 0, i32 %32)
%34 = load i8*, i8** %2
%35 = call i64 @strncmp(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%36 = icmp eq i64 %35, 0
br i1 %36, label %57, label %37
37: ; preds = %30
%38 = load i8*, i8** %2
%39 = call i64 @strncmp(i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%40 = icmp eq i64 %39, 0
br i1 %40, label %57, label %41
41: ; preds = %37
%42 = load i8*, i8** %2
%43 = call i64 @strncmp(i8* %42, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 8)
%44 = icmp eq i64 %43, 0
br i1 %44, label %57, label %45
45: ; preds = %41
%46 = load i8*, i8** %2
%47 = call i64 @strncmp(i8* %46, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 9)
%48 = icmp eq i64 %47, 0
br i1 %48, label %57, label %49
49: ; preds = %45
%50 = load i8*, i8** %2
%51 = call i64 @strncmp(i8* %50, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 14)
%52 = icmp eq i64 %51, 0
br i1 %52, label %57, label %53
53: ; preds = %49
%54 = load i8*, i8** %2
%55 = call i64 @strncmp(i8* %54, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32 15)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %53, %49, %45, %41, %37, %30
%58 = load i8*, i8** %3
%59 = call i32 @sprintf(i8* %58, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
br label %143
60: ; preds = %53
%61 = load i8*, i8** %2
%62 = call i64 @strncmp(i8* %61, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 9)
%63 = icmp eq i64 %62, 0
br i1 %63, label %88, label %64
64: ; preds = %60
%65 = load i8*, i8** %2
%66 = call i64 @strncmp(i8* %65, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i32 9)
%67 = icmp eq i64 %66, 0
br i1 %67, label %88, label %68
68: ; preds = %64
%69 = load i8*, i8** %2
%70 = call i64 @strncmp(i8* %69, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32 11)
%71 = icmp eq i64 %70, 0
br i1 %71, label %88, label %72
72: ; preds = %68
%73 = load i8*, i8** %2
%74 = call i64 @strncmp(i8* %73, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 9)
%75 = icmp eq i64 %74, 0
br i1 %75, label %88, label %76
76: ; preds = %72
%77 = load i8*, i8** %2
%78 = call i64 @strncmp(i8* %77, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i32 9)
%79 = icmp eq i64 %78, 0
br i1 %79, label %88, label %80
80: ; preds = %76
%81 = load i8*, i8** %2
%82 = call i64 @strncmp(i8* %81, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), i32 9)
%83 = icmp eq i64 %82, 0
br i1 %83, label %88, label %84
84: ; preds = %80
%85 = load i8*, i8** %2
%86 = call i64 @strncmp(i8* %85, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.17, i64 0, i64 0), i32 9)
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %84, %80, %76, %72, %68, %64, %60
%89 = load i8*, i8** %3
%90 = call i32 @sprintf(i8* %89, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0))
br label %142
91: ; preds = %84
%92 = load i8*, i8** %2
%93 = call i64 @strncmp(i8* %92, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0), i32 5)
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %98
95: ; preds = %91
%96 = load i8*, i8** %3
%97 = call i32 @sprintf(i8* %96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.20, i64 0, i64 0))
br label %141
98: ; preds = %91
%99 = load i8*, i8** %2
%100 = call i64 @strncmp(i8* %99, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0), i32 5)
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %129
102: ; preds = %98
%103 = load i8*, i8** %2
%104 = call i64 @strncmp(i8* %103, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.22, i64 0, i64 0), i32 12)
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %109
106: ; preds = %102
%107 = load i8*, i8** %3
%108 = call i32 @sprintf(i8* %107, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.23, i64 0, i64 0))
br label %128
109: ; preds = %102
%110 = load i8*, i8** %2
%111 = call i64 @strncmp(i8* %110, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.24, i64 0, i64 0), i32 12)
%112 = icmp eq i64 %111, 0
br i1 %112, label %113, label %116
113: ; preds = %109
%114 = load i8*, i8** %3
%115 = call i32 @sprintf(i8* %114, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.25, i64 0, i64 0))
br label %127
116: ; preds = %109
%117 = load i8*, i8** %2
%118 = call i64 @strcmp(i8* %117, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0))
%119 = icmp eq i64 %118, 0
br i1 %119, label %120, label %123
120: ; preds = %116
%121 = load i8*, i8** %3
%122 = call i32 @sprintf(i8* %121, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0))
br label %126
123: ; preds = %116
%124 = load i8*, i8** %3
%125 = call i32 @sprintf(i8* %124, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.26, i64 0, i64 0))
br label %126
126: ; preds = %123, %120
br label %127
127: ; preds = %126, %113
br label %128
128: ; preds = %127, %106
br label %140
129: ; preds = %98
%130 = load i8*, i8** %2
%131 = call i64 @strncmp(i8* %130, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.27, i64 0, i64 0), i32 4)
%132 = icmp eq i64 %131, 0
br i1 %132, label %133, label %136
133: ; preds = %129
%134 = load i8*, i8** %3
%135 = call i32 @sprintf(i8* %134, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.28, i64 0, i64 0))
br label %139
136: ; preds = %129
%137 = load i8*, i8** %3
%138 = call i32 @sprintf(i8* %137, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.29, i64 0, i64 0))
br label %139
139: ; preds = %136, %133
br label %140
140: ; preds = %139, %128
br label %141
141: ; preds = %140, %95
br label %142
142: ; preds = %141, %88
br label %143
143: ; preds = %142, %57
%144 = load i8*, i8** %2
%145 = load i8*, i8** %3
%146 = load i8*, i8** %3
%147 = call i64 @strlen(i8* %146)
%148 = add nsw i64 %147, 1
%149 = call i32 @setxattr(i8* %144, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.30, i64 0, i64 0), i8* %145, i64 %148, i32 0)
store i32 %149, i32* %5
%150 = load i32, i32* %5
%151 = icmp slt i32 %150, 0
br i1 %151, label %152, label %153
152: ; preds = %143
br label %153
153: ; preds = %152, %143
%154 = load i8*, i8** %3
%155 = call i32 @free(i8* %154)
br label %156
156: ; preds = %153, %17
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [6 x i8] c"name \00"
@.str.1 = [20 x i8] c"%s lstat error: %s\0A\00"
@errno = global i32 0
@.str.2 = [8 x i8] c"malloc \00"
@.str.3 = [5 x i8] c"/bin\00"
@.str.4 = [6 x i8] c"/sbin\00"
@.str.5 = [9 x i8] c"/usr/bin\00"
@.str.6 = [10 x i8] c"/usr/sbin\00"
@.str.7 = [15 x i8] c"/usr/local/bin\00"
@.str.8 = [16 x i8] c"/usr/local/sbin\00"
@.str.10 = [11 x i8] c"4:0:c0:15\00\00"
@.str.11 = [10 x i8] c"/dev/null\00"
@.str.12 = [10 x i8] c"/dev/zero\00"
@.str.13 = [12 x i8] c"/dev/random\00"
@.str.14 = [10 x i8] c"/dev/fd/0\00"
@.str.15 = [10 x i8] c"/dev/fd/1\00"
@.str.16 = [10 x i8] c"/dev/fd/2\00"
@.str.17 = [10 x i8] c"/dev/fd/3\00"
@.str.18 = [10 x i8] c"4:0:c0:8\00\00"
@.str.19 = [6 x i8] c"/root\00"
@.str.20 = [13 x i8] c"1:2:c0,c1:8\00\00"
@.str.21 = [6 x i8] c"/home\00"
@.str.22 = [13 x i8] c"/home/secadm\00"
@.str.23 = [13 x i8] c"1:2:c0,c2:8\00\00"
@.str.24 = [13 x i8] c"/home/audadm\00"
@.str.25 = [13 x i8] c"1:2:c0,c3:8\00\00"
@.str.26 = [10 x i8] c"1:1:c4:8\00\00"
@.str.27 = [5 x i8] c"/tmp\00"
@.str.28 = [10 x i8] c"0:0:c0:8\00\00"
@.str.29 = [10 x i8] c"2:1:c0:8\00\00"
@.str.30 = [13 x i8] c"security.kse\00"
define void @kse_setcon(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %1
%9 = call i32 @lstat(i8* %0, %struct.stat* %2)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i32, i32* @errno
%13 = tail call i8* @strerror(i32 %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %13)
br label %93
15: ; preds = %8
%16 = tail call dereferenceable_or_null(255) i8* @malloc(i32 255)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%20 = tail call i32 @exit(i32 -1)
unreachable
21: ; preds = %15
%22 = tail call i32 @memset(i8* %16, i32 0, i32 255)
%23 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%24 = icmp eq i64 %23, 0
br i1 %24, label %40, label %25
25: ; preds = %21
%26 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%27 = icmp eq i64 %26, 0
br i1 %27, label %40, label %28
28: ; preds = %25
%29 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 8)
%30 = icmp eq i64 %29, 0
br i1 %30, label %40, label %31
31: ; preds = %28
%32 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 9)
%33 = icmp eq i64 %32, 0
br i1 %33, label %40, label %34
34: ; preds = %31
%35 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 14)
%36 = icmp eq i64 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %34
%38 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32 15)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %37, %34, %31, %28, %25, %21
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(10) %16, i8* align 1 dereferenceable(10) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i64 10, i1 false)
br label %88
41: ; preds = %37
%42 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 9)
%43 = icmp eq i64 %42, 0
br i1 %43, label %62, label %44
44: ; preds = %41
%45 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i32 9)
%46 = icmp eq i64 %45, 0
br i1 %46, label %62, label %47
47: ; preds = %44
%48 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32 11)
%49 = icmp eq i64 %48, 0
br i1 %49, label %62, label %50
50: ; preds = %47
%51 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 9)
%52 = icmp eq i64 %51, 0
br i1 %52, label %62, label %53
53: ; preds = %50
%54 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i32 9)
%55 = icmp eq i64 %54, 0
br i1 %55, label %62, label %56
56: ; preds = %53
%57 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), i32 9)
%58 = icmp eq i64 %57, 0
br i1 %58, label %62, label %59
59: ; preds = %56
%60 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.17, i64 0, i64 0), i32 9)
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %59, %56, %53, %50, %47, %44, %41
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(9) %16, i8* align 1 dereferenceable(9) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), i64 9, i1 false)
br label %88
63: ; preds = %59
%64 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0), i32 5)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %63
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(12) %16, i8* align 1 dereferenceable(12) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.20, i64 0, i64 0), i64 12, i1 false)
br label %88
67: ; preds = %63
%68 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0), i32 5)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %83
70: ; preds = %67
%71 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.22, i64 0, i64 0), i32 12)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %70
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(12) %16, i8* align 1 dereferenceable(12) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.23, i64 0, i64 0), i64 12, i1 false)
br label %88
74: ; preds = %70
%75 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.24, i64 0, i64 0), i32 12)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %74
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(12) %16, i8* align 1 dereferenceable(12) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.25, i64 0, i64 0), i64 12, i1 false)
br label %88
78: ; preds = %74
%79 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0))
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %82
81: ; preds = %78
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(9) %16, i8* align 1 dereferenceable(9) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), i64 9, i1 false)
br label %88
82: ; preds = %78
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(9) %16, i8* align 1 dereferenceable(9) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.26, i64 0, i64 0), i64 9, i1 false)
br label %88
83: ; preds = %67
%84 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.27, i64 0, i64 0), i32 4)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %83
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(9) %16, i8* align 1 dereferenceable(9) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.28, i64 0, i64 0), i64 9, i1 false)
br label %88
87: ; preds = %83
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(9) %16, i8* align 1 dereferenceable(9) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.29, i64 0, i64 0), i64 9, i1 false)
br label %88
88: ; preds = %62, %77, %82, %81, %73, %87, %86, %66, %40
%89 = tail call i64 @strlen(i8* %16)
%90 = add nsw i64 %89, 1
%91 = tail call i32 @setxattr(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.30, i64 0, i64 0), i8* %16, i64 %90, i32 0)
%92 = tail call i32 @free(i8* %16)
br label %93
93: ; preds = %88, %11
ret void
}