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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
char *malloc(int);
int strlen(char const *);
scalar_t__ strncmp(char const *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
const char *getAccountId(const char *pUser, const char *pAccounts) {
  char *toReturn = NULL;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  FILE *fp;
  fp = fopen(pAccounts, "r");
  if (fp == NULL) {
    return NULL;
  }
  while ((read = getline(&line, &len, fp)) != -1) {
    if ((read == strlen(pUser) + 64 + 3) &&
        strncmp(pUser, line, strlen(pUser)) == 0 &&
        line[strlen(pUser)] == ':') {
      toReturn = malloc(64 + 1);
      strncpy(toReturn, line + strlen(pUser) + 2, 64);
      toReturn[64] = '\0';
      break;
    }
  }
  free(line);
  fclose(fp);
  return toReturn;
}


x86 assembly (clang, -O0):
<getAccountId>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11d4 <getAccountId+0x54>
movq   $0x0,-0x8(%rbp)
jmp    12df <getAccountId+0x15f>
jmp    11d9 <getAccountId+0x59>
mov    -0x40(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10a0 <getline@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     12c5 <getAccountId+0x145>
mov    -0x34(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
add    $0x40,%ecx
add    $0x3,%ecx
cmp    %ecx,%eax
jne    12c0 <getAccountId+0x140>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    12c0 <getAccountId+0x140>
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    12c0 <getAccountId+0x140>
mov    $0x41,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x70(%rbp),%rsi
mov    -0x68(%rbp),%rdi
cltq
add    %rax,%rsi
add    $0x2,%rsi
mov    $0x40,%edx
call   1040 <strncpy@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,0x40(%rax)
jmp    12c5 <getAccountId+0x145>
jmp    11d9 <getAccountId+0x59>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getAccountId>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe53(%rip),%rsi
mov    %rax,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1285 <getAccountId+0x105>
mov    %rax,%r15
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rax,%rdx
call   10a0 <getline@plt>
cmp    $0xffffffff,%eax
je     128a <getAccountId+0x10a>
mov    %eax,%ebp
lea    0x8(%rsp),%r12
lea    0x10(%rsp),%r13
xor    %r14d,%r14d
jmp    1209 <getAccountId+0x89>
nopl   (%rax)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   10a0 <getline@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     128d <getAccountId+0x10d>
mov    %rbx,%rdi
call   1070 <strlen@plt>
add    $0x43,%eax
cmp    %eax,%ebp
jne    11f0 <getAccountId+0x70>
mov    0x8(%rsp),%rbp
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jne    11f0 <getAccountId+0x70>
mov    0x8(%rsp),%rbp
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0x3a,0x0(%rbp,%rax,1)
jne    11f0 <getAccountId+0x70>
mov    $0x41,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    0x8(%rsp),%rbp
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
lea    (%rax,%rbp,1),%rsi
add    $0x2,%rsi
mov    %r14,%rdi
mov    $0x40,%edx
call   1040 <strncpy@plt>
movb   $0x0,0x40(%r14)
jmp    128d <getAccountId+0x10d>
xor    %r14d,%r14d
jmp    129f <getAccountId+0x11f>
xor    %r14d,%r14d
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i8* @getAccountId(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i64 0, i64* %8
%11 = load i8*, i8** %5
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %10
%13 = load i32*, i32** %10
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %16
15: ; preds = %2
store i8* null, i8** %3
br label %63
16: ; preds = %2
br label %17
17: ; preds = %56, %16
%18 = load i32*, i32** %10
%19 = call i32 @getline(i8** %7, i64* %8, i32* %18)
store i32 %19, i32* %9
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %57
21: ; preds = %17
%22 = load i32, i32* %9
%23 = load i8*, i8** %4
%24 = call i32 @strlen(i8* %23)
%25 = add nsw i32 %24, 64
%26 = add nsw i32 %25, 3
%27 = icmp eq i32 %22, %26
br i1 %27, label %28, label %56
28: ; preds = %21
%29 = load i8*, i8** %4
%30 = load i8*, i8** %7
%31 = load i8*, i8** %4
%32 = call i32 @strlen(i8* %31)
%33 = call i64 @strncmp(i8* %29, i8* %30, i32 %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %56
35: ; preds = %28
%36 = load i8*, i8** %7
%37 = load i8*, i8** %4
%38 = call i32 @strlen(i8* %37)
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 58
br i1 %43, label %44, label %56
44: ; preds = %35
%45 = call i8* @malloc(i32 65)
store i8* %45, i8** %6
%46 = load i8*, i8** %6
%47 = load i8*, i8** %7
%48 = load i8*, i8** %4
%49 = call i32 @strlen(i8* %48)
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %47, i64 %50
%52 = getelementptr inbounds i8, i8* %51, i64 2
%53 = call i32 @strncpy(i8* %46, i8* %52, i32 64)
%54 = load i8*, i8** %6
%55 = getelementptr inbounds i8, i8* %54, i64 64
store i8 0, i8* %55
br label %57
56: ; preds = %35, %28, %21
br label %17
57: ; preds = %44, %17
%58 = load i8*, i8** %7
%59 = call i32 @free(i8* %58)
%60 = load i32*, i32** %10
%61 = call i32 @fclose(i32* %60)
%62 = load i8*, i8** %6
store i8* %62, i8** %3
br label %63
63: ; preds = %57, %15
%64 = load i8*, i8** %3
ret i8* %64
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i8* @getAccountId(i8* %0, i8* nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %46, label %9
9: ; preds = %2
%10 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%11 = icmp eq i32 %10, -1
br i1 %11, label %41, label %12
12: ; preds = %9, %38
%13 = phi i32 [ %39, %38 ], [ %10, %9 ]
%14 = call i32 @strlen(i8* %0)
%15 = add nsw i32 %14, 67
%16 = icmp eq i32 %13, %15
br i1 %16, label %17, label %38
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = call i32 @strlen(i8* %0)
%20 = call i64 @strncmp(i8* %0, i8* %18, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %38
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = call i32 @strlen(i8* %0)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 58
br i1 %28, label %29, label %38
29: ; preds = %22
%30 = call dereferenceable_or_null(65) i8* @malloc(i32 65)
%31 = load i8*, i8** %3
%32 = call i32 @strlen(i8* %0)
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = getelementptr inbounds i8, i8* %34, i64 2
%36 = call i32 @strncpy(i8* %30, i8* %35, i32 64)
%37 = getelementptr inbounds i8, i8* %30, i64 64
store i8 0, i8* %37
br label %41
38: ; preds = %22, %17, %12
%39 = call i32 @getline(i8** %3, i64* %4, i32* %7)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %12
41: ; preds = %38, %9, %29
%42 = phi i8* [ %30, %29 ], [ null, %9 ], [ null, %38 ]
%43 = load i8*, i8** %3
%44 = call i32 @free(i8* %43)
%45 = call i32 @fclose(i32* %7)
br label %46
46: ; preds = %2, %41
%47 = phi i8* [ %42, %41 ], [ null, %2 ]
ret i8* %47
}