#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 EOF;
int minscanf(char *, int *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *);
int main(void) {
  int day, month, year;
  int res = 0, ln = 0;
  while (res != EOF) {
    ln++;
    res = minscanf(" %d/%d/%d", &day, &month, &year);
    printf("\nLine: %i\t", ln);
    printf("result: %d\n", res);
    if (res == 3) {
      printf("Full match!\t");
      printf("d: %d, m: %d, y: %d\n", day, month, year);
    } else
      printf("no (full) match\n");
    printf("---Done\n");
    res = scanf("%*[^\n]%*[\n]");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
je     1209 <main+0xd9>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
lea    0xe91(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <minscanf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x14(%rbp)
jne    11d9 <main+0xa9>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e7 <main+0xb7>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe61(%rip),%rdi
call   1050 <scanf@plt>
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e93(%rip),%rax
cmpl   $0x0,(%rax)
je     1224 <main+0xe4>
mov    $0x1,%ebx
lea    0xea0(%rip),%rbp
lea    0xea4(%rip),%r14
lea    0xee7(%rip),%r15
lea    0xec4(%rip),%r12
jmp    11ba <main+0x7a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1060 <scanf@plt>
add    $0x1,%ebx
mov    0x2e32(%rip),%rcx
cmp    (%rcx),%eax
je     1224 <main+0xe4>
lea    0xe3f(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1050 <minscanf@plt>
mov    %eax,%r13d
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x3,%r13d
jne    1190 <main+0x50>
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    119c <main+0x5c>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [10 x i8] c" %d/%d/%d\00"
@.str.1 = [11 x i8] c"\0ALine: %i\09\00"
@.str.2 = [12 x i8] c"result: %d\0A\00"
@.str.3 = [13 x i8] c"Full match!\09\00"
@.str.4 = [21 x i8] c"d: %d, m: %d, y: %d\0A\00"
@.str.5 = [17 x i8] c"no (full) match\0A\00"
@.str.6 = [9 x i8] c"---Done\0A\00"
@.str.7 = [12 x i8] c"%*[^\0A]%*[\0A]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %29, %0
%8 = load i32, i32* %5
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %32
11: ; preds = %7
%12 = load i32, i32* %6
%13 = add nsw i32 %12, 1
store i32 %13, i32* %6
%14 = call i32 @minscanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
store i32 %14, i32* %5
%15 = load i32, i32* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %5
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 3
br i1 %20, label %21, label %27
21: ; preds = %11
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %23, i32 %24, i32 %25)
br label %29
27: ; preds = %11
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %29
29: ; preds = %27, %21
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
store i32 %31, i32* %5
br label %7
32: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [10 x i8] c" %d/%d/%d\00"
@.str.1 = [11 x i8] c"\0ALine: %i\09\00"
@.str.2 = [12 x i8] c"result: %d\0A\00"
@.str.3 = [13 x i8] c"Full match!\09\00"
@.str.4 = [21 x i8] c"d: %d, m: %d, y: %d\0A\00"
@.str.7 = [12 x i8] c"%*[^\0A]%*[\0A]\00"
@str = [16 x i8] c"no (full) match\00"
@str.8 = [8 x i8] c"---Done\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %7, 0
br i1 %8, label %29, label %9
9: ; preds = %0, %24
%10 = phi i32 [ %11, %24 ], [ 0, %0 ]
%11 = add nuw nsw i32 %10, 1
%12 = call i32 @minscanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%15 = icmp eq i32 %12, 3
br i1 %15, label %16, label %22
16: ; preds = %9
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %18, i32 %19, i32 %20)
br label %24
22: ; preds = %9
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %22, %16
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.8, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%27 = load i32, i32* @EOF
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %9
29: ; preds = %24, %0
ret i32 0
}