#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*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
char *make_path(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/);
int /*<<< orphan*/ safe_free(char *);
int /*<<< orphan*/ stdout;
int print_news() {
  char *news_file;
  FILE *fp;
  int c;
  news_file = make_path(
      "/home/diagnostix3/ida/tompa/pmf-1.13.1/pmfdir/system_dir", "NEWS");
  fp = fopen(news_file, "r");
  safe_free(news_file);
  if (fp == 0) {
    return -1;
  } else {
    printf("Local news about PMF:\n");
    while ((c = getc(fp)) != EOF)
      putc(c, stdout);
    printf("\n");
    return 0;
  }
}


x86 assembly (clang, -O0):
<print_news>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
lea    0xec3(%rip),%rsi
call   1050 <make_path@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <safe_free@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11b3 <print_news+0x53>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <print_news+0xa3>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1080 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e16(%rip),%rcx
cmp    (%rcx),%eax
je     11f0 <print_news+0x90>
mov    -0x1c(%rbp),%edi
mov    0x2df4(%rip),%rax
mov    (%rax),%esi
call   1040 <putc@plt>
jmp    11bf <print_news+0x5f>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_news>:
push   %r15
push   %r14
push   %rbx
lea    0xe84(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1060 <make_path@plt>
mov    %rax,%r14
lea    0xea5(%rip),%rsi
mov    %rax,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1070 <safe_free@plt>
test   %rbx,%rbx
je     1205 <print_news+0x95>
lea    0xe8d(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1090 <getc@plt>
mov    0x2e23(%rip),%r14
cmp    (%r14),%eax
je     11f7 <print_news+0x87>
mov    0x2e07(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15),%esi
mov    %eax,%edi
call   1050 <putc@plt>
mov    %rbx,%rdi
call   1090 <getc@plt>
cmp    (%r14),%eax
jne    11e0 <print_news+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
jmp    120a <print_news+0x9a>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [57 x i8] c"/home/diagnostix3/ida/tompa/pmf-1.13.1/pmfdir/system_dir\00"
@.str.1 = [5 x i8] c"NEWS\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [23 x i8] c"Local news about PMF:\0A\00"
@EOF = global i32 0
@stdout = global i32 0
@.str.4 = [2 x i8] c"\0A\00"
define i32 @print_news() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = call i8* @make_path(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %7, i32** %3
%8 = load i8*, i8** %2
%9 = call i32 @safe_free(i8* %8)
%10 = load i32*, i32** %3
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 -1, i32* %1
br label %26
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %20, %13
%16 = load i32*, i32** %3
%17 = call i32 @getc(i32* %16)
store i32 %17, i32* %4
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32, i32* %4
%22 = load i32, i32* @stdout
%23 = call i32 @putc(i32 %21, i32 %22)
br label %15
24: ; preds = %15
%25 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %26
26: ; preds = %24, %12
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [57 x i8] c"/home/diagnostix3/ida/tompa/pmf-1.13.1/pmfdir/system_dir\00"
@.str.1 = [5 x i8] c"NEWS\00"
@.str.2 = [2 x i8] c"r\00"
@EOF = global i32 0
@stdout = global i32 0
@str = [22 x i8] c"Local news about PMF:\00"
define i32 @print_news() {
%1 = tail call i8* @make_path(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32 @safe_free(i8* %1)
%4 = icmp eq i32* %2, null
br i1 %4, label %19, label %5
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @getc(i32* %2)
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %17, label %10
10: ; preds = %5, %10
%11 = phi i32 [ %14, %10 ], [ %7, %5 ]
%12 = load i32, i32* @stdout
%13 = tail call i32 @putc(i32 %11, i32 %12)
%14 = tail call i32 @getc(i32* %2)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %10
17: ; preds = %10, %5
%18 = tail call i32 @putchar(i32 10)
br label %19
19: ; preds = %0, %17
%20 = phi i32 [ 0, %17 ], [ -1, %0 ]
ret i32 %20
}