#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*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int sscanf(char *, char *, int *);
int get_current_version(void) {
  static int auriga_version = 0;
  if (auriga_version == 0) {
    FILE *fp;
    char filename[256];
    if (1129 < 100)
      sprintf(filename, "Readme%03d", 1129);
    else
      sprintf(filename, "Readme%04d", 1129);
    fp = fopen(filename, "r");
    if (fp) {
      char line[1024];
      int ver;
      while (fgets(line, sizeof(line), fp)) {
        if (sscanf(line, "//%d [%*d/%*d/%*d] by", &ver) == 1) {
          auriga_version = ver;
          break;
        }
      }
      fclose(fp);
    }
    if (auriga_version == 0)
      auriga_version = 1129;
  }
  return auriga_version;
}


x86 assembly (clang, -O0):
<get_current_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x520,%rsp
cmpl   $0x0,0x2eea(%rip)
jne    1224 <get_current_version+0xd4>
lea    -0x110(%rbp),%rdi
lea    0xe8a(%rip),%rsi
mov    $0x469,%edx
call   1070 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1208 <get_current_version+0xb8>
jmp    11a7 <get_current_version+0x57>
lea    -0x510(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11ff <get_current_version+0xaf>
lea    -0x510(%rbp),%rdi
lea    0xe39(%rip),%rsi
lea    -0x514(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    11fa <get_current_version+0xaa>
mov    -0x514(%rbp),%eax
mov    %eax,0x2e57(%rip)
jmp    11ff <get_current_version+0xaf>
jmp    11a7 <get_current_version+0x57>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
cmpl   $0x0,0x2e3d(%rip)
jne    121f <get_current_version+0xcf>
movl   $0x469,0x2e2d(%rip)
jmp    1224 <get_current_version+0xd4>
mov    0x2e22(%rip),%eax
add    $0x520,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_current_version>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x518,%rsp
mov    0x2ee8(%rip),%eax
test   %eax,%eax
jne    1203 <get_current_version+0xb3>
lea    0xe8d(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x469,%edx
call   1070 <sprintf@plt>
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11ea <get_current_version+0x9a>
mov    %rax,%rbx
lea    0x110(%rsp),%r14
lea    0xe62(%rip),%r15
lea    0xc(%rsp),%r12
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11e2 <get_current_version+0x92>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    11b0 <get_current_version+0x60>
mov    0xc(%rsp),%eax
mov    %eax,0x2e6a(%rip)
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2e5c(%rip),%eax
test   %eax,%eax
jne    1203 <get_current_version+0xb3>
movl   $0x469,0x2e4e(%rip)
mov    $0x469,%eax
add    $0x518,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@get_current_version.auriga_version = internal global i32 0
@.str = [11 x i8] c"Readme%04d\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"//%d [%*d/%*d/%*d] by\00"
define i32 @get_current_version() {
%1 = alloca i32*
%2 = alloca [256 x i8]
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = load i32, i32* @get_current_version.auriga_version
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %35
7: ; preds = %0
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%9 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1129)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %1
%12 = load i32*, i32** %1
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %30
14: ; preds = %7
br label %15
15: ; preds = %26, %14
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%17 = load i32*, i32** %1
%18 = call i64 @fgets(i8* %16, i32 1024, i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %15
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load i32, i32* %4
store i32 %25, i32* @get_current_version.auriga_version
br label %27
26: ; preds = %20
br label %15
27: ; preds = %24, %15
%28 = load i32*, i32** %1
%29 = call i32 @fclose(i32* %28)
br label %30
30: ; preds = %27, %7
%31 = load i32, i32* @get_current_version.auriga_version
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %30
store i32 1129, i32* @get_current_version.auriga_version
br label %34
34: ; preds = %33, %30
br label %35
35: ; preds = %34, %0
%36 = load i32, i32* @get_current_version.auriga_version
ret i32 %36
}

LLVM IR (-O2):
@get_current_version.auriga_version = internal unnamed_addr global i32 0
@.str = [11 x i8] c"Readme%04d\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"//%d [%*d/%*d/%*d] by\00"
define i32 @get_current_version() {
%1 = alloca [256 x i8]
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = load i32, i32* @get_current_version.auriga_version
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %30
6: ; preds = %0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%8 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1129)
%9 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %24, label %11
11: ; preds = %6
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%13 = bitcast i32* %3 to i8*
br label %14
14: ; preds = %17, %11
%15 = call i64 @fgets(i8* %12, i32 1024, i32* %9)
%16 = icmp eq i64 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %14
20: ; preds = %17
%21 = load i32, i32* %3
store i32 %21, i32* @get_current_version.auriga_version
br label %22
22: ; preds = %14, %20
%23 = call i32 @fclose(i32* %9)
br label %24
24: ; preds = %22, %6
%25 = load i32, i32* @get_current_version.auriga_version
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 1129, i32* @get_current_version.auriga_version
br label %28
28: ; preds = %27, %24
%29 = phi i32 [ 1129, %27 ], [ %25, %24 ]
br label %30
30: ; preds = %28, %0
%31 = phi i32 [ %29, %28 ], [ %4, %0 ]
ret i32 %31
}