#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
int main(void) {
  int day, month, year;
  int earliest_day = 0, earliest_month = 0, earliest_year = 0;
  int total, earliest_total;
  printf("Enter a  date (mm/dd/yy): ");
  scanf("%d/%d/%d", &month, &day, &year);
  total = year * 365 + month * 30 + day;
  if (total == 0) {
    return 0;
  }
  earliest_total = total;
  while (total != 0) {
    if (total <= earliest_total) {
      earliest_day = day;
      earliest_month = month;
      earliest_year = year;
      earliest_total = total;
    }
    printf("Enter a  date (mm/dd/yy): ");
    scanf("%d/%d/%d", &month, &day, &year);
    total = year * 365 + month * 30 + day;
  }
  printf("The earliest date entered was: %d/%.2d/%.2d\n", earliest_month,
         earliest_day, earliest_year);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x8(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
imul   $0x16d,-0x10(%rbp),%eax
imul   $0x1e,-0xc(%rbp),%ecx
add    %ecx,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    1193 <main+0x73>
movl   $0x0,-0x4(%rbp)
jmp    1223 <main+0x103>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1205 <main+0xe5>
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     11c7 <main+0xa7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3f(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x8(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
imul   $0x16d,-0x10(%rbp),%eax
imul   $0x1e,-0xc(%rbp),%ecx
add    %ecx,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1199 <main+0x79>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
imul   $0x16d,%eax,%edx
mov    0x10(%rsp),%ecx
mov    %ecx,%r12d
shl    $0x5,%r12d
sub    %ecx,%r12d
sub    %ecx,%r12d
add    %edx,%r12d
mov    0x14(%rsp),%edx
add    %edx,%r12d
je     120e <main+0xee>
lea    0x14(%rsp),%r13
lea    0xc(%rsp),%rbx
mov    %r12d,%esi
xor    %ebp,%ebp
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    11e6 <main+0xc6>
nopl   0x0(%rax)
lea    0xe59(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe66(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
imul   $0x16d,%eax,%edx
mov    0x10(%rsp),%ecx
mov    %ecx,%esi
shl    $0x5,%esi
sub    %ecx,%esi
sub    %ecx,%esi
add    %edx,%esi
mov    0x14(%rsp),%edx
add    %edx,%esi
je     11f8 <main+0xd8>
cmp    %r12d,%esi
jg     11a0 <main+0x80>
mov    %edx,%r14d
mov    %ecx,%r15d
mov    %eax,%ebp
mov    %esi,%r12d
jmp    11a0 <main+0x80>
lea    0xe25(%rip),%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter a date (mm/dd/yy): \00"
@.str.1 = [9 x i8] c"%d/%d/%d\00"
@.str.2 = [45 x i8] c"The earliest date entered was: %d/%.2d/%.2d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %2, i32* %4)
%12 = load i32, i32* %4
%13 = mul nsw i32 %12, 365
%14 = load i32, i32* %3
%15 = mul nsw i32 %14, 30
%16 = add nsw i32 %13, %15
%17 = load i32, i32* %2
%18 = add nsw i32 %16, %17
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %0
store i32 0, i32* %1
br label %51
22: ; preds = %0
%23 = load i32, i32* %8
store i32 %23, i32* %9
br label %24
24: ; preds = %36, %22
%25 = load i32, i32* %8
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %46
27: ; preds = %24
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = icmp sle i32 %28, %29
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i32, i32* %2
store i32 %32, i32* %5
%33 = load i32, i32* %3
store i32 %33, i32* %6
%34 = load i32, i32* %4
store i32 %34, i32* %7
%35 = load i32, i32* %8
store i32 %35, i32* %9
br label %36
36: ; preds = %31, %27
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %2, i32* %4)
%39 = load i32, i32* %4
%40 = mul nsw i32 %39, 365
%41 = load i32, i32* %3
%42 = mul nsw i32 %41, 30
%43 = add nsw i32 %40, %42
%44 = load i32, i32* %2
%45 = add nsw i32 %43, %44
store i32 %45, i32* %8
br label %24
46: ; preds = %24
%47 = load i32, i32* %6
%48 = load i32, i32* %5
%49 = load i32, i32* %7
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %47, i32 %48, i32 %49)
store i32 0, i32* %1
br label %51
51: ; preds = %46, %21
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter a date (mm/dd/yy): \00"
@.str.1 = [9 x i8] c"%d/%d/%d\00"
@.str.2 = [45 x i8] c"The earliest date entered was: %d/%.2d/%.2d\0A\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 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %1, i32* %3)
%9 = load i32, i32* %3
%10 = mul nsw i32 %9, 365
%11 = load i32, i32* %2
%12 = mul nsw i32 %11, 30
%13 = add nsw i32 %12, %10
%14 = load i32, i32* %1
%15 = add nsw i32 %13, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %45, label %17
17: ; preds = %0, %28
%18 = phi i32 [ %35, %28 ], [ %9, %0 ]
%19 = phi i32 [ %37, %28 ], [ %11, %0 ]
%20 = phi i32 [ %40, %28 ], [ %14, %0 ]
%21 = phi i32 [ %32, %28 ], [ %15, %0 ]
%22 = phi i32 [ %41, %28 ], [ %15, %0 ]
%23 = phi i32 [ %31, %28 ], [ 0, %0 ]
%24 = phi i32 [ %30, %28 ], [ 0, %0 ]
%25 = phi i32 [ %29, %28 ], [ 0, %0 ]
%26 = icmp sgt i32 %22, %21
br i1 %26, label %28, label %27
27: ; preds = %17
br label %28
28: ; preds = %27, %17
%29 = phi i32 [ %20, %27 ], [ %25, %17 ]
%30 = phi i32 [ %19, %27 ], [ %24, %17 ]
%31 = phi i32 [ %18, %27 ], [ %23, %17 ]
%32 = phi i32 [ %22, %27 ], [ %21, %17 ]
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %1, i32* %3)
%35 = load i32, i32* %3
%36 = mul nsw i32 %35, 365
%37 = load i32, i32* %2
%38 = mul nsw i32 %37, 30
%39 = add nsw i32 %38, %36
%40 = load i32, i32* %1
%41 = add nsw i32 %39, %40
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %17
43: ; preds = %28
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %29, i32 %31)
br label %45
45: ; preds = %0, %43
ret i32 0
}