#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 uid_t;
struct passwd {
  int pw_uid;
};
struct group {
  int gr_gid;
};
typedef int gid_t;

/* Variables and functions */
int /*<<< orphan*/ AT_FDCWD;
int /*<<< orphan*/ EXIT_FAILURE;
char *basename(char *);
scalar_t__ chdir(char *);
char *dirname(char *);
int /*<<< orphan*/ display_perms(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fchownat(int /*<<< orphan*/, char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
struct group *getgrnam(char *);
struct passwd *getpwnam(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
int main(int argc, char *argv[]) {
  if (argc < 4) {
    fprintf(stderr, "Usage: %s <file> <user> <group>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  uid_t uid = -1;
  struct passwd *pwd;
  gid_t gid = -1;
  struct group *grp;
  if (strcmp(argv[2], "-1") != 0) {
    pwd = getpwnam(argv[2]);
    if (pwd == NULL) {
      printf("'%s' not found\n", argv[2]);
      exit(EXIT_FAILURE);
    }
    uid = pwd->pw_uid;
  }
  if (strcmp(argv[3], "-1") != 0) {
    grp = getgrnam(argv[3]);
    if (grp == NULL) {
      printf("'%s' not found\n", argv[3]);
      exit(EXIT_FAILURE);
    }
    gid = grp->gr_gid;
  }
  char *fn = strdup(argv[1]);
  printf("fn=%s\n", fn);
  if (fn == NULL) {
    perror("strdup");
    goto fail;
  }
  if (fn[0] != '/') {
    fprintf(stderr, "'%s' must be absolute path\n", fn);
    goto fail;
  }
  char *dir = dirname(fn);
  printf("dir=%s\n", dir);
  if (chdir(dir) < 0) {
    perror("chdir");
    goto fail;
  }
  printf("Before: ");
  display_perms(argv[1]);
  free(fn);
  fn = strdup(argv[1]);
  char *base = basename(fn);
  if (fchownat(AT_FDCWD, base, uid, gid, 0) < 0) {
    perror("fchownat");
    goto fail;
  }
  printf("After: ");
  display_perms(argv[1]);
  exit(0);
fail:
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    122a <main+0x4a>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xde9(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
movl   $0xffffffff,-0x14(%rbp)
movl   $0xffffffff,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdda(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     129f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <getpwnam@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1296 <main+0xb6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd73(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1306 <main+0x126>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <getgrnam@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12fd <main+0x11d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2ce2(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1100 <strdup@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x38(%rbp)
jne    1345 <main+0x165>
lea    0xd00(%rip),%rdi
call   10d0 <perror@plt>
jmp    1450 <main+0x270>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1373 <main+0x193>
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xcd9(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1450 <main+0x270>
mov    -0x38(%rbp),%rdi
call   1060 <dirname@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xcd3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1040 <chdir@plt>
cmp    $0x0,%rax
jge    13b6 <main+0x1d6>
lea    0xcba(%rip),%rdi
call   10d0 <perror@plt>
jmp    1450 <main+0x270>
lea    0xcaf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <display_perms@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1100 <strdup@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   10a0 <basename@plt>
mov    %rax,-0x48(%rbp)
mov    0x2bc9(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x24(%rbp),%ecx
xor    %r8d,%r8d
call   10e0 <fchownat@plt>
cmp    $0x0,%rax
jge    142e <main+0x24e>
lea    0xc51(%rip),%rdi
call   10d0 <perror@plt>
jmp    1450 <main+0x270>
lea    0xc49(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <display_perms@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
mov    0x2b81(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
cmp    $0x3,%edi
jle    132e <main+0x14e>
mov    0x10(%r12),%rdi
lea    0xe21(%rip),%rsi
call   1070 <strcmp@plt>
mov    $0xffffffff,%r14d
mov    $0xffffffff,%r15d
test   %rax,%rax
je     122c <main+0x4c>
mov    0x10(%r12),%rdi
call   1080 <getpwnam@plt>
test   %rax,%rax
je     1349 <main+0x169>
mov    (%rax),%r15d
mov    0x18(%r12),%rdi
lea    0xde9(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1258 <main+0x78>
mov    0x18(%r12),%rdi
call   10b0 <getgrnam@plt>
test   %rax,%rax
je     1350 <main+0x170>
mov    (%rax),%r14d
mov    0x8(%r12),%rdi
call   1100 <strdup@plt>
mov    %rax,%rbp
lea    0xdc8(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbp,%rbp
jne    1287 <main+0xa7>
lea    0xdb9(%rip),%rdi
jmp    131b <main+0x13b>
cmpb   $0x2f,0x0(%rbp)
jne    1365 <main+0x185>
mov    %rbp,%rdi
call   1060 <dirname@plt>
mov    %rax,%rbx
lea    0xdbb(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <chdir@plt>
test   %rax,%rax
jns    12c3 <main+0xe3>
lea    0xda5(%rip),%rdi
jmp    131b <main+0x13b>
lea    0xda2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%r12),%rdi
call   10c0 <display_perms@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x8(%r12),%rdi
call   1100 <strdup@plt>
mov    %rax,%rdi
call   10a0 <basename@plt>
mov    0x2ccc(%rip),%rcx
mov    (%rcx),%edi
mov    %rax,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %r8d,%r8d
call   10e0 <fchownat@plt>
test   %rax,%rax
jns    137f <main+0x19f>
lea    0xd5a(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2cb1(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
lea    0xcbe(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1320 <main+0x140>
mov    0x10(%r12),%rsi
jmp    1355 <main+0x175>
mov    0x18(%r12),%rsi
lea    0xcc8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1320 <main+0x140>
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
lea    0xccd(%rip),%rsi
mov    %rbp,%rdx
call   1090 <fprintf@plt>
jmp    1320 <main+0x140>
lea    0xcf8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%r12),%rdi
call   10c0 <display_perms@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.passwd = type { i32 }
%struct.group = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"Usage: %s <file> <user> <group>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"-1\00"
@.str.2 = [16 x i8] c"'%s' not found\0A\00"
@.str.3 = [7 x i8] c"fn=%s\0A\00"
@.str.4 = [7 x i8] c"strdup\00"
@.str.5 = [28 x i8] c"'%s' must be absolute path\0A\00"
@.str.6 = [8 x i8] c"dir=%s\0A\00"
@.str.7 = [6 x i8] c"chdir\00"
@.str.8 = [9 x i8] c"Before: \00"
@AT_FDCWD = global i32 0
@.str.9 = [9 x i8] c"fchownat\00"
@.str.10 = [8 x i8] c"After: \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.passwd*
%8 = alloca i32
%9 = alloca %struct.group*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
store i32 -1, i32* %6
store i32 -1, i32* %8
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %47
29: ; preds = %23
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call %struct.passwd* @getpwnam(i8* %32)
store %struct.passwd* %33, %struct.passwd** %7
%34 = load %struct.passwd*, %struct.passwd** %7
%35 = icmp eq %struct.passwd* %34, null
br i1 %35, label %36, label %43
36: ; preds = %29
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %29
%44 = load %struct.passwd*, %struct.passwd** %7
%45 = getelementptr inbounds %struct.passwd, %struct.passwd* %44, i32 0, i32 0
%46 = load i32, i32* %45
store i32 %46, i32* %6
br label %47
47: ; preds = %43, %23
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 3
%50 = load i8*, i8** %49
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %71
53: ; preds = %47
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 3
%56 = load i8*, i8** %55
%57 = call %struct.group* @getgrnam(i8* %56)
store %struct.group* %57, %struct.group** %9
%58 = load %struct.group*, %struct.group** %9
%59 = icmp eq %struct.group* %58, null
br i1 %59, label %60, label %67
60: ; preds = %53
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 3
%63 = load i8*, i8** %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %63)
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %53
%68 = load %struct.group*, %struct.group** %9
%69 = getelementptr inbounds %struct.group, %struct.group* %68, i32 0, i32 0
%70 = load i32, i32* %69
store i32 %70, i32* %8
br label %71
71: ; preds = %67, %47
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 1
%74 = load i8*, i8** %73
%75 = call i8* @strdup(i8* %74)
store i8* %75, i8** %10
%76 = load i8*, i8** %10
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %76)
%78 = load i8*, i8** %10
%79 = icmp eq i8* %78, null
br i1 %79, label %80, label %82
80: ; preds = %71
%81 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %131
82: ; preds = %71
%83 = load i8*, i8** %10
%84 = getelementptr inbounds i8, i8* %83, i64 0
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp ne i32 %86, 47
br i1 %87, label %88, label %92
88: ; preds = %82
%89 = load i32, i32* @stderr
%90 = load i8*, i8** %10
%91 = call i32 @fprintf(i32 %89, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %90)
br label %131
92: ; preds = %82
%93 = load i8*, i8** %10
%94 = call i8* @dirname(i8* %93)
store i8* %94, i8** %11
%95 = load i8*, i8** %11
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %95)
%97 = load i8*, i8** %11
%98 = call i64 @chdir(i8* %97)
%99 = icmp slt i64 %98, 0
br i1 %99, label %100, label %102
100: ; preds = %92
%101 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %131
102: ; preds = %92
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%104 = load i8**, i8*** %5
%105 = getelementptr inbounds i8*, i8** %104, i64 1
%106 = load i8*, i8** %105
%107 = call i32 @display_perms(i8* %106)
%108 = load i8*, i8** %10
%109 = call i32 @free(i8* %108)
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 1
%112 = load i8*, i8** %111
%113 = call i8* @strdup(i8* %112)
store i8* %113, i8** %10
%114 = load i8*, i8** %10
%115 = call i8* @basename(i8* %114)
store i8* %115, i8** %12
%116 = load i32, i32* @AT_FDCWD
%117 = load i8*, i8** %12
%118 = load i32, i32* %6
%119 = load i32, i32* %8
%120 = call i64 @fchownat(i32 %116, i8* %117, i32 %118, i32 %119, i32 0)
%121 = icmp slt i64 %120, 0
br i1 %121, label %122, label %124
122: ; preds = %102
%123 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %131
124: ; preds = %102
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%126 = load i8**, i8*** %5
%127 = getelementptr inbounds i8*, i8** %126, i64 1
%128 = load i8*, i8** %127
%129 = call i32 @display_perms(i8* %128)
%130 = call i32 @exit(i32 0)
unreachable
131: ; preds = %122, %100, %88, %80
%132 = load i32, i32* @EXIT_FAILURE
%133 = call i32 @exit(i32 %132)
unreachable
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
%struct.group = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"Usage: %s <file> <user> <group>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"-1\00"
@.str.2 = [16 x i8] c"'%s' not found\0A\00"
@.str.3 = [7 x i8] c"fn=%s\0A\00"
@.str.4 = [7 x i8] c"strdup\00"
@.str.5 = [28 x i8] c"'%s' must be absolute path\0A\00"
@.str.6 = [8 x i8] c"dir=%s\0A\00"
@.str.7 = [6 x i8] c"chdir\00"
@.str.8 = [9 x i8] c"Before: \00"
@AT_FDCWD = global i32 0
@.str.9 = [9 x i8] c"fchownat\00"
@.str.10 = [8 x i8] c"After: \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %10
%16 = load i8*, i8** %11
%17 = tail call %struct.passwd* @getpwnam(i8* %16)
%18 = icmp eq %struct.passwd* %17, null
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i8*, i8** %11
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %15
%25 = getelementptr inbounds %struct.passwd, %struct.passwd* %17, i64 0, i32 0
%26 = load i32, i32* %25
br label %27
27: ; preds = %24, %10
%28 = phi i32 [ %26, %24 ], [ -1, %10 ]
%29 = getelementptr inbounds i8*, i8** %1, i64 3
%30 = load i8*, i8** %29
%31 = tail call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %45, label %33
33: ; preds = %27
%34 = load i8*, i8** %29
%35 = tail call %struct.group* @getgrnam(i8* %34)
%36 = icmp eq %struct.group* %35, null
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i8*, i8** %29
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %38)
%40 = load i32, i32* @EXIT_FAILURE
%41 = tail call i32 @exit(i32 %40)
unreachable
42: ; preds = %33
%43 = getelementptr inbounds %struct.group, %struct.group* %35, i64 0, i32 0
%44 = load i32, i32* %43
br label %45
45: ; preds = %42, %27
%46 = phi i32 [ %44, %42 ], [ -1, %27 ]
%47 = getelementptr inbounds i8*, i8** %1, i64 1
%48 = load i8*, i8** %47
%49 = tail call i8* @strdup(i8* %48)
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %49)
%51 = icmp eq i8* %49, null
br i1 %51, label %52, label %54
52: ; preds = %45
%53 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %85
54: ; preds = %45
%55 = load i8, i8* %49
%56 = icmp eq i8 %55, 47
br i1 %56, label %60, label %57
57: ; preds = %54
%58 = load i32, i32* @stderr
%59 = tail call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %49)
br label %85
60: ; preds = %54
%61 = tail call i8* @dirname(i8* %49)
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %61)
%63 = tail call i64 @chdir(i8* %61)
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %60
%66 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %85
67: ; preds = %60
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%69 = load i8*, i8** %47
%70 = tail call i32 @display_perms(i8* %69)
%71 = tail call i32 @free(i8* %49)
%72 = load i8*, i8** %47
%73 = tail call i8* @strdup(i8* %72)
%74 = tail call i8* @basename(i8* %73)
%75 = load i32, i32* @AT_FDCWD
%76 = tail call i64 @fchownat(i32 %75, i8* %74, i32 %28, i32 %46, i32 0)
%77 = icmp slt i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %67
%79 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %85
80: ; preds = %67
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%82 = load i8*, i8** %47
%83 = tail call i32 @display_perms(i8* %82)
%84 = tail call i32 @exit(i32 0)
unreachable
85: ; preds = %78, %65, %57, %52
%86 = load i32, i32* @EXIT_FAILURE
%87 = tail call i32 @exit(i32 %86)
unreachable
}