#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 /*<<< orphan*/ tm_year;
  int /*<<< orphan*/ tm_mon;
  int /*<<< orphan*/ tm_mday;
};

/* Variables and functions */
char EOF;
char getchar();
int scanf(char *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
          int /*<<< orphan*/ *);
void stub1();
int ReadDate(struct tm *OutResult, void (*OnInvalidInput)(void)) {
  if (!OutResult) {
    return 1;
  }
  while (scanf("%d/%d/%d", &OutResult->tm_mday, &OutResult->tm_mon,
               &OutResult->tm_year) < 3) {
    char c = '\0';
    while ((c = getchar()) != '\n' && c != EOF) {
      continue;
    }
    if (OnInvalidInput)
      (*OnInvalidInput)();
  }
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<ReadDate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1147 <ReadDate+0x27>
movl   $0x1,-0x4(%rbp)
jmp    11e0 <ReadDate+0xc0>
jmp    114c <ReadDate+0x2c>
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    -0x10(%rbp),%rdx
add    $0x4,%rdx
mov    -0x10(%rbp),%rcx
lea    0xe99(%rip),%rdi
call   1040 <scanf@plt>
cmp    $0x3,%eax
jge    11d2 <ReadDate+0xb2>
movb   $0x0,-0x19(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1a(%rbp)
je     11aa <ReadDate+0x8a>
movsbl -0x19(%rbp),%eax
mov    0x2e49(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    11ba <ReadDate+0x9a>
jmp    11bf <ReadDate+0x9f>
jmp    1179 <ReadDate+0x59>
cmpq   $0x0,-0x18(%rbp)
je     11cd <ReadDate+0xad>
call   *-0x18(%rbp)
jmp    114c <ReadDate+0x2c>
mov    $0x0,%al
call   1030 <getchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadDate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11aa <ReadDate+0x8a>
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x8(%rdi),%r15
lea    0x4(%rdi),%r12
lea    0xebb(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
call   1040 <scanf@plt>
cmp    $0x2,%eax
jg     119f <ReadDate+0x7f>
mov    0x2e89(%rip),%rbp
lea    0xe9a(%rip),%r13
jmp    1186 <ReadDate+0x66>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
call   1040 <scanf@plt>
cmp    $0x3,%eax
jge    119f <ReadDate+0x7f>
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
je     1196 <ReadDate+0x76>
cmp    0x0(%rbp),%al
jne    1186 <ReadDate+0x66>
test   %rbx,%rbx
je     1170 <ReadDate+0x50>
call   *%rbx
jmp    1170 <ReadDate+0x50>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
jmp    11af <ReadDate+0x8f>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@.str = [9 x i8] c"%d/%d/%d\00"
@EOF = global i8 0
define i32 @ReadDate(%struct.tm* %0, void ()* %1) {
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca void ()*
%6 = alloca i8
store %struct.tm* %0, %struct.tm** %4
store void ()* %1, void ()** %5
%7 = load %struct.tm*, %struct.tm** %4
%8 = icmp ne %struct.tm* %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i32 1, i32* %3
br label %42
10: ; preds = %2
br label %11
11: ; preds = %39, %10
%12 = load %struct.tm*, %struct.tm** %4
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 2
%14 = load %struct.tm*, %struct.tm** %4
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 1
%16 = load %struct.tm*, %struct.tm** %4
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 0
%18 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %13, i32* %15, i32* %17)
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %40
20: ; preds = %11
store i8 0, i8* %6
br label %21
21: ; preds = %33, %20
%22 = call signext i8 (...) @getchar()
store i8 %22, i8* %6
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 10
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i8, i8* %6
%27 = sext i8 %26 to i32
%28 = load i8, i8* @EOF
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %27, %29
br label %31
31: ; preds = %25, %21
%32 = phi i1 [ false, %21 ], [ %30, %25 ]
br i1 %32, label %33, label %34
33: ; preds = %31
br label %21
34: ; preds = %31
%35 = load void ()*, void ()** %5
%36 = icmp ne void ()* %35, null
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = load void ()*, void ()** %5
br label %39
39: ; preds = %37, %34
br label %11
40: ; preds = %11
%41 = call signext i8 (...) @getchar()
store i32 0, i32* %3
br label %42
42: ; preds = %40, %9
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@.str = [9 x i8] c"%d/%d/%d\00"
@EOF = global i8 0
define i32 @ReadDate(%struct.tm* %0, void ()* %1) {
%3 = icmp eq %struct.tm* %0, null
br i1 %3, label %26, label %4
4: ; preds = %2
%5 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 2
%6 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 1
%7 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 0
%8 = tail call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7)
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %24
10: ; preds = %4
%11 = icmp eq void ()* %1, null
br label %12
12: ; preds = %18, %10
%13 = tail call signext i8 (...) @getchar()
%14 = icmp ne i8 %13, 10
%15 = load i8, i8* @EOF
%16 = icmp ne i8 %13, %15
%17 = select i1 %14, i1 %16, i1 false
br i1 %17, label %18, label %19
18: ; preds = %12, %21
br label %12
19: ; preds = %12
br i1 %11, label %21, label %20
20: ; preds = %19
tail call void %1()
br label %21
21: ; preds = %20, %19
%22 = tail call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7)
%23 = icmp slt i32 %22, 3
br i1 %23, label %18, label %24
24: ; preds = %21, %4
%25 = tail call signext i8 (...) @getchar()
br label %26
26: ; preds = %2, %24
%27 = phi i32 [ 0, %24 ], [ 1, %2 ]
ret i32 %27
}