#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;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, char *);
size_t strftime(char *, int, char *, struct tm *);
void printheader(struct tm *time, bool printyear) {
  char buffer[22], spaces[10];
  size_t i, output;
  if (printyear) {
    time->tm_year -= 1900;
    output = strftime(buffer, 80, "%B %Y", time);
    time->tm_year += 1900;
  } else
    output = strftime(buffer, 80, "%B", time);
  for (i = 0; i < (21 - output) / 2; i++)
    spaces[i] = ' ';
  spaces[i] = 0;
  printf("%s%s\n", spaces, buffer);
}


x86 assembly (clang, -O0):
<printheader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1177 <printheader+0x57>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
sub    $0x76c,%ecx
mov    %ecx,(%rax)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x50,%esi
lea    0xea5(%rip),%rdx
call   1040 <strftime@plt>
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x76c,%ecx
mov    %ecx,(%rax)
jmp    1194 <printheader+0x74>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x50,%esi
lea    0xe7b(%rip),%rdx
call   1040 <strftime@plt>
mov    %rax,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    $0x15,%ecx
sub    -0x50(%rbp),%rcx
shr    $0x1,%rcx
cmp    %rcx,%rax
jae    11d0 <printheader+0xb0>
mov    -0x48(%rbp),%rax
movb   $0x20,-0x3a(%rbp,%rax,1)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    119c <printheader+0x7c>
mov    -0x48(%rbp),%rax
movb   $0x0,-0x3a(%rbp,%rax,1)
lea    -0x3a(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printheader>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
test   %esi,%esi
je     1163 <printheader+0x33>
addl   $0xfffff894,(%rbx)
lea    0xeb7(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x50,%esi
mov    %rbx,%rcx
call   1050 <strftime@plt>
addl   $0x76c,(%rbx)
jmp    117c <printheader+0x4c>
lea    0xe9c(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x50,%esi
mov    %rbx,%rcx
call   1050 <strftime@plt>
mov    $0x15,%ebx
sub    %rax,%rbx
cmp    $0x2,%rbx
jae    118e <printheader+0x5e>
xor    %ebx,%ebx
jmp    11a3 <printheader+0x73>
shr    %rbx
lea    0x6(%rsp),%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
call   1040 <memset@plt>
movb   $0x0,0x6(%rsp,%rbx,1)
lea    0xe5a(%rip),%rdi
lea    0x6(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [6 x i8] c"%B %Y\00"
@.str.1 = [3 x i8] c"%B\00"
@.str.2 = [6 x i8] c"%s%s\0A\00"
define void @printheader(%struct.tm* %0, i32 %1) {
%3 = alloca %struct.tm*
%4 = alloca i32
%5 = alloca [22 x i8]
%6 = alloca [10 x i8]
%7 = alloca i64
%8 = alloca i64
store %struct.tm* %0, %struct.tm** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %2
%12 = load %struct.tm*, %struct.tm** %3
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = sub nsw i32 %14, 1900
store i32 %15, i32* %13
%16 = getelementptr inbounds [22 x i8], [22 x i8]* %5, i64 0, i64 0
%17 = load %struct.tm*, %struct.tm** %3
%18 = call i64 @strftime(i8* %16, i32 80, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %17)
store i64 %18, i64* %8
%19 = load %struct.tm*, %struct.tm** %3
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1900
store i32 %22, i32* %20
br label %27
23: ; preds = %2
%24 = getelementptr inbounds [22 x i8], [22 x i8]* %5, i64 0, i64 0
%25 = load %struct.tm*, %struct.tm** %3
%26 = call i64 @strftime(i8* %24, i32 80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %25)
store i64 %26, i64* %8
br label %27
27: ; preds = %23, %11
store i64 0, i64* %7
br label %28
28: ; preds = %37, %27
%29 = load i64, i64* %7
%30 = load i64, i64* %8
%31 = sub i64 21, %30
%32 = udiv i64 %31, 2
%33 = icmp ult i64 %29, %32
br i1 %33, label %34, label %40
34: ; preds = %28
%35 = load i64, i64* %7
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %35
store i8 32, i8* %36
br label %37
37: ; preds = %34
%38 = load i64, i64* %7
%39 = add i64 %38, 1
store i64 %39, i64* %7
br label %28
40: ; preds = %28
%41 = load i64, i64* %7
%42 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %41
store i8 0, i8* %42
%43 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%44 = getelementptr inbounds [22 x i8], [22 x i8]* %5, i64 0, i64 0
%45 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %43, i8* %44)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [6 x i8] c"%B %Y\00"
@.str.1 = [3 x i8] c"%B\00"
@.str.2 = [6 x i8] c"%s%s\0A\00"
define void @printheader(%struct.tm* %0, i32 %1) {
%3 = alloca [22 x i8]
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%8 = icmp eq i32 %1, 0
br i1 %8, label %16, label %9
9: ; preds = %2
%10 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 0
%11 = load i32, i32* %10
%12 = add nsw i32 %11, -1900
store i32 %12, i32* %10
%13 = call i64 @strftime(i8* %6, i32 80, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %0)
%14 = load i32, i32* %10
%15 = add nsw i32 %14, 1900
store i32 %15, i32* %10
br label %18
16: ; preds = %2
%17 = call i64 @strftime(i8* %6, i32 80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %0)
br label %18
18: ; preds = %16, %9
%19 = phi i64 [ %13, %9 ], [ %17, %16 ]
%20 = sub i64 21, %19
%21 = icmp ult i64 %20, 2
br i1 %21, label %24, label %22
22: ; preds = %18
%23 = lshr i64 %20, 1
br label %24
24: ; preds = %22, %18
%25 = phi i64 [ 0, %18 ], [ %23, %22 ]
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %25
store i8 0, i8* %26
%27 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* %6)
ret void
}