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

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int print_header(FILE *in_file, FILE *out_file, char *file_name) {
  long size;
  time_t t = time(NULL);
  struct tm tm = *localtime(&t);
  if (fseek(in_file, 0L, SEEK_END) < 0) {
    fprintf(stderr, "Error seeking to end of input file\n");
    return -1;
  }
  if ((size = ftell(in_file)) < 0) {
    fprintf(stderr, "Error getting size of file\n");
    return -1;
  }
  rewind(in_file);
  fprintf(out_file, "# File %s generated on %d-%d-%d %d:%d:%d\n", file_name,
          tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min,
          tm.tm_sec);
  fprintf(out_file, "# Number of taps: %lu\n", size / sizeof(float));
  fprintf(out_file, "#\n#\n");
  return 0;
}


x86 assembly (clang, -O0):
<print_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x2c(%rbp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%rcx
mov    %rcx,-0x48(%rbp)
mov    0x8(%rax),%rcx
mov    %rcx,-0x40(%rbp)
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e3d(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1080 <fseek@plt>
cmp    $0x0,%rax
jge    11e4 <print_header+0x84>
mov    0x2e11(%rip),%rax
mov    (%rax),%rdi
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    129e <print_header+0x13e>
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jge    121f <print_header+0xbf>
mov    0x2dd6(%rip),%rax
mov    (%rax),%rdi
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    129e <print_header+0x13e>
mov    -0x10(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x48(%rbp),%ecx
add    $0x76c,%ecx
mov    -0x44(%rbp),%r8d
add    $0x1,%r8d
mov    -0x40(%rbp),%r9d
mov    -0x3c(%rbp),%r11d
mov    -0x38(%rbp),%r10d
mov    -0x34(%rbp),%eax
lea    0xde9(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
shr    $0x2,%rdx
lea    0xdec(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_header>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%r13d
mov    0x4(%rax),%r12d
mov    0x8(%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    0xc(%rax),%ebx
mov    0x10(%rax),%ecx
mov    %rcx,0x20(%rsp)
mov    0x14(%rax),%eax
mov    %rax,0x18(%rsp)
mov    0x2e24(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
test   %rax,%rax
js     1273 <print_header+0x103>
mov    %rbx,0x10(%rsp)
mov    %r15,%rbx
mov    %r14,%r15
mov    %rbp,%rdi
call   1060 <ftell@plt>
test   %rax,%rax
js     128b <print_header+0x11b>
mov    %rax,%r14
mov    %rbp,%rdi
call   1040 <rewind@plt>
add    $0x76c,%r13d
add    $0x1,%r12d
sub    $0x8,%rsp
lea    0xe2a(%rip),%rsi
xor    %ebp,%ebp
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r13d,%ecx
mov    %r12d,%r8d
mov    0x10(%rsp),%r9d
xor    %eax,%eax
push   0x20(%rsp)
push   0x30(%rsp)
push   0x28(%rsp)
call   1050 <fprintf@plt>
add    $0x20,%rsp
shr    $0x2,%r14
lea    0xe1f(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe22(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1090 <fwrite@plt>
jmp    12b0 <print_header+0x140>
mov    0x2d5e(%rip),%rax
mov    (%rax),%rcx
lea    0xd7c(%rip),%rdi
mov    $0x23,%esi
jmp    12a1 <print_header+0x131>
mov    0x2d46(%rip),%rax
mov    (%rax),%rcx
lea    0xd88(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
call   1090 <fwrite@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@SEEK_END = global i32 0
@stderr = global i32* null
@.str = [36 x i8] c"Error seeking to end of input file\0A\00"
@.str.1 = [28 x i8] c"Error getting size of file\0A\00"
@.str.2 = [42 x i8] c"# File %s generated on %d-%d-%d %d:%d:%d\0A\00"
@.str.3 = [23 x i8] c"# Number of taps: %lu\0A\00"
@.str.4 = [5 x i8] c"#\0A#\0A\00"
define i32 @print_header(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca %struct.tm
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
%11 = call i32 @time(i32* null)
store i32 %11, i32* %9
%12 = call %struct.tm* @localtime(i32* %9)
%13 = bitcast %struct.tm* %10 to i8*
%14 = bitcast %struct.tm* %12 to i8*
%15 = load i32*, i32** %5
%16 = load i32, i32* @SEEK_END
%17 = call i64 @fseek(i32* %15, i64 0, i32 %16)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %3
%20 = load i32*, i32** @stderr
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %55
22: ; preds = %3
%23 = load i32*, i32** %5
%24 = call i64 @ftell(i32* %23)
store i64 %24, i64* %8
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32*, i32** @stderr
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %55
29: ; preds = %22
%30 = load i32*, i32** %5
%31 = call i32 @rewind(i32* %30)
%32 = load i32*, i32** %6
%33 = load i8*, i8** %7
%34 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%35 = load i32, i32* %34
%36 = add nsw i32 %35, 1900
%37 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 1
%38 = load i32, i32* %37
%39 = add nsw i32 %38, 1
%40 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 2
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 3
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 4
%45 = load i32, i32* %44
%46 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 5
%47 = load i32, i32* %46
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %33, i32 %36, i32 %39, i32 %41, i32 %43, i32 %45, i32 %47)
%49 = load i32*, i32** %6
%50 = load i64, i64* %8
%51 = udiv i64 %50, 4
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i64 %51)
%53 = load i32*, i32** %6
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %55
55: ; preds = %29, %26, %19
%56 = load i32, i32* %4
ret i32 %56
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@SEEK_END = global i32 0
@stderr = global i32* null
@.str = [36 x i8] c"Error seeking to end of input file\0A\00"
@.str.1 = [28 x i8] c"Error getting size of file\0A\00"
@.str.2 = [42 x i8] c"# File %s generated on %d-%d-%d %d:%d:%d\0A\00"
@.str.3 = [23 x i8] c"# Number of taps: %lu\0A\00"
@.str.4 = [5 x i8] c"#\0A#\0A\00"
define i32 @print_header(i32* nocapture %0, i32* nocapture %1, i8* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = tail call i32 @time(i32* null)
store i32 %6, i32* %4
%7 = call %struct.tm* @localtime(i32* %4)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 3
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 4
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 5
%19 = load i32, i32* %18
%20 = load i32, i32* @SEEK_END
%21 = call i64 @fseek(i32* %0, i64 0, i32 %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %3
%24 = load i32*, i32** @stderr
%25 = call i64 @fwrite(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i64 35, i64 1, i32* %24)
br label %40
26: ; preds = %3
%27 = call i64 @ftell(i32* %0)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32*, i32** @stderr
%31 = call i64 @fwrite(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i64 27, i64 1, i32* %30)
br label %40
32: ; preds = %26
%33 = call i32 @rewind(i32* %0)
%34 = add nsw i32 %9, 1900
%35 = add nsw i32 %11, 1
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %2, i32 %34, i32 %35, i32 %13, i32 %15, i32 %17, i32 %19)
%37 = lshr i64 %27, 2
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i64 %37)
%39 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 4, i64 1, i32* %1)
br label %40
40: ; preds = %32, %29, %23
%41 = phi i32 [ -1, %23 ], [ -1, %29 ], [ 0, %32 ]
ret i32 %41
}