#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, int, int);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int dias_digitados;
  int dias = 0;
  int meses = 0;
  int anos = 0;
  int acumulador;
  scanf("%d", &dias_digitados);
  while (dias_digitados >= 365) {
    acumulador = dias_digitados - 365;
    dias_digitados = acumulador;
    anos += 1;
  }
  while (dias_digitados >= 30) {
    acumulador = dias_digitados - 30;
    dias_digitados = acumulador;
    meses += 1;
  }
  while (dias_digitados >= 1) {
    acumulador = dias_digitados - 1;
    dias_digitados = acumulador;
    dias += 1;
  }
  printf("%d ano(s)\n%d mes(es)\n%d dia(s)\n", anos, meses, dias);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x16d,-0x8(%rbp)
jl     1180 <main+0x60>
mov    -0x8(%rbp),%eax
sub    $0x16d,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <main+0x34>
jmp    1185 <main+0x65>
cmpl   $0x1e,-0x8(%rbp)
jl     11ac <main+0x8c>
mov    -0x8(%rbp),%eax
sub    $0x1e,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1185 <main+0x65>
jmp    11b1 <main+0x91>
cmpl   $0x1,-0x8(%rbp)
jl     11d8 <main+0xb8>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b1 <main+0x91>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ecx
xor    %edx,%edx
cmp    $0x16d,%ecx
jl     1189 <main+0x69>
cmp    $0x2d9,%ecx
mov    $0x2d9,%eax
cmovl  %ecx,%eax
neg    %eax
lea    (%rcx,%rax,1),%esi
add    $0x16c,%esi
imul   $0x6719f361,%rsi,%rax
shr    $0x20,%rax
sub    %eax,%esi
shr    %esi
add    %eax,%esi
shr    $0x8,%esi
imul   $0xfffffe93,%esi,%eax
add    %eax,%ecx
add    $0xfffffe93,%ecx
add    $0x1,%esi
mov    %ecx,0x4(%rsp)
cmp    $0x1e,%ecx
jge    1190 <main+0x70>
jmp    11be <main+0x9e>
xor    %esi,%esi
cmp    $0x1e,%ecx
jl     11be <main+0x9e>
cmp    $0x3b,%ecx
mov    $0x3b,%eax
cmovl  %ecx,%eax
neg    %eax
add    %ecx,%eax
add    $0x1d,%eax
mov    $0x88888889,%edx
imul   %rax,%rdx
shr    $0x24,%rdx
imul   $0xffffffe2,%edx,%eax
add    %eax,%ecx
add    $0xffffffe2,%ecx
add    $0x1,%edx
mov    %ecx,0x4(%rsp)
test   %ecx,%ecx
jle    11cc <main+0xac>
movl   $0x0,0x4(%rsp)
jmp    11ce <main+0xae>
xor    %ecx,%ecx
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [32 x i8] c"%d ano(s)\0A%d mes(es)\0A%d dia(s)\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* %3
store i32 0, i32* %4
store i32 0, i32* %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %11, %0
%9 = load i32, i32* %2
%10 = icmp sge i32 %9, 365
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load i32, i32* %2
%13 = sub nsw i32 %12, 365
store i32 %13, i32* %6
%14 = load i32, i32* %6
store i32 %14, i32* %2
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
store i32 %16, i32* %5
br label %8
17: ; preds = %8
br label %18
18: ; preds = %21, %17
%19 = load i32, i32* %2
%20 = icmp sge i32 %19, 30
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = load i32, i32* %2
%23 = sub nsw i32 %22, 30
store i32 %23, i32* %6
%24 = load i32, i32* %6
store i32 %24, i32* %2
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %18
27: ; preds = %18
br label %28
28: ; preds = %31, %27
%29 = load i32, i32* %2
%30 = icmp sge i32 %29, 1
br i1 %30, label %31, label %37
31: ; preds = %28
%32 = load i32, i32* %2
%33 = sub nsw i32 %32, 1
store i32 %33, i32* %6
%34 = load i32, i32* %6
store i32 %34, i32* %2
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %28
37: ; preds = %28
%38 = load i32, i32* %5
%39 = load i32, i32* %4
%40 = load i32, i32* %3
%41 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %38, i32 %39, i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [32 x i8] c"%d ano(s)\0A%d mes(es)\0A%d dia(s)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp sgt i32 %4, 364
br i1 %5, label %6, label %15
6: ; preds = %0
%7 = add nsw i32 %4, -365
%8 = add nuw i32 %4, 364
%9 = call i32 @llvm.smin.i32(i32 %4, i32 729)
%10 = sub nuw i32 %8, %9
%11 = udiv i32 %10, 365
%12 = mul nsw i32 %11, -365
%13 = add nsw i32 %12, %7
%14 = add nuw nsw i32 %11, 1
store i32 %13, i32* %1
br label %15
15: ; preds = %6, %0
%16 = phi i32 [ %13, %6 ], [ %4, %0 ]
%17 = phi i32 [ %14, %6 ], [ 0, %0 ]
%18 = icmp sgt i32 %16, 29
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = add nsw i32 %16, -30
%21 = add nuw nsw i32 %16, 29
%22 = call i32 @llvm.smin.i32(i32 %16, i32 59)
%23 = sub nuw nsw i32 %21, %22
%24 = udiv i32 %23, 30
%25 = mul nsw i32 %24, -30
%26 = add nsw i32 %25, %20
%27 = add nuw nsw i32 %24, 1
store i32 %26, i32* %1
br label %28
28: ; preds = %19, %15
%29 = phi i32 [ %26, %19 ], [ %16, %15 ]
%30 = phi i32 [ %27, %19 ], [ 0, %15 ]
%31 = icmp sgt i32 %29, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 0, i32* %1
br label %33
33: ; preds = %32, %28
%34 = phi i32 [ %29, %32 ], [ 0, %28 ]
%35 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %30, i32 %34)
ret i32 0
}