#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 */

/* Variables and functions */
int /*<<< orphan*/ inline_replace(char *, char *, char *);
scalar_t__ isdigit(char);
char *strchr(char *, char);
char *strrchr(char *, char);
char *adjust_slash_date(char **arg, char *format) {
  char *first = strchr(*arg, '/');
  char *last = strrchr(*arg, '/');
  if (first == last++) {
    inline_replace(format, "/%Y", "");
  } else {
    if (isdigit(*last) && isdigit(*(last + 1)) && !isdigit(*(last + 2))) {
      inline_replace(format, "%Y", "%y");
    }
  }
  return format;
}


x86 assembly (clang, -O0):
<adjust_slash_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
cmp    %rcx,%rax
jne    11b2 <adjust_slash_date+0x72>
mov    -0x10(%rbp),%rdi
lea    0xe5f(%rip),%rsi
lea    0xe5b(%rip),%rdx
call   1060 <inline_replace@plt>
jmp    1212 <adjust_slash_date+0xd2>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     120d <adjust_slash_date+0xcd>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     120d <adjust_slash_date+0xcd>
mov    -0x20(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    120d <adjust_slash_date+0xcd>
mov    -0x10(%rbp),%rdi
lea    0xe00(%rip),%rsi
lea    0xdfc(%rip),%rdx
call   1060 <inline_replace@plt>
jmp    1212 <adjust_slash_date+0xd2>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adjust_slash_date>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    (%rdi),%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
cmp    %rax,%r15
je     11aa <adjust_slash_date+0x6a>
mov    %rax,%rbx
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11c0 <adjust_slash_date+0x80>
movsbl 0x2(%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11c0 <adjust_slash_date+0x80>
movsbl 0x3(%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    11c0 <adjust_slash_date+0x80>
lea    0xe60(%rip),%rsi
lea    0xe5c(%rip),%rdx
jmp    11b8 <adjust_slash_date+0x78>
lea    0xe4f(%rip),%rsi
lea    0xe4b(%rip),%rdx
mov    %r14,%rdi
call   1060 <inline_replace@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"/%Y\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%Y\00"
@.str.3 = [3 x i8] c"%y\00"
define i8* @adjust_slash_date(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8** %0, i8*** %3
store i8* %1, i8** %4
%7 = load i8**, i8*** %3
%8 = load i8*, i8** %7
%9 = call i8* @strchr(i8* %8, i8 signext 47)
store i8* %9, i8** %5
%10 = load i8**, i8*** %3
%11 = load i8*, i8** %10
%12 = call i8* @strrchr(i8* %11, i8 signext 47)
store i8* %12, i8** %6
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %6
%16 = icmp eq i8* %13, %14
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = call i32 @inline_replace(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %41
20: ; preds = %2
%21 = load i8*, i8** %6
%22 = load i8, i8* %21
%23 = call i64 @isdigit(i8 signext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %40
25: ; preds = %20
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = call i64 @isdigit(i8 signext %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %25
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i64 2
%34 = load i8, i8* %33
%35 = call i64 @isdigit(i8 signext %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %31
%38 = load i8*, i8** %4
%39 = call i32 @inline_replace(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %37, %31, %25, %20
br label %41
41: ; preds = %40, %17
%42 = load i8*, i8** %4
ret i8* %42
}

LLVM IR (-O2):
@.str = [4 x i8] c"/%Y\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%Y\00"
@.str.3 = [3 x i8] c"%y\00"
define i8* @adjust_slash_date(i8** nocapture %0, i8* returned %1) {
%3 = load i8*, i8** %0
%4 = tail call i8* @strchr(i8* dereferenceable(1) %3, i8 signext 47)
%5 = tail call i8* @strrchr(i8* dereferenceable(1) %3, i8 signext 47)
%6 = icmp eq i8* %4, %5
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @inline_replace(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %26
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %5, i64 1
%11 = load i8, i8* %10
%12 = tail call i64 @isdigit(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %26, label %14
14: ; preds = %9
%15 = getelementptr inbounds i8, i8* %5, i64 2
%16 = load i8, i8* %15
%17 = tail call i64 @isdigit(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %14
%20 = getelementptr inbounds i8, i8* %5, i64 3
%21 = load i8, i8* %20
%22 = tail call i64 @isdigit(i8 signext %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = tail call i32 @inline_replace(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %9, %14, %19, %24, %7
ret i8* %1
}