#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 tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ isdigit(char);
int match_multi_number(unsigned long, char, char const *, char *, struct tm *);
unsigned long strtoul(char const *, char **, int);
const char *approxidate_digit(const char *date, struct tm *tm, int *num) {
  char *end;
  unsigned long number = strtoul(date, &end, 10);
  switch (*end) {
  case ':':
  case '.':
  case '/':
  case '-':
    if (isdigit(end[1])) {
      int match = match_multi_number(number, *end, date, end, tm);
      if (match)
        return date + match;
    }
  }
  if (date[0] != '0' || end - date <= 2)
    *num = number;
  return end;
}


x86 assembly (clang, -O0):
<approxidate_digit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x38(%rbp)
add    $0xffffffd3,%eax
sub    $0x3,%eax
jb     1186 <approxidate_digit+0x56>
jmp    1175 <approxidate_digit+0x45>
mov    -0x38(%rbp),%eax
sub    $0x3a,%eax
jne    11e5 <approxidate_digit+0xb5>
jmp    1186 <approxidate_digit+0x56>
mov    -0x28(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11e0 <approxidate_digit+0xb0>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%r8
movsbl %al,%esi
call   1050 <match_multi_number@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     11db <approxidate_digit+0xab>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    121e <approxidate_digit+0xee>
jmp    11e0 <approxidate_digit+0xb0>
jmp    11e5 <approxidate_digit+0xb5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    120a <approxidate_digit+0xda>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x2,%rax
jg     1216 <approxidate_digit+0xe6>
mov    -0x30(%rbp),%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<approxidate_digit>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r15
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %rax,%r12
mov    0x8(%rsp),%rbx
movsbl (%rbx),%eax
cmp    $0x3a,%eax
ja     11a4 <approxidate_digit+0x74>
movabs $0x400e00000000000,%rcx
bt     %rax,%rcx
jae    11a4 <approxidate_digit+0x74>
movsbl 0x1(%rbx),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11a4 <approxidate_digit+0x74>
movsbl (%rbx),%esi
mov    %r12,%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r13,%r8
call   1050 <match_multi_number@plt>
test   %eax,%eax
je     11a4 <approxidate_digit+0x74>
cltq
add    %rax,%r15
mov    %r15,%rbx
jmp    11b9 <approxidate_digit+0x89>
mov    %rbx,%rax
sub    %r15,%rax
cmp    $0x3,%rax
jl     11b6 <approxidate_digit+0x86>
cmpb   $0x30,(%r15)
je     11b9 <approxidate_digit+0x89>
mov    %r12d,(%r14)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
define i8* @approxidate_digit(i8* %0, %struct.tm* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.tm*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
store i8* %0, i8** %5
store %struct.tm* %1, %struct.tm** %6
store i32* %2, i32** %7
%11 = load i8*, i8** %5
%12 = call i64 @strtoul(i8* %11, i8** %8, i32 10)
store i64 %12, i64* %9
%13 = load i8*, i8** %8
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %39 [
i32 58, label %16
i32 46, label %16
i32 47, label %16
i32 45, label %16
]
16: ; preds = %3, %3, %3, %3
%17 = load i8*, i8** %8
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = call i32 @isdigit(i8 signext %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %38
22: ; preds = %16
%23 = load i64, i64* %9
%24 = load i8*, i8** %8
%25 = load i8, i8* %24
%26 = load i8*, i8** %5
%27 = load i8*, i8** %8
%28 = load %struct.tm*, %struct.tm** %6
%29 = call i32 @match_multi_number(i64 %23, i8 signext %25, i8* %26, i8* %27, %struct.tm* %28)
store i32 %29, i32* %10
%30 = load i32, i32* %10
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %22
%33 = load i8*, i8** %5
%34 = load i32, i32* %10
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8* %36, i8** %4
br label %58
37: ; preds = %22
br label %38
38: ; preds = %37, %16
br label %39
39: ; preds = %38, %3
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 0
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 48
br i1 %44, label %52, label %45
45: ; preds = %39
%46 = load i8*, i8** %8
%47 = load i8*, i8** %5
%48 = ptrtoint i8* %46 to i64
%49 = ptrtoint i8* %47 to i64
%50 = sub i64 %48, %49
%51 = icmp sle i64 %50, 2
br i1 %51, label %52, label %56
52: ; preds = %45, %39
%53 = load i64, i64* %9
%54 = trunc i64 %53 to i32
%55 = load i32*, i32** %7
store i32 %54, i32* %55
br label %56
56: ; preds = %52, %45
%57 = load i8*, i8** %8
store i8* %57, i8** %4
br label %58
58: ; preds = %56, %32
%59 = load i8*, i8** %4
ret i8* %59
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define i8* @approxidate_digit(i8* %0, %struct.tm* %1, i32* nocapture writeonly %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call i64 @strtoul(i8* %0, i8** %4, i32 10)
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %21 [
i32 58, label %10
i32 46, label %10
i32 47, label %10
i32 45, label %10
]
10: ; preds = %3, %3, %3, %3
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = tail call i32 @isdigit(i8 signext %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %10
%16 = load i8, i8* %7
%17 = tail call i32 @match_multi_number(i64 %6, i8 signext %16, i8* %0, i8* %7, %struct.tm* %1)
%18 = icmp eq i32 %17, 0
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
br i1 %18, label %21, label %31
21: ; preds = %10, %15, %3
%22 = load i8, i8* %0
%23 = icmp ne i8 %22, 48
%24 = ptrtoint i8* %7 to i64
%25 = ptrtoint i8* %0 to i64
%26 = sub i64 %24, %25
%27 = icmp slt i64 %26, 3
%28 = or i1 %27, %23
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = trunc i64 %6 to i32
store i32 %30, i32* %2
br label %31
31: ; preds = %21, %29, %15
%32 = phi i8* [ %20, %15 ], [ %7, %29 ], [ %7, %21 ]
ret i8* %32
}