#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 dateCompare(char *, char *);
int getDay(char *);
int getMonth(char *);
int getYear(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
int main() {
  int d = 0, m = 0, y = 0;
  int res = 0;
  char mydate1[11] = "03/11/2008";
  char mydate2[11] = "26/11/2008";
  printf("\n");
  printf("testing the conversion of a date representation from string to "
         "integers (d, m, y): \n");
  d = getDay(mydate1);
  if (d < 0) {
    printf("<main> Error (code %d) in converting the day: %s\n", d, mydate1);
    return -1;
  }
  m = getMonth(mydate1);
  if (m < 0) {
    printf("<main> Error (code %d) in converting the month: %s\n", m, mydate1);
    return -1;
  }
  y = getYear(mydate1);
  if (y < 0) {
    printf("<main> Error (code %d) in converting the year: %s\n", y, mydate1);
    return -1;
  }
  printf("%s ==> %d-%d-%d\n", mydate1, d, m, y);
  printf("\n");
  printf("testing dateCompare: \n");
  res = dateCompare(mydate1, mydate2);
  if (res == -9)
    printf("Error with dates \n");
  if (res == -1)
    printf("%s is before %s \n", mydate1, mydate2);
  if (res == 1)
    printf("%s is after %s \n", mydate1, mydate2);
  if (res == 0)
    printf("%s is the same as %s \n", mydate1, mydate2);
  system("PAUSE");
  return (1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xe6e(%rip),%rax
mov    %rax,-0x1f(%rbp)
mov    0xe6b(%rip),%ax
mov    %ax,-0x17(%rbp)
mov    0xe63(%rip),%al
mov    %al,-0x15(%rbp)
mov    0xe5a(%rip),%rax
mov    %rax,-0x2a(%rbp)
mov    0xe57(%rip),%ax
mov    %ax,-0x22(%rbp)
mov    0xe4f(%rip),%al
mov    %al,-0x20(%rbp)
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1f(%rbp),%rdi
call   1070 <getDay@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    121c <main+0xbc>
mov    -0x8(%rbp),%esi
lea    -0x1f(%rbp),%rdx
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135d <main+0x1fd>
lea    -0x1f(%rbp),%rdi
call   1080 <getMonth@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1253 <main+0xf3>
mov    -0xc(%rbp),%esi
lea    -0x1f(%rbp),%rdx
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135d <main+0x1fd>
lea    -0x1f(%rbp),%rdi
call   1040 <getYear@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    128a <main+0x12a>
mov    -0x10(%rbp),%esi
lea    -0x1f(%rbp),%rdx
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135d <main+0x1fd>
lea    -0x1f(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1f(%rbp),%rdi
lea    -0x2a(%rbp),%rsi
call   1030 <dateCompare@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xfffffff7,-0x14(%rbp)
jne    12ea <main+0x18a>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0xffffffff,-0x14(%rbp)
jne    130a <main+0x1aa>
lea    -0x1f(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    132a <main+0x1ca>
lea    -0x1f(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    134a <main+0x1ea>
lea    -0x1f(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe28(%rip),%rdi
call   1050 <system@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movabs $0x30322f31312f3330,%rax
2f 32 30
mov    %rax,(%rsp)
movl   $0x383030,0x7(%rsp)
movabs $0x30322f31312f3632,%rax
2f 32 30
mov    %rax,0x10(%rsp)
movl   $0x383030,0x17(%rsp)
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xf66(%rip),%rdi
call   1060 <puts@plt>
mov    %rsp,%rdi
call   1090 <getDay@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1263 <main+0xe3>
mov    %rsp,%rdi
call   10a0 <getMonth@plt>
mov    %eax,%ebp
test   %eax,%eax
js     1271 <main+0xf1>
mov    %rsp,%rdi
call   1050 <getYear@plt>
test   %eax,%eax
js     127f <main+0xff>
lea    0xed5(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xf55(%rip),%rdi
call   1060 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1030 <dateCompare@plt>
add    $0x9,%eax
cmp    $0xa,%eax
ja     12c1 <main+0x141>
lea    0xdb4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf3a(%rip),%rdi
call   1060 <puts@plt>
jmp    12c1 <main+0x141>
lea    0xdd8(%rip),%rdi
mov    %rsp,%rdx
mov    %ebx,%esi
jmp    128b <main+0x10b>
lea    0xdfc(%rip),%rdi
mov    %rsp,%rdx
mov    %ebp,%esi
jmp    128b <main+0x10b>
lea    0xe22(%rip),%rdi
mov    %rsp,%rdx
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xffffffff,%eax
jmp    12d2 <main+0x152>
lea    0xe4c(%rip),%rdi
jmp    12b2 <main+0x132>
lea    0xe66(%rip),%rdi
jmp    12b2 <main+0x132>
lea    0xe4c(%rip),%rdi
mov    %rsp,%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe5e(%rip),%rdi
call   1070 <system@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.mydate1 = [11 x i8] c"03/11/2008\00"
@__const.main.mydate2 = [11 x i8] c"26/11/2008\00"
@.str = [2 x i8] c"\0A\00"
@.str.1 = [85 x i8] c"testing the conversion of a date representation from string to integers (d, m, y): \0A\00"
@.str.2 = [50 x i8] c"<main> Error (code %d) in converting the day: %s\0A\00"
@.str.3 = [52 x i8] c"<main> Error (code %d) in converting the month: %s\0A\00"
@.str.4 = [51 x i8] c"<main> Error (code %d) in converting the year: %s\0A\00"
@.str.5 = [17 x i8] c"%s ==> %d-%d-%d\0A\00"
@.str.6 = [23 x i8] c"testing dateCompare: \0A\00"
@.str.7 = [19 x i8] c"Error with dates \0A\00"
@.str.8 = [18 x i8] c"%s is before %s \0A\00"
@.str.9 = [17 x i8] c"%s is after %s \0A\00"
@.str.10 = [23 x i8] c"%s is the same as %s \0A\00"
@.str.11 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [11 x i8]
%7 = alloca [11 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%8 = bitcast [11 x i8]* %6 to i8*
%9 = bitcast [11 x i8]* %7 to i8*
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%13 = call i32 @getDay(i8* %12)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %0
%17 = load i32, i32* %2
%18 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %17, i8* %18)
store i32 -1, i32* %1
br label %76
20: ; preds = %0
%21 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%22 = call i32 @getMonth(i8* %21)
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = load i32, i32* %3
%27 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i32 %26, i8* %27)
store i32 -1, i32* %1
br label %76
29: ; preds = %20
%30 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%31 = call i32 @getYear(i8* %30)
store i32 %31, i32* %4
%32 = load i32, i32* %4
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32, i32* %4
%36 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %35, i8* %36)
store i32 -1, i32* %1
br label %76
38: ; preds = %29
%39 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%40 = load i32, i32* %2
%41 = load i32, i32* %3
%42 = load i32, i32* %4
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %39, i32 %40, i32 %41, i32 %42)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%46 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%47 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%48 = call i32 @dateCompare(i8* %46, i8* %47)
store i32 %48, i32* %5
%49 = load i32, i32* %5
%50 = icmp eq i32 %49, -9
br i1 %50, label %51, label %53
51: ; preds = %38
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %53
53: ; preds = %51, %38
%54 = load i32, i32* %5
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %60
56: ; preds = %53
%57 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%58 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* %57, i8* %58)
br label %60
60: ; preds = %56, %53
%61 = load i32, i32* %5
%62 = icmp eq i32 %61, 1
br i1 %62, label %63, label %67
63: ; preds = %60
%64 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%65 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %64, i8* %65)
br label %67
67: ; preds = %63, %60
%68 = load i32, i32* %5
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %67
%71 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%72 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* %71, i8* %72)
br label %74
74: ; preds = %70, %67
%75 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %1
br label %76
76: ; preds = %74, %34, %25, %16
%77 = load i32, i32* %1
ret i32 %77
}

LLVM IR (-O2):
@__const.main.mydate1 = [11 x i8] c"03/11/2008\00"
@__const.main.mydate2 = [11 x i8] c"26/11/2008\00"
@.str.2 = [50 x i8] c"<main> Error (code %d) in converting the day: %s\0A\00"
@.str.3 = [52 x i8] c"<main> Error (code %d) in converting the month: %s\0A\00"
@.str.4 = [51 x i8] c"<main> Error (code %d) in converting the year: %s\0A\00"
@.str.5 = [17 x i8] c"%s ==> %d-%d-%d\0A\00"
@.str.8 = [18 x i8] c"%s is before %s \0A\00"
@.str.9 = [17 x i8] c"%s is after %s \0A\00"
@.str.10 = [23 x i8] c"%s is the same as %s \0A\00"
@.str.11 = [6 x i8] c"PAUSE\00"
@str = [84 x i8] c"testing the conversion of a date representation from string to integers (d, m, y): \00"
@str.12 = [22 x i8] c"testing dateCompare: \00"
@str.13 = [18 x i8] c"Error with dates \00"
define i32 @main() {
%1 = alloca [11 x i8]
%2 = alloca [11 x i8]
%3 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @putchar(i32 10)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([84 x i8], [84 x i8]* @str, i64 0, i64 0))
%7 = call i32 @getDay(i8* %3)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %7, i8* %3)
br label %36
11: ; preds = %0
%12 = call i32 @getMonth(i8* %3)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i32 %12, i8* %3)
br label %36
16: ; preds = %11
%17 = call i32 @getYear(i8* %3)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %17, i8* %3)
br label %36
21: ; preds = %16
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %3, i32 %7, i32 %12, i32 %17)
%23 = call i32 @putchar(i32 10)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0))
%25 = call i32 @dateCompare(i8* %3, i8* %4)
switch i32 %25, label %34 [
i32 -9, label %26
i32 -1, label %28
i32 1, label %30
i32 0, label %32
]
26: ; preds = %21
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.13, i64 0, i64 0))
br label %34
28: ; preds = %21
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* %3, i8* %4)
br label %34
30: ; preds = %21
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %3, i8* %4)
br label %34
32: ; preds = %21
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* %3, i8* %4)
br label %34
34: ; preds = %30, %28, %26, %21, %32
%35 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
br label %36
36: ; preds = %34, %19, %14, %9
%37 = phi i32 [ -1, %9 ], [ -1, %14 ], [ -1, %19 ], [ 1, %34 ]
ret i32 %37
}