#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 /*<<< orphan*/ st_mode;
};

/* Variables and functions */
int EOF;
int PATH_MAX;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ memset(struct stat *, int /*<<< orphan*/, int);
int optind;
int optopt;
int /*<<< orphan*/ perror(char *);
int rename(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, ...);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strrchr(char *, char);
int /*<<< orphan*/ unlink(char *);
int main(int argc, char *argv[]) {
  int c, f;
  char *p;
  struct stat sb;
  f = 0;
  do {
    c = getopt(argc, argv, "f");
    if (c == EOF)
      break;
    switch (c) {
    case 'f':
      f = 1;
      break;
    case '?':
      fprintf(stderr, "%s: invalid option -%c\n", argv[0], optopt);
      return 1;
    }
  } while (1);
  if (optind == argc) {
    fprintf(stderr, "Usage: %s [-f] source dest\n", argv[0]);
    return 1;
  }
  memset(&sb, 0, sizeof(struct stat));
  if (stat(argv[argc - 1], &sb) < 0 && argc - optind > 2) {
    if (!(S_ISDIR(sb.st_mode))) {
      fprintf(stderr, "multiple targets and %s is not a directory\n",
              argv[argc - 1]);
      return 1;
    }
  }
  for (c = optind; c < argc - 1; c++) {
    char target[PATH_MAX];
    p = strrchr(argv[c], '/');
    p++;
    if (S_ISDIR(sb.st_mode))
      snprintf(target, PATH_MAX, "%s/%s", argv[argc - 1], p);
    else
      snprintf(target, PATH_MAX, "%s", argv[argc - 1]);
    if (f)
      unlink(target);
    if (rename(argv[c], target) == -1)
      perror(target);
  }
  return 0;
}


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)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe35(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2dfb(%rip),%rcx
cmp    (%rcx),%eax
jne    11ea <main+0x4a>
jmp    1262 <main+0xc2>
mov    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x3f,%eax
je     121b <main+0x7b>
jmp    11fe <main+0x5e>
mov    -0x3c(%rbp),%eax
sub    $0x66,%eax
jne    124e <main+0xae>
jmp    120f <main+0x6f>
movl   $0x1,-0x18(%rbp)
jmp    124e <main+0xae>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    0x2dae(%rip),%rax
mov    (%rax),%ecx
lea    0xdc7(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    146a <main+0x2ca>
jmp    1253 <main+0xb3>
mov    $0x1,%al
test   $0x1,%al
jne    11bd <main+0x1d>
jmp    1262 <main+0xc2>
mov    0x2d67(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    129e <main+0xfe>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd8f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    146a <main+0x2ca>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1070 <memset@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x28(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%rax
jge    1332 <main+0x192>
mov    -0x8(%rbp),%eax
mov    0x2cf4(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x2,%eax
jle    1332 <main+0x192>
mov    -0x28(%rbp),%edi
call   1040 <S_ISDIR@plt>
cmp    $0x0,%rax
jne    132d <main+0x18d>
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd1c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    146a <main+0x2ca>
jmp    1332 <main+0x192>
mov    0x2c97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1463 <main+0x2c3>
mov    0x2c9a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%edi
call   1040 <S_ISDIR@plt>
cmp    $0x0,%rax
je     13e8 <main+0x248>
mov    -0x48(%rbp),%rdi
mov    0x2c32(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x20(%rbp),%r8
lea    0xc86(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
jmp    1414 <main+0x274>
mov    -0x48(%rbp),%rdi
mov    0x2bfd(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xc58(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
cmpl   $0x0,-0x18(%rbp)
je     1427 <main+0x287>
mov    -0x48(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x48(%rbp),%rsi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10b0 <rename@plt>
cmp    $0xffffffff,%eax
jne    144e <main+0x2ae>
mov    -0x48(%rbp),%rdi
call   10a0 <perror@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    133e <main+0x19e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r12
mov    %edi,%ebx
lea    0xe43(%rip),%rdx
call   10c0 <getopt@plt>
mov    0x2e0f(%rip),%r14
xor    %r13d,%r13d
cmp    (%r14),%eax
jne    1207 <main+0x67>
mov    0x2df8(%rip),%r14
cmp    %ebx,(%r14)
jne    1271 <main+0xd1>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
lea    0xe25(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%r13d
jmp    13df <main+0x23f>
xor    %r13d,%r13d
lea    0xdef(%rip),%r15
jmp    1238 <main+0x98>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1,%r13d
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   10c0 <getopt@plt>
cmp    (%r14),%eax
je     11d1 <main+0x31>
cmp    $0x66,%eax
je     1220 <main+0x80>
cmp    $0x3f,%eax
jne    1226 <main+0x86>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
mov    0x2d8a(%rip),%rax
mov    (%rax),%ecx
lea    0xda3(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%r13d
jmp    13df <main+0x23f>
mov    %r13d,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
xor    %r13d,%r13d
xor    %esi,%esi
mov    $0x4,%edx
call   1070 <memset@plt>
movslq %ebx,%r15
mov    -0x8(%r12,%r15,8),%rdi
add    $0xffffffffffffffff,%r15
lea    -0x30(%rbp),%rsi
call   1090 <stat@plt>
test   %rax,%rax
jns    12bd <main+0x11d>
mov    %ebx,%eax
sub    (%r14),%eax
cmp    $0x3,%eax
jl     12bd <main+0x11d>
mov    -0x30(%rbp),%edi
call   1040 <S_ISDIR@plt>
test   %rax,%rax
je     13f1 <main+0x251>
movslq (%r14),%rax
cmp    %r15d,%eax
jge    13df <main+0x23f>
mov    %r15,-0x40(%rbp)
mov    %r12,-0x48(%rbp)
lea    (%r12,%rax,8),%r13
not    %eax
add    %ebx,%eax
mov    0x2d10(%rip),%r14
xor    %r12d,%r12d
mov    %rax,-0x58(%rbp)
jmp    1321 <main+0x181>
nopl   0x0(%rax)
mov    0x0(%r13,%r12,8),%rdi
mov    %rbx,%rsi
call   10b0 <rename@plt>
cmp    $0xffffffff,%eax
je     13cf <main+0x22f>
mov    %r14,%rsp
add    $0x1,%r12
mov    -0x58(%rbp),%rax
cmp    %r12d,%eax
mov    0x2cd5(%rip),%r14
je     13dc <main+0x23c>
mov    %rsp,-0x50(%rbp)
mov    (%r14),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r13,%r15
mov    0x0(%r13,%r12,8),%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
mov    %rax,%r13
mov    -0x30(%rbp),%edi
call   1040 <S_ISDIR@plt>
test   %rax,%rax
je     1390 <main+0x1f0>
add    $0x1,%r13
mov    (%r14),%esi
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    %rbx,%rdi
lea    0xcea(%rip),%rdx
mov    %r13,%r8
xor    %eax,%eax
call   1050 <snprintf@plt>
jmp    13b0 <main+0x210>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%esi
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    %rbx,%rdi
lea    0xcbc(%rip),%rdx
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    -0x34(%rbp),%eax
mov    %r15,%r13
mov    -0x50(%rbp),%r14
test   %eax,%eax
je     12f0 <main+0x150>
mov    %rbx,%rdi
call   1030 <unlink@plt>
jmp    12f0 <main+0x150>
mov    %rbx,%rdi
call   10a0 <perror@plt>
jmp    1306 <main+0x166>
xor    %r13d,%r13d
mov    %r13d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bc8(%rip),%rax
mov    (%rax),%edi
mov    (%r12,%r15,8),%rdx
lea    0xc31(%rip),%rsi
jmp    11f5 <main+0x55>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [2 x i8] c"f\00"
@EOF = global i32 0
@stderr = global i32 0
@.str.1 = [24 x i8] c"%s: invalid option -%c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.2 = [28 x i8] c"Usage: %s [-f] source dest\0A\00"
@.str.3 = [44 x i8] c"multiple targets and %s is not a directory\0A\00"
@PATH_MAX = global i32 0
@.str.4 = [6 x i8] c"%s/%s\00"
@.str.5 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca %struct.stat
%10 = alloca i8*
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %12
12: ; preds = %31, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %12
br label %32
20: ; preds = %12
%21 = load i32, i32* %6
switch i32 %21, label %30 [
i32 102, label %22
i32 63, label %23
]
22: ; preds = %20
store i32 1, i32* %7
br label %30
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = load i32, i32* @optopt
%29 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %27, i32 %28)
store i32 1, i32* %3
br label %136
30: ; preds = %20, %22
br label %31
31: ; preds = %30
br i1 true, label %12, label %32
32: ; preds = %31, %19
%33 = load i32, i32* @optind
%34 = load i32, i32* %4
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %40)
store i32 1, i32* %3
br label %136
42: ; preds = %32
%43 = call i32 @memset(%struct.stat* %9, i32 0, i32 4)
%44 = load i8**, i8*** %5
%45 = load i32, i32* %4
%46 = sub nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %44, i64 %47
%49 = load i8*, i8** %48
%50 = call i64 @stat(i8* %49, %struct.stat* %9)
%51 = icmp slt i64 %50, 0
br i1 %51, label %52, label %72
52: ; preds = %42
%53 = load i32, i32* %4
%54 = load i32, i32* @optind
%55 = sub nsw i32 %53, %54
%56 = icmp sgt i32 %55, 2
br i1 %56, label %57, label %72
57: ; preds = %52
%58 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%59 = load i32, i32* %58
%60 = call i64 @S_ISDIR(i32 %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %71, label %62
62: ; preds = %57
%63 = load i32, i32* @stderr
%64 = load i8**, i8*** %5
%65 = load i32, i32* %4
%66 = sub nsw i32 %65, 1
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %64, i64 %67
%69 = load i8*, i8** %68
%70 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* %69)
store i32 1, i32* %3
br label %136
71: ; preds = %57
br label %72
72: ; preds = %71, %52, %42
%73 = load i32, i32* @optind
store i32 %73, i32* %6
br label %74
74: ; preds = %132, %72
%75 = load i32, i32* %6
%76 = load i32, i32* %4
%77 = sub nsw i32 %76, 1
%78 = icmp slt i32 %75, %77
br i1 %78, label %79, label %135
79: ; preds = %74
%80 = load i32, i32* @PATH_MAX
%81 = zext i32 %80 to i64
%82 = call i8* @llvm.stacksave()
store i8* %82, i8** %10
%83 = alloca i8, i64 %81
store i64 %81, i64* %11
%84 = load i8**, i8*** %5
%85 = load i32, i32* %6
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8*, i8** %84, i64 %86
%88 = load i8*, i8** %87
%89 = call i8* @strrchr(i8* %88, i8 signext 47)
store i8* %89, i8** %8
%90 = load i8*, i8** %8
%91 = getelementptr inbounds i8, i8* %90, i32 1
store i8* %91, i8** %8
%92 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%93 = load i32, i32* %92
%94 = call i64 @S_ISDIR(i32 %93)
%95 = icmp ne i64 %94, 0
br i1 %95, label %96, label %106
96: ; preds = %79
%97 = load i32, i32* @PATH_MAX
%98 = load i8**, i8*** %5
%99 = load i32, i32* %4
%100 = sub nsw i32 %99, 1
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8*, i8** %98, i64 %101
%103 = load i8*, i8** %102
%104 = load i8*, i8** %8
%105 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %83, i32 %97, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %103, i8* %104)
br label %115
106: ; preds = %79
%107 = load i32, i32* @PATH_MAX
%108 = load i8**, i8*** %5
%109 = load i32, i32* %4
%110 = sub nsw i32 %109, 1
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8*, i8** %108, i64 %111
%113 = load i8*, i8** %112
%114 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %83, i32 %107, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %113)
br label %115
115: ; preds = %106, %96
%116 = load i32, i32* %7
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %120
118: ; preds = %115
%119 = call i32 @unlink(i8* %83)
br label %120
120: ; preds = %118, %115
%121 = load i8**, i8*** %5
%122 = load i32, i32* %6
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8*, i8** %121, i64 %123
%125 = load i8*, i8** %124
%126 = call i32 @rename(i8* %125, i8* %83)
%127 = icmp eq i32 %126, -1
br i1 %127, label %128, label %130
128: ; preds = %120
%129 = call i32 @perror(i8* %83)
br label %130
130: ; preds = %128, %120
%131 = load i8*, i8** %10
br label %132
132: ; preds = %130
%133 = load i32, i32* %6
%134 = add nsw i32 %133, 1
store i32 %134, i32* %6
br label %74
135: ; preds = %74
store i32 0, i32* %3
br label %136
136: ; preds = %135, %62, %36, %23
%137 = load i32, i32* %3
ret i32 %137
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [2 x i8] c"f\00"
@EOF = global i32 0
@stderr = global i32 0
@.str.1 = [24 x i8] c"%s: invalid option -%c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.2 = [28 x i8] c"Usage: %s [-f] source dest\0A\00"
@.str.3 = [44 x i8] c"multiple targets and %s is not a directory\0A\00"
@PATH_MAX = global i32 0
@.str.4 = [6 x i8] c"%s/%s\00"
@.str.5 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %22, label %8
8: ; preds = %2, %17
%9 = phi i32 [ %19, %17 ], [ %5, %2 ]
%10 = phi i32 [ %18, %17 ], [ 0, %2 ]
switch i32 %9, label %17 [
i32 102, label %11
i32 63, label %12
]
11: ; preds = %8
br label %17
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = load i32, i32* @optopt
%16 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %14, i32 %15)
br label %92
17: ; preds = %11, %8
%18 = phi i32 [ %10, %8 ], [ 1, %11 ]
%19 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %8
22: ; preds = %17, %2
%23 = phi i32 [ 0, %2 ], [ %18, %17 ]
%24 = load i32, i32* @optind
%25 = icmp eq i32 %24, %0
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %1
%29 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %92
30: ; preds = %22
%31 = call i32 @memset(%struct.stat* %3, i32 0, i32 4)
%32 = add nsw i32 %0, -1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %1, i64 %33
%35 = load i8*, i8** %34
%36 = call i64 @stat(i8* %35, %struct.stat* %3)
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %51
38: ; preds = %30
%39 = load i32, i32* @optind
%40 = sub nsw i32 %0, %39
%41 = icmp sgt i32 %40, 2
br i1 %41, label %42, label %51
42: ; preds = %38
%43 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%44 = load i32, i32* %43
%45 = call i64 @S_ISDIR(i32 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %42
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %34
%50 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* %49)
br label %92
51: ; preds = %42, %38, %30
%52 = load i32, i32* @optind
%53 = icmp slt i32 %52, %32
br i1 %53, label %54, label %92
54: ; preds = %51
%55 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%56 = icmp eq i32 %23, 0
%57 = sext i32 %52 to i64
br label %58
58: ; preds = %54, %88
%59 = phi i64 [ %57, %54 ], [ %89, %88 ]
%60 = load i32, i32* @PATH_MAX
%61 = zext i32 %60 to i64
%62 = call i8* @llvm.stacksave()
%63 = alloca i8, i64 %61
%64 = getelementptr inbounds i8*, i8** %1, i64 %59
%65 = load i8*, i8** %64
%66 = call i8* @strrchr(i8* dereferenceable(1) %65, i8 signext 47)
%67 = load i32, i32* %55
%68 = call i64 @S_ISDIR(i32 %67)
%69 = icmp eq i64 %68, 0
br i1 %69, label %75, label %70
70: ; preds = %58
%71 = getelementptr inbounds i8, i8* %66, i64 1
%72 = load i32, i32* @PATH_MAX
%73 = load i8*, i8** %34
%74 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %63, i32 %72, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %73, i8* %71)
br label %79
75: ; preds = %58
%76 = load i32, i32* @PATH_MAX
%77 = load i8*, i8** %34
%78 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %63, i32 %76, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %77)
br label %79
79: ; preds = %75, %70
br i1 %56, label %82, label %80
80: ; preds = %79
%81 = call i32 @unlink(i8* %63)
br label %82
82: ; preds = %80, %79
%83 = load i8*, i8** %64
%84 = call i32 @rename(i8* %83, i8* %63)
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %88
86: ; preds = %82
%87 = call i32 @perror(i8* %63)
br label %88
88: ; preds = %86, %82
%89 = add nsw i64 %59, 1
%90 = trunc i64 %89 to i32
%91 = icmp eq i32 %32, %90
br i1 %91, label %92, label %58
92: ; preds = %88, %51, %47, %26, %12
%93 = phi i32 [ 1, %26 ], [ 1, %47 ], [ 1, %12 ], [ 0, %51 ], [ 0, %88 ]
ret i32 %93
}