#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*/ sprintf(char *, char *, unsigned char const *);
int to_int(unsigned char const *, int);
int /*<<< orphan*/ yymmd0(unsigned char const *, int, int, int, int, int *,
                          int *, char *, int const);
int yymmdd(const unsigned char *data, int data_len, int offset, int min,
           int max, int *p_err_no, int *p_err_posn, char err_msg[50],
           const int length_only) {
  if (!yymmd0(data, data_len, offset, min, max, p_err_no, p_err_posn, err_msg,
              length_only)) {
    return 0;
  }
  data_len -= offset;
  if (!length_only && data_len) {
    int day = to_int(data + offset + 4, 2);
    if (day == 0) {
      *p_err_no = 3;
      *p_err_posn = offset + 4 + 1;
      sprintf(err_msg, "Invalid day '%.2s'", data + offset + 4);
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<yymmdd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    0x10(%rbp),%r11
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%eax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <yymmd0@plt>
cmp    $0x0,%eax
jne    119f <yymmdd+0x6f>
movl   $0x0,-0x4(%rbp)
jmp    1234 <yymmdd+0x104>
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,0x20(%rbp)
jne    122d <yymmdd+0xfd>
cmpl   $0x0,-0x14(%rbp)
je     122d <yymmdd+0xfd>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
add    $0x4,%rdi
mov    $0x2,%esi
call   1030 <to_int@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1228 <yymmdd+0xf8>
mov    -0x28(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x18(%rbp),%ecx
add    $0x4,%ecx
add    $0x1,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
movslq -0x18(%rbp),%rax
add    %rax,%rdx
add    $0x4,%rdx
lea    0xde9(%rip),%rsi
call   1040 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1234 <yymmdd+0x104>
jmp    122d <yymmdd+0xfd>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yymmdd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %edx,%r13d
mov    %esi,%ebx
mov    %rdi,%r12
mov    0x50(%rsp),%r15d
sub    $0x8,%rsp
push   %r15
push   0x58(%rsp)
push   0x58(%rsp)
call   1050 <yymmd0@plt>
add    $0x20,%rsp
xor    %ebp,%ebp
test   %eax,%eax
je     11bc <yymmdd+0x8c>
mov    $0x1,%ebp
cmp    %r13d,%ebx
je     11bc <yymmdd+0x8c>
test   %r15d,%r15d
jne    11bc <yymmdd+0x8c>
movslq %r13d,%rax
lea    (%r12,%rax,1),%rbx
add    $0x4,%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <to_int@plt>
test   %eax,%eax
jne    11bc <yymmdd+0x8c>
movl   $0x3,(%r14)
add    $0x5,%r13d
mov    0x40(%rsp),%rax
mov    %r13d,(%rax)
lea    0xe53(%rip),%rsi
mov    0x48(%rsp),%rdi
mov    %rbx,%rdx
call   1040 <sprintf@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Invalid day '%.2s'\00"
define i32 @yymmdd(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5, i32* %6, i8* %7, i32 %8) {
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
store i8* %0, i8** %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store i32 %3, i32* %14
store i32 %4, i32* %15
store i32* %5, i32** %16
store i32* %6, i32** %17
store i8* %7, i8** %18
store i32 %8, i32* %19
%21 = load i8*, i8** %11
%22 = load i32, i32* %12
%23 = load i32, i32* %13
%24 = load i32, i32* %14
%25 = load i32, i32* %15
%26 = load i32*, i32** %16
%27 = load i32*, i32** %17
%28 = load i8*, i8** %18
%29 = load i32, i32* %19
%30 = call i32 @yymmd0(i8* %21, i32 %22, i32 %23, i32 %24, i32 %25, i32* %26, i32* %27, i8* %28, i32 %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %9
store i32 0, i32* %10
br label %66
33: ; preds = %9
%34 = load i32, i32* %13
%35 = load i32, i32* %12
%36 = sub nsw i32 %35, %34
store i32 %36, i32* %12
%37 = load i32, i32* %19
%38 = icmp ne i32 %37, 0
br i1 %38, label %65, label %39
39: ; preds = %33
%40 = load i32, i32* %12
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %65
42: ; preds = %39
%43 = load i8*, i8** %11
%44 = load i32, i32* %13
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = getelementptr inbounds i8, i8* %46, i64 4
%48 = call i32 @to_int(i8* %47, i32 2)
store i32 %48, i32* %20
%49 = load i32, i32* %20
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %64
51: ; preds = %42
%52 = load i32*, i32** %16
store i32 3, i32* %52
%53 = load i32, i32* %13
%54 = add nsw i32 %53, 4
%55 = add nsw i32 %54, 1
%56 = load i32*, i32** %17
store i32 %55, i32* %56
%57 = load i8*, i8** %18
%58 = load i8*, i8** %11
%59 = load i32, i32* %13
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = getelementptr inbounds i8, i8* %61, i64 4
%63 = call i32 @sprintf(i8* %57, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %62)
store i32 0, i32* %10
br label %66
64: ; preds = %42
br label %65
65: ; preds = %64, %39, %33
store i32 1, i32* %10
br label %66
66: ; preds = %65, %51, %32
%67 = load i32, i32* %10
ret i32 %67
}

LLVM IR (-O2):
@.str = [19 x i8] c"Invalid day '%.2s'\00"
define i32 @yymmdd(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5, i32* %6, i8* %7, i32 %8) {
%10 = tail call i32 @yymmd0(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5, i32* %6, i8* %7, i32 %8)
%11 = icmp eq i32 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %9
%13 = icmp eq i32 %8, 0
%14 = icmp ne i32 %1, %2
%15 = and i1 %14, %13
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = sext i32 %2 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 4
%20 = tail call i32 @to_int(i8* %19, i32 2)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16
store i32 3, i32* %5
%23 = add nsw i32 %2, 5
store i32 %23, i32* %6
%24 = tail call i32 @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %25
25: ; preds = %16, %12, %22, %9
%26 = phi i32 [ 0, %22 ], [ 0, %9 ], [ 1, %12 ], [ 1, %16 ]
ret i32 %26
}