#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 */
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_lunation(int lunation, struct tm *event_date) {
  int i;
  printf("%+5.5d  ", lunation);
  for (i = 0; i <= 3; i++) {
    printf("%4.4d/%2.2d/%2.2d %2.2d:%2.2d  ", event_date[i].tm_year + 1900,
           event_date[i].tm_mon + 1, event_date[i].tm_mday,
           event_date[i].tm_hour, event_date[i].tm_min);
  }
  if (lunation % 12 == 4)
    printf("*");
  if (lunation % 12 == -8)
    printf("*");
  printf("\n");
}


x86 assembly (clang, -O0):
<print_lunation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%esi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jg     11c1 <print_lunation+0xb1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%esi
add    $0x76c,%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
mov    0x4(%rax),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%ecx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rdi
imul   $0x14,%rdi,%rdi
add    %rdi,%rax
mov    0xc(%rax),%r8d
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rdi
imul   $0x14,%rdi,%rdi
add    %rdi,%rax
mov    0x10(%rax),%r9d
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <print_lunation+0x27>
mov    -0x4(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
cmp    $0x4,%edx
jne    11e3 <print_lunation+0xd3>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
cmp    $0xfffffff8,%edx
jne    1205 <print_lunation+0xf5>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_lunation>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0xecc(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x76c,%ebp
mov    (%rbx),%esi
add    %ebp,%esi
mov    0x4(%rbx),%edx
mov    0x8(%rbx),%ecx
add    $0x1,%edx
mov    0xc(%rbx),%r8d
mov    0x10(%rbx),%r9d
lea    0xeaa(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rbx),%esi
add    %ebp,%esi
mov    0x18(%rbx),%edx
mov    0x1c(%rbx),%ecx
add    $0x1,%edx
mov    0x20(%rbx),%r8d
mov    0x24(%rbx),%r9d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rbx),%esi
add    %ebp,%esi
mov    0x2c(%rbx),%edx
mov    0x30(%rbx),%ecx
add    $0x1,%edx
mov    0x34(%rbx),%r8d
mov    0x38(%rbx),%r9d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    0x3c(%rbx),%ebp
mov    0x40(%rbx),%edx
mov    0x44(%rbx),%ecx
add    $0x1,%edx
mov    0x48(%rbx),%r8d
mov    0x4c(%rbx),%r9d
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movslq %r14d,%rax
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    $0x4,%eax
je     11f2 <print_lunation+0xd2>
cmp    $0xfffffff8,%eax
jne    11fc <print_lunation+0xdc>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32 }
@.str = [9 x i8] c"%+5.5d \00"
@.str.1 = [32 x i8] c"%4.4d/%2.2d/%2.2d %2.2d:%2.2d \00"
@.str.2 = [2 x i8] c"*\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @print_lunation(i32 %0, %struct.tm* %1) {
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca i32
store i32 %0, i32* %3
store %struct.tm* %1, %struct.tm** %4
%6 = load i32, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 0, i32* %5
br label %8
8: ; preds = %45, %2
%9 = load i32, i32* %5
%10 = icmp sle i32 %9, 3
br i1 %10, label %11, label %48
11: ; preds = %8
%12 = load %struct.tm*, %struct.tm** %4
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds %struct.tm, %struct.tm* %12, i64 %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1900
%19 = load %struct.tm*, %struct.tm** %4
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds %struct.tm, %struct.tm* %19, i64 %21
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 1
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
%26 = load %struct.tm*, %struct.tm** %4
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds %struct.tm, %struct.tm* %26, i64 %28
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 2
%31 = load i32, i32* %30
%32 = load %struct.tm*, %struct.tm** %4
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds %struct.tm, %struct.tm* %32, i64 %34
%36 = getelementptr inbounds %struct.tm, %struct.tm* %35, i32 0, i32 3
%37 = load i32, i32* %36
%38 = load %struct.tm*, %struct.tm** %4
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds %struct.tm, %struct.tm* %38, i64 %40
%42 = getelementptr inbounds %struct.tm, %struct.tm* %41, i32 0, i32 4
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %25, i32 %31, i32 %37, i32 %43)
br label %45
45: ; preds = %11
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %8
48: ; preds = %8
%49 = load i32, i32* %3
%50 = srem i32 %49, 12
%51 = icmp eq i32 %50, 4
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %54
54: ; preds = %52, %48
%55 = load i32, i32* %3
%56 = srem i32 %55, 12
%57 = icmp eq i32 %56, -8
br i1 %57, label %58, label %60
58: ; preds = %54
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %60
60: ; preds = %58, %54
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32 }
@.str = [9 x i8] c"%+5.5d \00"
@.str.1 = [32 x i8] c"%4.4d/%2.2d/%2.2d %2.2d:%2.2d \00"
define void @print_lunation(i32 %0, %struct.tm* nocapture %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = add nsw i32 %5, 1900
%7 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 1
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 1
%10 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 2
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 3
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 4
%15 = load i32, i32* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %9, i32 %11, i32 %13, i32 %15)
%17 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 1, i32 0
%18 = load i32, i32* %17
%19 = add nsw i32 %18, 1900
%20 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 1, i32 1
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
%23 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 1, i32 2
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 1, i32 3
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 1, i32 4
%28 = load i32, i32* %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %22, i32 %24, i32 %26, i32 %28)
%30 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 2, i32 0
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1900
%33 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 2, i32 1
%34 = load i32, i32* %33
%35 = add nsw i32 %34, 1
%36 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 2, i32 2
%37 = load i32, i32* %36
%38 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 2, i32 3
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 2, i32 4
%41 = load i32, i32* %40
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %35, i32 %37, i32 %39, i32 %41)
%43 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 3, i32 0
%44 = load i32, i32* %43
%45 = add nsw i32 %44, 1900
%46 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 3, i32 1
%47 = load i32, i32* %46
%48 = add nsw i32 %47, 1
%49 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 3, i32 2
%50 = load i32, i32* %49
%51 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 3, i32 3
%52 = load i32, i32* %51
%53 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 3, i32 4
%54 = load i32, i32* %53
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %45, i32 %48, i32 %50, i32 %52, i32 %54)
%56 = srem i32 %0, 12
switch i32 %56, label %59 [
i32 4, label %57
i32 -8, label %57
]
57: ; preds = %2, %2
%58 = tail call i32 @putchar(i32 42)
br label %59
59: ; preds = %57, %2
%60 = tail call i32 @putchar(i32 10)
ret void
}