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

/* Variables and functions */
long atol(char *);
int /*<<< orphan*/ capitalize(char const *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ sprintf(char *, char *, char *, int /*<<< orphan*/);
char *strstr(char *, char *);
long get_age_from_file(const char *usrName) {
  char usrFile[65537];
  char fileBuf[65537 * 2];
  char *pDest;
  int index;
  FILE *fp;
  long age = -1;
  sprintf(usrFile, "%s%s", "user/", capitalize(usrName));
  fp = fopen(usrFile, "r");
  if (NULL != fp) {
    if (fread(fileBuf, sizeof(char), sizeof(fileBuf), fp) > 0) {
      pDest = strstr(fileBuf, "\nAge");
      if (pDest) {
        index = pDest - fileBuf + 1;
        while (!isdigit(fileBuf[index]))
          index++;
        age = atol(&fileBuf[index]);
      }
    }
    fclose(fp);
  }
  return age;
}


x86 assembly (clang, -O0):
<get_age_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30050,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0xffffffffffffffff,-0x30040(%rbp)
ff ff ff ff
lea    -0x10010(%rbp),%rax
mov    %rax,-0x30048(%rbp)
mov    -0x8(%rbp),%rdi
call   1090 <capitalize@plt>
mov    -0x30048(%rbp),%rdi
mov    %eax,%ecx
lea    0xe3f(%rip),%rsi
lea    0xe3d(%rip),%rdx
call   1080 <sprintf@plt>
lea    -0x10010(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30038(%rbp)
xor    %eax,%eax
cmp    -0x30038(%rbp),%rax
je     12cb <get_age_from_file+0x14b>
lea    -0x30020(%rbp),%rdi
mov    -0x30038(%rbp),%rcx
mov    $0x1,%esi
mov    $0x20002,%edx
call   1040 <fread@plt>
cmp    $0x0,%rax
jle    12bf <get_age_from_file+0x13f>
lea    -0x30020(%rbp),%rdi
lea    0xde2(%rip),%rsi
call   10a0 <strstr@plt>
mov    %rax,-0x30028(%rbp)
cmpq   $0x0,-0x30028(%rbp)
je     12ba <get_age_from_file+0x13a>
mov    -0x30028(%rbp),%rax
lea    -0x30020(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,-0x3002c(%rbp)
movslq -0x3002c(%rbp),%rax
movsbl -0x30020(%rbp,%rax,1),%edi
ff
call   1030 <isdigit@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1289 <get_age_from_file+0x109>
jmp    129d <get_age_from_file+0x11d>
mov    -0x3002c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3002c(%rbp)
jmp    1260 <get_age_from_file+0xe0>
movslq -0x3002c(%rbp),%rax
lea    -0x30020(%rbp),%rdi
add    %rax,%rdi
call   1060 <atol@plt>
mov    %rax,-0x30040(%rbp)
jmp    12bf <get_age_from_file+0x13f>
mov    -0x30038(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30040(%rbp),%rax
add    $0x30050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_age_from_file>:
push   %r14
push   %rbx
sub    $0x30018,%rsp
call   1090 <capitalize@plt>
lea    0xe6a(%rip),%rsi
lea    0xe68(%rip),%rdx
lea    0x20010(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%ecx
call   1080 <sprintf@plt>
lea    0xe55(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     123b <get_age_from_file+0xbb>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x20002,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    $0xffffffffffffffff,%rbx
test   %rax,%rax
jle    1231 <get_age_from_file+0xb1>
lea    0xe1f(%rip),%rsi
mov    %rsp,%rdi
call   10a0 <strstr@plt>
test   %rax,%rax
je     1231 <get_age_from_file+0xb1>
mov    %rsp,%rcx
sub    %ecx,%eax
add    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %eax,%rbx
movsbl (%rsp,%rbx,1),%edi
call   1030 <isdigit@plt>
mov    %eax,%ecx
lea    0x1(%rbx),%eax
test   %ecx,%ecx
je     1210 <get_age_from_file+0x90>
lea    (%rsp,%rbx,1),%rdi
call   1060 <atol@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <fclose@plt>
jmp    1242 <get_age_from_file+0xc2>
mov    $0xffffffffffffffff,%rbx
mov    %rbx,%rax
add    $0x30018,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [6 x i8] c"user/\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [5 x i8] c"\0AAge\00"
define i64 @get_age_from_file(i8* %0) {
%2 = alloca i8*
%3 = alloca [65537 x i8]
%4 = alloca [131074 x i8]
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i64
store i8* %0, i8** %2
store i64 -1, i64* %8
%9 = getelementptr inbounds [65537 x i8], [65537 x i8]* %3, i64 0, i64 0
%10 = load i8*, i8** %2
%11 = call i32 @capitalize(i8* %10)
%12 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [65537 x i8], [65537 x i8]* %3, i64 0, i64 0
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %14, i32** %7
%15 = load i32*, i32** %7
%16 = icmp ne i32* null, %15
br i1 %16, label %17, label %55
17: ; preds = %1
%18 = getelementptr inbounds [131074 x i8], [131074 x i8]* %4, i64 0, i64 0
%19 = load i32*, i32** %7
%20 = call i64 @fread(i8* %18, i32 1, i32 131074, i32* %19)
%21 = icmp sgt i64 %20, 0
br i1 %21, label %22, label %52
22: ; preds = %17
%23 = getelementptr inbounds [131074 x i8], [131074 x i8]* %4, i64 0, i64 0
%24 = call i8* @strstr(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i8* %24, i8** %5
%25 = load i8*, i8** %5
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %51
27: ; preds = %22
%28 = load i8*, i8** %5
%29 = getelementptr inbounds [131074 x i8], [131074 x i8]* %4, i64 0, i64 0
%30 = ptrtoint i8* %28 to i64
%31 = ptrtoint i8* %29 to i64
%32 = sub i64 %30, %31
%33 = add nsw i64 %32, 1
%34 = trunc i64 %33 to i32
store i32 %34, i32* %6
br label %35
35: ; preds = %43, %27
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [131074 x i8], [131074 x i8]* %4, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = call i32 @isdigit(i8 signext %39)
%41 = icmp ne i32 %40, 0
%42 = xor i1 %41, true
br i1 %42, label %43, label %46
43: ; preds = %35
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %35
46: ; preds = %35
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [131074 x i8], [131074 x i8]* %4, i64 0, i64 %48
%50 = call i64 @atol(i8* %49)
store i64 %50, i64* %8
br label %51
51: ; preds = %46, %22
br label %52
52: ; preds = %51, %17
%53 = load i32*, i32** %7
%54 = call i32 @fclose(i32* %53)
br label %55
55: ; preds = %52, %1
%56 = load i64, i64* %8
ret i64 %56
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [6 x i8] c"user/\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [5 x i8] c"\0AAge\00"
define i64 @get_age_from_file(i8* %0) {
%2 = alloca [65537 x i8]
%3 = alloca [131074 x i8]
%4 = getelementptr inbounds [65537 x i8], [65537 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [131074 x i8], [131074 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @capitalize(i8* %0)
%7 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %35, label %10
10: ; preds = %1
%11 = call i64 @fread(i8* %5, i32 1, i32 131074, i32* %8)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %32
13: ; preds = %10
%14 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %32, label %16
16: ; preds = %13
%17 = ptrtoint i8* %14 to i64
%18 = ptrtoint [131074 x i8]* %3 to i64
%19 = sub i64 %17, %18
%20 = trunc i64 %19 to i32
br label %21
21: ; preds = %21, %16
%22 = phi i32 [ %20, %16 ], [ %23, %21 ]
%23 = add i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [131074 x i8], [131074 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call i32 @isdigit(i8 signext %26)
%28 = icmp eq i32 %27, 0
br i1 %28, label %21, label %29
29: ; preds = %21
%30 = getelementptr inbounds [131074 x i8], [131074 x i8]* %3, i64 0, i64 %24
%31 = call i64 @atol(i8* %30)
br label %32
32: ; preds = %13, %29, %10
%33 = phi i64 [ %31, %29 ], [ -1, %13 ], [ -1, %10 ]
%34 = call i32 @fclose(i32* %8)
br label %35
35: ; preds = %32, %1
%36 = phi i64 [ %33, %32 ], [ -1, %1 ]
ret i64 %36
}