#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
scalar_t__ line_is_blank(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char line[256];
  FILE *f1, *f2;
  int nlines = 0;
  if (argc < 2) {
    fprintf(stderr, "%s: need path to ChangeLog\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  f1 = fopen(argv[1], "r");
  if (f1 == NULL) {
    fprintf(stderr, "%s: couldn't open %s\n", argv[0], argv[1]);
    exit(EXIT_FAILURE);
  }
  f2 = fopen("NEWS", "w");
  if (f2 == NULL) {
    fprintf(stderr, "%s: couldn't open %s\n", argv[0], "NEWS");
    fclose(f1);
    exit(EXIT_FAILURE);
  }
  fputs("For the full log of gretl changes since January 2000, see\n", f2);
  fputs("<@url=\"http://gretl.sourceforge.net/ChangeLog.html\">.\n\n", f2);
  while (fgets(line, sizeof line, f1)) {
    if (line_is_blank(line)) {
      break;
    } else {
      fputs(line, f2);
      nlines++;
    }
  }
  if (nlines < 2) {
    fprintf(stderr, "%s: NEWS file seems to be empty\n", argv[0]);
  }
  fclose(f1);
  fclose(f2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x124(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11c9 <main+0x59>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe44(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x118(%rbp)
jne    1226 <main+0xb6>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
lea    0xe07(%rip),%rdi
lea    0xe05(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x120(%rbp)
cmpq   $0x0,-0x120(%rbp)
jne    128d <main+0x11d>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb9(%rip),%rsi
lea    0xdc8(%rip),%rcx
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x118(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x120(%rbp),%rsi
lea    0xda0(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x120(%rbp),%rsi
lea    0xdc8(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x110(%rbp),%rdi
mov    -0x118(%rbp),%rdx
mov    $0x100,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1317 <main+0x1a7>
lea    -0x110(%rbp),%rdi
call   1030 <line_is_blank@plt>
cmp    $0x0,%rax
je     12f0 <main+0x180>
jmp    1317 <main+0x1a7>
lea    -0x110(%rbp),%rdi
mov    -0x120(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    12b3 <main+0x143>
cmpl   $0x2,-0x124(%rbp)
jge    1342 <main+0x1d2>
mov    0x2cb5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd73(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x118(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x120(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
cmp    $0x1,%edi
jle    12a1 <main+0x121>
mov    0x8(%r14),%rdi
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12bd <main+0x13d>
mov    %rax,%r15
lea    0xe76(%rip),%rdi
lea    0xe74(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12dd <main+0x15d>
mov    %rax,%r12
lea    0xe5e(%rip),%rdi
mov    $0x3a,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10a0 <fwrite@plt>
lea    0xe80(%rip),%rdi
mov    $0x37,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10a0 <fwrite@plt>
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1265 <main+0xe5>
xor    %ebp,%ebp
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <line_is_blank@plt>
test   %rax,%rax
jne    1260 <main+0xe0>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <fputs@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    1230 <main+0xb0>
cmp    $0x1,%ebp
ja     127f <main+0xff>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe36(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd4c(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1306 <main+0x186>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
lea    0xd4a(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1306 <main+0x186>
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd2e(%rip),%rsi
lea    0xd3d(%rip),%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"%s: need path to ChangeLog\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"%s: couldn't open %s\0A\00"
@.str.3 = [5 x i8] c"NEWS\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [59 x i8] c"For the full log of gretl changes since January 2000, see\0A\00"
@.str.6 = [56 x i8] c"<@url=\22http://gretl.sourceforge.net/ChangeLog.html\22>.\0A\0A\00"
@.str.7 = [33 x i8] c"%s: NEWS file seems to be empty\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %7
%25 = load i32*, i32** %7
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %38
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %20
%39 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %39, i32** %8
%40 = load i32*, i32** %8
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %52
42: ; preds = %38
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%48 = load i32*, i32** %7
%49 = call i32 @fclose(i32* %48)
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %38
%53 = load i32*, i32** %8
%54 = call i32 @fputs(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i32* %53)
%55 = load i32*, i32** %8
%56 = call i32 @fputs(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), i32* %55)
br label %57
57: ; preds = %73, %52
%58 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%59 = load i32*, i32** %7
%60 = call i64 @fgets(i8* %58, i32 256, i32* %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %74
62: ; preds = %57
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%64 = call i64 @line_is_blank(i8* %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %62
br label %74
67: ; preds = %62
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%69 = load i32*, i32** %8
%70 = call i32 @fputs(i8* %68, i32* %69)
%71 = load i32, i32* %9
%72 = add nsw i32 %71, 1
store i32 %72, i32* %9
br label %73
73: ; preds = %67
br label %57
74: ; preds = %66, %57
%75 = load i32, i32* %9
%76 = icmp slt i32 %75, 2
br i1 %76, label %77, label %83
77: ; preds = %74
%78 = load i32, i32* @stderr
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 0
%81 = load i8*, i8** %80
%82 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %81)
br label %83
83: ; preds = %77, %74
%84 = load i32*, i32** %7
%85 = call i32 @fclose(i32* %84)
%86 = load i32*, i32** %8
%87 = call i32 @fclose(i32* %86)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"%s: need path to ChangeLog\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"%s: couldn't open %s\0A\00"
@.str.3 = [5 x i8] c"NEWS\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [59 x i8] c"For the full log of gretl changes since January 2000, see\0A\00"
@.str.6 = [56 x i8] c"<@url=\22http://gretl.sourceforge.net/ChangeLog.html\22>.\0A\0A\00"
@.str.7 = [33 x i8] c"%s: NEWS file seems to be empty\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %1
%20 = load i8*, i8** %13
%21 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %19, i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %12
%25 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %1
%30 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%31 = tail call i32 @fclose(i32* %15)
%32 = load i32, i32* @EXIT_FAILURE
%33 = tail call i32 @exit(i32 %32)
unreachable
34: ; preds = %24
%35 = tail call i64 @fwrite(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i64 58, i64 1, i32* %25)
%36 = tail call i64 @fwrite(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), i64 55, i64 1, i32* %25)
%37 = call i64 @fgets(i8* %4, i32 256, i32* %15)
%38 = icmp eq i64 %37, 0
br i1 %38, label %51, label %39
39: ; preds = %34, %43
%40 = phi i32 [ %45, %43 ], [ 0, %34 ]
%41 = call i64 @line_is_blank(i8* %4)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = call i32 @fputs(i8* %4, i32* %25)
%45 = add nuw nsw i32 %40, 1
%46 = call i64 @fgets(i8* %4, i32 256, i32* %15)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %39
48: ; preds = %43, %39
%49 = phi i32 [ %45, %43 ], [ %40, %39 ]
%50 = icmp ult i32 %49, 2
br i1 %50, label %51, label %55
51: ; preds = %34, %48
%52 = load i32, i32* @stderr
%53 = load i8*, i8** %1
%54 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %53)
br label %55
55: ; preds = %51, %48
%56 = call i32 @fclose(i32* %15)
%57 = call i32 @fclose(i32* %25)
ret i32 0
}