#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, unsigned char,
                           unsigned char);
int eb_dat_to_str(unsigned char dd, unsigned char mm, unsigned char yy,
                  char *tgt) {
  if (dd >= 0x00 && dd <= 0x1F && mm >= 0x00 && mm <= 0x0C && yy >= 0x00 &&
      yy <= 0x63)
    sprintf(tgt, "%02d.%02d.%04d", dd, mm, yy + 2000);
  else
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<eb_dat_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x5(%rbp)
mov    %dl,-0x6(%rbp)
mov    %al,-0x7(%rbp)
mov    %rcx,-0x10(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x0,%eax
jl     11aa <eb_dat_to_str+0x9a>
movzbl -0x5(%rbp),%eax
cmp    $0x1f,%eax
jg     11aa <eb_dat_to_str+0x9a>
movzbl -0x6(%rbp),%eax
cmp    $0x0,%eax
jl     11aa <eb_dat_to_str+0x9a>
movzbl -0x6(%rbp),%eax
cmp    $0xc,%eax
jg     11aa <eb_dat_to_str+0x9a>
movzbl -0x7(%rbp),%eax
cmp    $0x0,%eax
jl     11aa <eb_dat_to_str+0x9a>
movzbl -0x7(%rbp),%eax
cmp    $0x63,%eax
jg     11aa <eb_dat_to_str+0x9a>
mov    -0x10(%rbp),%rdi
mov    -0x5(%rbp),%dl
mov    -0x6(%rbp),%cl
movzbl -0x7(%rbp),%eax
add    $0x7d0,%eax
lea    0xe6a(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %al,%r8d
call   1030 <sprintf@plt>
jmp    11b6 <eb_dat_to_str+0xa6>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bd <eb_dat_to_str+0xad>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eb_dat_to_str>:
mov    $0xffffffff,%eax
cmp    $0x1f,%dil
ja     1150 <eb_dat_to_str+0x40>
cmp    $0xc,%sil
ja     1150 <eb_dat_to_str+0x40>
cmp    $0x63,%dl
ja     1150 <eb_dat_to_str+0x40>
push   %rax
add    $0xd0,%dl
movzbl %dil,%eax
movzbl %sil,%r9d
movzbl %dl,%r8d
lea    0xec3(%rip),%rsi
mov    %rcx,%rdi
mov    %eax,%edx
mov    %r9d,%ecx
call   1030 <sprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%02d.%02d.%04d\00"
define i32 @eb_dat_to_str(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8*
store i8 %0, i8* %6
store i8 %1, i8* %7
store i8 %2, i8* %8
store i8* %3, i8** %9
%10 = load i8, i8* %6
%11 = zext i8 %10 to i32
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %42
13: ; preds = %4
%14 = load i8, i8* %6
%15 = zext i8 %14 to i32
%16 = icmp sle i32 %15, 31
br i1 %16, label %17, label %42
17: ; preds = %13
%18 = load i8, i8* %7
%19 = zext i8 %18 to i32
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %42
21: ; preds = %17
%22 = load i8, i8* %7
%23 = zext i8 %22 to i32
%24 = icmp sle i32 %23, 12
br i1 %24, label %25, label %42
25: ; preds = %21
%26 = load i8, i8* %8
%27 = zext i8 %26 to i32
%28 = icmp sge i32 %27, 0
br i1 %28, label %29, label %42
29: ; preds = %25
%30 = load i8, i8* %8
%31 = zext i8 %30 to i32
%32 = icmp sle i32 %31, 99
br i1 %32, label %33, label %42
33: ; preds = %29
%34 = load i8*, i8** %9
%35 = load i8, i8* %6
%36 = load i8, i8* %7
%37 = load i8, i8* %8
%38 = zext i8 %37 to i32
%39 = add nsw i32 %38, 2000
%40 = trunc i32 %39 to i8
%41 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8 zeroext %35, i8 zeroext %36, i8 zeroext %40)
br label %43
42: ; preds = %29, %25, %21, %17, %13, %4
store i32 -1, i32* %5
br label %44
43: ; preds = %33
store i32 0, i32* %5
br label %44
44: ; preds = %43, %42
%45 = load i32, i32* %5
ret i32 %45
}

LLVM IR (-O2):
@.str = [15 x i8] c"%02d.%02d.%04d\00"
define i32 @eb_dat_to_str(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8* nocapture writeonly %3) {
%5 = icmp ult i8 %0, 32
%6 = icmp ult i8 %1, 13
%7 = and i1 %5, %6
%8 = icmp ult i8 %2, 100
%9 = and i1 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = add nsw i8 %2, -48
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8 zeroext %0, i8 zeroext %1, i8 zeroext %11)
br label %13
13: ; preds = %4, %10
%14 = phi i32 [ 0, %10 ], [ -1, %4 ]
ret i32 %14
}