#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 *strstr(char *, char *);
char *adjust_alpha_date(char **arg, char *format) {
  char *pch = strstr(*arg, ", ");
  if (pch) {
    pch += 2;
    if (isdigit(*pch) && isdigit(*(pch + 1)) && !isdigit(*(pch + 2))) {
      inline_replace(format, "%Y", "%y");
    }
  } else {
    inline_replace(format, ", %Y", "");
  }
  return format;
}


x86 assembly (clang, -O0):
<adjust_alpha_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xeb2(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ce <adjust_alpha_date+0x9e>
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11c9 <adjust_alpha_date+0x99>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11c9 <adjust_alpha_date+0x99>
mov    -0x18(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    11c9 <adjust_alpha_date+0x99>
mov    -0x10(%rbp),%rdi
lea    0xe4b(%rip),%rsi
lea    0xe3f(%rip),%rdx
call   1040 <inline_replace@plt>
jmp    11e5 <adjust_alpha_date+0xb5>
mov    -0x10(%rbp),%rdi
lea    0xe2d(%rip),%rsi
lea    0xe22(%rip),%rdx
call   1040 <inline_replace@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adjust_alpha_date>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    (%rdi),%rdi
lea    0xebf(%rip),%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1188 <adjust_alpha_date+0x58>
mov    %rax,%rbx
movsbl 0x2(%rax),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     119e <adjust_alpha_date+0x6e>
movsbl 0x3(%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     119e <adjust_alpha_date+0x6e>
movsbl 0x4(%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    119e <adjust_alpha_date+0x6e>
lea    0xe89(%rip),%rsi
lea    0xe7d(%rip),%rdx
jmp    1196 <adjust_alpha_date+0x66>
lea    0xe77(%rip),%rsi
lea    0xe6c(%rip),%rdx
mov    %r14,%rdi
call   1040 <inline_replace@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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