#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*/ cache_add_internal(char *, char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
char *strchr(char *, char);
char *strtok(char *, char *);
void cache_repopulate_internal(FILE *f) {
  char buf[1024];
  char *mkey, *value;
  while (fgets(buf, 1024, f) != NULL) {
    if (strchr(buf, '\r'))
      *(strchr(buf, '\r')) = '\0';
    if (strchr(buf, '\n'))
      *(strchr(buf, '\n')) = '\0';
    mkey = strtok(buf, "=");
    if (!mkey)
      continue;
    value = strtok(NULL, "=");
    if (!value)
      continue;
    cache_add_internal(mkey, value);
  }
}


x86 assembly (clang, -O0):
<cache_repopulate_internal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     123b <cache_repopulate_internal+0xfb>
lea    -0x410(%rbp),%rdi
mov    $0xd,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     119d <cache_repopulate_internal+0x5d>
lea    -0x410(%rbp),%rdi
mov    $0xd,%esi
call   1030 <strchr@plt>
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     11cc <cache_repopulate_internal+0x8c>
lea    -0x410(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
jne    11f9 <cache_repopulate_internal+0xb9>
jmp    114f <cache_repopulate_internal+0xf>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdfc(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    1223 <cache_repopulate_internal+0xe3>
jmp    114f <cache_repopulate_internal+0xf>
mov    -0x418(%rbp),%rdi
mov    -0x420(%rbp),%rsi
call   1050 <cache_add_internal@plt>
jmp    114f <cache_repopulate_internal+0xf>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cache_repopulate_internal>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%r14
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11ee <cache_repopulate_internal+0xae>
mov    %rsp,%r12
lea    0xe8c(%rip),%r15
jmp    1195 <cache_repopulate_internal+0x55>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11ee <cache_repopulate_internal+0xae>
mov    %r12,%rdi
mov    $0xd,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11aa <cache_repopulate_internal+0x6a>
movb   $0x0,(%rax)
mov    %r12,%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11bf <cache_repopulate_internal+0x7f>
movb   $0x0,(%rax)
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     1180 <cache_repopulate_internal+0x40>
mov    %rax,%rbx
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     1180 <cache_repopulate_internal+0x40>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <cache_add_internal@plt>
jmp    1180 <cache_repopulate_internal+0x40>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"=\00"
define void @cache_repopulate_internal(i32* %0) {
%2 = alloca i32*
%3 = alloca [1024 x i8]
%4 = alloca i8*
%5 = alloca i8*
store i32* %0, i32** %2
br label %6
6: ; preds = %36, %35, %30, %1
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = load i32*, i32** %2
%9 = call i32* @fgets(i8* %7, i32 1024, i32* %8)
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %40
11: ; preds = %6
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = call i8* @strchr(i8* %12, i8 signext 13)
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%17 = call i8* @strchr(i8* %16, i8 signext 13)
store i8 0, i8* %17
br label %18
18: ; preds = %15, %11
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%20 = call i8* @strchr(i8* %19, i8 signext 10)
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%24 = call i8* @strchr(i8* %23, i8 signext 10)
store i8 0, i8* %24
br label %25
25: ; preds = %22, %18
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%27 = call i8* @strtok(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %27, i8** %4
%28 = load i8*, i8** %4
%29 = icmp ne i8* %28, null
br i1 %29, label %31, label %30
30: ; preds = %25
br label %6
31: ; preds = %25
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %32, i8** %5
%33 = load i8*, i8** %5
%34 = icmp ne i8* %33, null
br i1 %34, label %36, label %35
35: ; preds = %31
br label %6
36: ; preds = %31
%37 = load i8*, i8** %4
%38 = load i8*, i8** %5
%39 = call i32 @cache_add_internal(i8* %37, i8* %38)
br label %6
40: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"=\00"
define void @cache_repopulate_internal(i32* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32* @fgets(i8* %3, i32 1024, i32* %0)
%5 = icmp eq i32* %4, null
br i1 %5, label %25, label %6
6: ; preds = %1, %22
%7 = call i8* @strchr(i8* %3, i8 signext 13)
%8 = icmp eq i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %6
store i8 0, i8* %7
br label %10
10: ; preds = %9, %6
%11 = call i8* @strchr(i8* %3, i8 signext 10)
%12 = icmp eq i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %10
store i8 0, i8* %11
br label %14
14: ; preds = %13, %10
%15 = call i8* @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 @cache_add_internal(i8* %15, i8* %18)
br label %22
22: ; preds = %20, %14, %17
%23 = call i32* @fgets(i8* %3, i32 1024, i32* %0)
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %6
25: ; preds = %22, %1
ret void
}