#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 /*<<< orphan*/ system(char *);
main() {
  system("title 19_Cascallar_Autrán_Manuel");
  system("color 0A");
  system("cls");
  printf("DIAS QUE TEN UN MES DENTRO DUN ANO\n");
  printf("==================================\n\n");
  int meses, anos, dias, resto_de_anos_1, resto_de_anos_2, resto_de_anos_3;
  printf("Introduce o mes:\n");
  scanf("%d", &meses);
  printf("Introduce o ano:\n");
  scanf("%d", &anos);
  resto_de_anos_1 = anos % 400;
  resto_de_anos_2 = anos % 4;
  resto_de_anos_3 = anos % 100;
  if (anos >= 1582) {
    if (meses == 1 || meses == 3 || meses == 5 || meses == 7 || meses == 8 ||
        meses == 10 || meses == 12) {
      printf("Este mes ten 31 d\241as\n");
    } else if (meses == 4 || meses == 6 || meses == 9 || meses == 11) {
      printf("Este mes ten 30 d\241as\n");
    } else if (meses == 2)
      if (resto_de_anos_1 == 0 ||
          (resto_de_anos_2 == 0 && resto_de_anos_3 != 0)) {
        printf("Este mes ten 29 d\241as\n");
      } else
        printf("Este mes ten 28 d\241as\n");
    else
      printf("Este mes non existe\n");
  } else
    printf("Neste ano todav\241a non se usaba os calendario gregoriano\n");
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <system@plt>
lea    0xed0(%rip),%rdi
call   1030 <system@plt>
lea    0xecd(%rip),%rdi
call   1030 <system@plt>
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
lea    0xedd(%rip),%rdi
call   1040 <printf@plt>
lea    0xef6(%rip),%rdi
call   1040 <printf@plt>
lea    0xefc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeef(%rip),%rdi
call   1040 <printf@plt>
lea    0xee0(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
cmpl   $0x62e,-0xc(%rbp)
jl     12df <main+0x1af>
cmpl   $0x1,-0x8(%rbp)
je     1230 <main+0x100>
cmpl   $0x3,-0x8(%rbp)
je     1230 <main+0x100>
cmpl   $0x5,-0x8(%rbp)
je     1230 <main+0x100>
cmpl   $0x7,-0x8(%rbp)
je     1230 <main+0x100>
cmpl   $0x8,-0x8(%rbp)
je     1230 <main+0x100>
cmpl   $0xa,-0x8(%rbp)
je     1230 <main+0x100>
cmpl   $0xc,-0x8(%rbp)
jne    1241 <main+0x111>
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
jmp    12da <main+0x1aa>
cmpl   $0x4,-0x8(%rbp)
je     1269 <main+0x139>
cmpl   $0x6,-0x8(%rbp)
je     1269 <main+0x139>
cmpl   $0x9,-0x8(%rbp)
je     1269 <main+0x139>
cmpl   $0xb,-0x8(%rbp)
jne    127a <main+0x14a>
lea    0xe45(%rip),%rdi
call   1040 <printf@plt>
jmp    12d5 <main+0x1a5>
cmpl   $0x2,-0x8(%rbp)
jne    12c4 <main+0x194>
cmpl   $0x0,-0x14(%rbp)
je     12a2 <main+0x172>
cmpl   $0x0,-0x18(%rbp)
jne    12b3 <main+0x183>
cmpl   $0x0,-0x1c(%rbp)
je     12b3 <main+0x183>
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
jmp    12bf <main+0x18f>
lea    0xe27(%rip),%rdi
call   1040 <printf@plt>
jmp    12d0 <main+0x1a0>
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
jmp    12d5 <main+0x1a5>
jmp    12da <main+0x1aa>
jmp    12eb <main+0x1bb>
lea    0xe26(%rip),%rdi
call   1040 <printf@plt>
lea    0xe53(%rip),%rdi
call   1030 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
call   1040 <system@plt>
lea    0xeda(%rip),%rdi
call   1040 <system@plt>
lea    0xed7(%rip),%rdi
call   1040 <system@plt>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xef8(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movslq 0x8(%rsp),%rax
cmp    $0x62e,%rax
jl     11d7 <main+0xa7>
mov    0xc(%rsp),%ecx
cmp    $0xc,%ecx
ja     1259 <main+0x129>
mov    $0x15aa,%edx
bt     %ecx,%edx
jae    11e0 <main+0xb0>
lea    0xf57(%rip),%rdi
jmp    11f1 <main+0xc1>
lea    0xec3(%rip),%rdi
jmp    11f1 <main+0xc1>
mov    $0xa50,%edx
bt     %ecx,%edx
jae    120a <main+0xda>
lea    0xf26(%rip),%rdi
call   1030 <puts@plt>
lea    0xe35(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
cmp    $0x2,%ecx
jne    1259 <main+0x129>
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rsi
sar    $0x27,%rsi
mov    %rcx,%rdx
shr    $0x3f,%rdx
add    %edx,%esi
imul   $0x190,%esi,%esi
mov    %eax,%edi
sub    %esi,%edi
je     1262 <main+0x132>
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
mov    %eax,%edx
sub    %ecx,%edx
lea    0xebc(%rip),%rdi
lea    0xea0(%rip),%rcx
cmove  %rcx,%rdi
test   $0x3,%al
cmovne %rcx,%rdi
jmp    11f1 <main+0xc1>
lea    0xe79(%rip),%rdi
jmp    11f1 <main+0xc1>
lea    0xe99(%rip),%rdi
jmp    11f1 <main+0xc1>

LLVM IR (-O0):
@.str = [34 x i8] c"title 19_Cascallar_Autr\C3\A1n_Manuel\00"
@.str.1 = [9 x i8] c"color 0A\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.3 = [36 x i8] c"DIAS QUE TEN UN MES DENTRO DUN ANO\0A\00"
@.str.4 = [37 x i8] c"==================================\0A\0A\00"
@.str.5 = [18 x i8] c"Introduce o mes:\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [18 x i8] c"Introduce o ano:\0A\00"
@.str.8 = [22 x i8] c"Este mes ten 31 d\A1as\0A\00"
@.str.9 = [22 x i8] c"Este mes ten 30 d\A1as\0A\00"
@.str.10 = [22 x i8] c"Este mes ten 29 d\A1as\0A\00"
@.str.11 = [22 x i8] c"Este mes ten 28 d\A1as\0A\00"
@.str.12 = [21 x i8] c"Este mes non existe\0A\00"
@.str.13 = [57 x i8] c"Neste ano todav\A1a non se usaba os calendario gregoriano\0A\00"
@.str.14 = [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 i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @system(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%15 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = srem i32 %17, 400
store i32 %18, i32* %5
%19 = load i32, i32* %3
%20 = srem i32 %19, 4
store i32 %20, i32* %6
%21 = load i32, i32* %3
%22 = srem i32 %21, 100
store i32 %22, i32* %7
%23 = load i32, i32* %3
%24 = icmp sge i32 %23, 1582
br i1 %24, label %25, label %84
25: ; preds = %0
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 1
br i1 %27, label %46, label %28
28: ; preds = %25
%29 = load i32, i32* %2
%30 = icmp eq i32 %29, 3
br i1 %30, label %46, label %31
31: ; preds = %28
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 5
br i1 %33, label %46, label %34
34: ; preds = %31
%35 = load i32, i32* %2
%36 = icmp eq i32 %35, 7
br i1 %36, label %46, label %37
37: ; preds = %34
%38 = load i32, i32* %2
%39 = icmp eq i32 %38, 8
br i1 %39, label %46, label %40
40: ; preds = %37
%41 = load i32, i32* %2
%42 = icmp eq i32 %41, 10
br i1 %42, label %46, label %43
43: ; preds = %40
%44 = load i32, i32* %2
%45 = icmp eq i32 %44, 12
br i1 %45, label %46, label %48
46: ; preds = %43, %40, %37, %34, %31, %28, %25
%47 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
br label %83
48: ; preds = %43
%49 = load i32, i32* %2
%50 = icmp eq i32 %49, 4
br i1 %50, label %60, label %51
51: ; preds = %48
%52 = load i32, i32* %2
%53 = icmp eq i32 %52, 6
br i1 %53, label %60, label %54
54: ; preds = %51
%55 = load i32, i32* %2
%56 = icmp eq i32 %55, 9
br i1 %56, label %60, label %57
57: ; preds = %54
%58 = load i32, i32* %2
%59 = icmp eq i32 %58, 11
br i1 %59, label %60, label %62
60: ; preds = %57, %54, %51, %48
%61 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
br label %82
62: ; preds = %57
%63 = load i32, i32* %2
%64 = icmp eq i32 %63, 2
br i1 %64, label %65, label %79
65: ; preds = %62
%66 = load i32, i32* %5
%67 = icmp eq i32 %66, 0
br i1 %67, label %74, label %68
68: ; preds = %65
%69 = load i32, i32* %6
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %68
%72 = load i32, i32* %7
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %71, %65
%75 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %78
76: ; preds = %71, %68
%77 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
br label %78
78: ; preds = %76, %74
br label %81
79: ; preds = %62
%80 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
br label %81
81: ; preds = %79, %78
br label %82
82: ; preds = %81, %60
br label %83
83: ; preds = %82, %46
br label %86
84: ; preds = %0
%85 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.13, i64 0, i64 0))
br label %86
86: ; preds = %84, %83
%87 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
%88 = load i32, i32* %1
ret i32 %88
}

LLVM IR (-O2):
@.str = [34 x i8] c"title 19_Cascallar_Autr\C3\A1n_Manuel\00"
@.str.1 = [9 x i8] c"color 0A\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.14 = [6 x i8] c"pause\00"
@str = [35 x i8] c"DIAS QUE TEN UN MES DENTRO DUN ANO\00"
@str.15 = [36 x i8] c"==================================\0A\00"
@str.16 = [17 x i8] c"Introduce o mes:\00"
@str.17 = [17 x i8] c"Introduce o ano:\00"
@str.18 = [56 x i8] c"Neste ano todav\A1a non se usaba os calendario gregoriano\00"
@str.19 = [20 x i8] c"Este mes non existe\00"
@str.20 = [21 x i8] c"Este mes ten 28 d\A1as\00"
@str.21 = [21 x i8] c"Este mes ten 29 d\A1as\00"
@str.22 = [21 x i8] c"Este mes ten 30 d\A1as\00"
@str.23 = [21 x i8] c"Este mes ten 31 d\A1as\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @system(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.15, i64 0, i64 0))
%8 = bitcast i32* %1 to i8*
%9 = bitcast i32* %2 to i8*
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.16, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.17, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = srem i32 %14, 400
%16 = srem i32 %14, 100
%17 = icmp sgt i32 %14, 1581
br i1 %17, label %18, label %30
18: ; preds = %0
%19 = load i32, i32* %1
switch i32 %19, label %29 [
i32 12, label %30
i32 10, label %30
i32 8, label %30
i32 7, label %30
i32 5, label %30
i32 3, label %30
i32 1, label %30
i32 11, label %20
i32 9, label %20
i32 6, label %20
i32 4, label %20
i32 2, label %21
]
20: ; preds = %18, %18, %18, %18
br label %30
21: ; preds = %18
%22 = icmp eq i32 %15, 0
br i1 %22, label %30, label %23
23: ; preds = %21
%24 = and i32 %14, 3
%25 = icmp eq i32 %24, 0
%26 = icmp ne i32 %16, 0
%27 = and i1 %25, %26
%28 = select i1 %27, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.21, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.20, i64 0, i64 0)
br label %30
29: ; preds = %18
br label %30
30: ; preds = %23, %0, %21, %18, %18, %18, %18, %18, %18, %18, %29, %20
%31 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.19, i64 0, i64 0), %29 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.22, i64 0, i64 0), %20 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.23, i64 0, i64 0), %18 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.23, i64 0, i64 0), %18 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.23, i64 0, i64 0), %18 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.23, i64 0, i64 0), %18 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.23, i64 0, i64 0), %18 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.23, i64 0, i64 0), %18 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.23, i64 0, i64 0), %18 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.21, i64 0, i64 0), %21 ], [ getelementptr inbounds ([56 x i8], [56 x i8]* @str.18, i64 0, i64 0), %0 ], [ %28, %23 ]
%32 = call i32 @puts(i8* dereferenceable(1) %31)
%33 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
ret i32 0
}