#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 LateByDays(char *, char *);
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char duedt[9];
  char subdt[9];
  int dtdue, dtsub, dtlate;
  printf(
      "Note: this program does not check the correctness of entered values.\n");
  printf("Please enter valid values.\n");
  printf("Enter hw01 due date as YYYYMMDD> ");
  scanf("%s", duedt);
  printf("You entered %s\n", duedt);
  printf("Enter hw01 submission date as YYYYMMDD> ");
  scanf("%s", subdt);
  printf("You entered %s\n", subdt);
  dtdue = atoi(duedt);
  dtsub = atoi(subdt);
  if ((dtsub == dtdue) || (dtsub < dtdue)) {
    printf("Not a late submission.\n");
    exit(0);
  }
  dtlate = LateByDays(duedt, subdt);
  if (dtlate < 0)
    printf("Error in LateByDays() function!\n");
  else
    printf("You are late by %d day(s).\n", dtlate);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xd(%rbp),%rsi
lea    0xef0(%rip),%rdi
call   1050 <scanf@plt>
lea    -0xd(%rbp),%rsi
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x16(%rbp),%rsi
lea    0xec0(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x16(%rbp),%rsi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xd(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x16(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     120b <main+0xbb>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1220 <main+0xd0>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    -0xd(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1040 <LateByDays@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    124d <main+0xfd>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125e <main+0x10e>
mov    -0x24(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
lea    0xf40(%rip),%rdi
call   1030 <puts@plt>
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe89(%rip),%r14
lea    0x17(%rsp),%r12
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
lea    0xe75(%rip),%r15
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe71(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <atoi@plt>
cmp    %ebp,%eax
jle    123e <main+0xde>
lea    0x17(%rsp),%rdi
lea    0xe(%rsp),%rsi
call   1050 <LateByDays@plt>
test   %eax,%eax
js     1223 <main+0xc3>
lea    0xe46(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    122f <main+0xcf>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [70 x i8] c"Note: this program does not check the correctness of entered values.\0A\00"
@.str.1 = [28 x i8] c"Please enter valid values.\0A\00"
@.str.2 = [34 x i8] c"Enter hw01 due date as YYYYMMDD> \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [16 x i8] c"You entered %s\0A\00"
@.str.5 = [41 x i8] c"Enter hw01 submission date as YYYYMMDD> \00"
@.str.6 = [24 x i8] c"Not a late submission.\0A\00"
@.str.7 = [33 x i8] c"Error in LateByDays() function!\0A\00"
@.str.8 = [28 x i8] c"You are late by %d day(s).\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i8]
%3 = alloca [9 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%15 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %4
%21 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = load i32, i32* %4
%25 = icmp eq i32 %23, %24
br i1 %25, label %30, label %26
26: ; preds = %0
%27 = load i32, i32* %5
%28 = load i32, i32* %4
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %33
30: ; preds = %26, %0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%32 = call i32 @exit(i32 0)
unreachable
33: ; preds = %26
%34 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%35 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%36 = call i32 @LateByDays(i8* %34, i8* %35)
store i32 %36, i32* %6
%37 = load i32, i32* %6
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %33
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
br label %44
41: ; preds = %33
%42 = load i32, i32* %6
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %41, %39
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [34 x i8] c"Enter hw01 due date as YYYYMMDD> \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [16 x i8] c"You entered %s\0A\00"
@.str.5 = [41 x i8] c"Enter hw01 submission date as YYYYMMDD> \00"
@.str.8 = [28 x i8] c"You are late by %d day(s).\0A\00"
@str = [69 x i8] c"Note: this program does not check the correctness of entered values.\00"
@str.9 = [27 x i8] c"Please enter valid values.\00"
@str.10 = [32 x i8] c"Error in LateByDays() function!\00"
@str.11 = [23 x i8] c"Not a late submission.\00"
define i32 @main() {
%1 = alloca [9 x i8]
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%13 = call i32 @atoi(i8* %3)
%14 = call i32 @atoi(i8* %4)
%15 = icmp sgt i32 %14, %13
br i1 %15, label %19, label %16
16: ; preds = %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0))
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %0
%20 = call i32 @LateByDays(i8* %3, i8* %4)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.10, i64 0, i64 0))
br label %26
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i32 %20)
br label %26
26: ; preds = %24, %22
ret i32 0
}