#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
char *pretty_name(char *);
int /*<<< orphan*/ stdout;
void write_header(char *filename) {
  static unsigned short first_file = 1;
  static char *last = NULL;
  if (last != filename) {
    fprintf(stdout, "%s==> %s <==\n", (first_file ? "" : "\n"),
            pretty_name(filename));
    fflush(stdout);
  }
  first_file = 0;
  last = filename;
}


x86 assembly (clang, -O0):
<write_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2f05(%rip),%rax
cmp    -0x8(%rbp),%rax
je     11a6 <write_header+0x76>
mov    0x2e8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movzwl 0x2ed8(%rip),%edx
lea    0xea5(%rip),%rax
lea    0xe9f(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <pretty_name@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    %rax,%rcx
lea    0xe6d(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
movw   $0x0,0x2e89(%rip)
mov    -0x8(%rbp),%rax
mov    %rax,0x2e8e(%rip)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_header>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmp    %rdi,0x2f07(%rip)
je     118b <write_header+0x5b>
mov    0x2e96(%rip),%r15
mov    (%r15),%r14d
lea    0xeb8(%rip),%rax
lea    0xeb2(%rip),%rbp
cmpb   $0x0,0x2ede(%rip)
cmovne %rax,%rbp
mov    %rbx,%rdi
call   1030 <pretty_name@plt>
lea    0xe8b(%rip),%rsi
mov    %r14d,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
call   1040 <fprintf@plt>
mov    (%r15),%edi
call   1050 <fflush@plt>
movb   $0x1,0x2eae(%rip)
mov    %rbx,0x2eaf(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@write_header.first_file = internal global i16 1
@write_header.last = internal global i8* null
@stdout = global i32 0
@.str = [14 x i8] c"%s==> %s <==\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"\0A\00"
define void @write_header(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** @write_header.last
%4 = load i8*, i8** %2
%5 = icmp ne i8* %3, %4
br i1 %5, label %6, label %18
6: ; preds = %1
%7 = load i32, i32* @stdout
%8 = load i16, i16* @write_header.first_file
%9 = zext i16 %8 to i32
%10 = icmp ne i32 %9, 0
%11 = zext i1 %10 to i64
%12 = select i1 %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%13 = load i8*, i8** %2
%14 = call i8* @pretty_name(i8* %13)
%15 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %14)
%16 = load i32, i32* @stdout
%17 = call i32 @fflush(i32 %16)
br label %18
18: ; preds = %6, %1
store i16 0, i16* @write_header.first_file
%19 = load i8*, i8** %2
store i8* %19, i8** @write_header.last
ret void
}

LLVM IR (-O2):
@write_header.first_file = internal unnamed_addr global i1 false
@write_header.last = internal unnamed_addr global i8* null
@stdout = global i32 0
@.str = [14 x i8] c"%s==> %s <==\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"\0A\00"
define void @write_header(i8* %0) {
%2 = load i8*, i8** @write_header.last
%3 = icmp eq i8* %2, %0
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = load i32, i32* @stdout
%6 = load i1, i1* @write_header.first_file
%7 = select i1 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
%8 = tail call i8* @pretty_name(i8* %0)
%9 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
%10 = load i32, i32* @stdout
%11 = tail call i32 @fflush(i32 %10)
br label %12
12: ; preds = %4, %1
store i1 true, i1* @write_header.first_file
store i8* %0, i8** @write_header.last
ret void
}