#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ insert_task(int /*<<< orphan*/, char *, char *);
char *read_input(int /*<<< orphan*/ *);
void read_from_file(void) {
  char *name, *category;
  FILE *list = fopen("daily219todolist.txt", "r");
  name = category = NULL;
  if (list == NULL)
    return;
  for (;;) {
    name = read_input(list);
    category = read_input(list);
    if (feof(list))
      break;
    insert_task(0, name, category);
    free(name);
    free(category);
  }
  fclose(list);
  free(name);
  free(category);
}


x86 assembly (clang, -O0):
<read_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x8(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119f <read_from_file+0x3f>
jmp    1217 <read_from_file+0xb7>
jmp    11a4 <read_from_file+0x44>
mov    -0x18(%rbp),%rdi
call   1080 <read_input@plt>
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <read_input@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     11d6 <read_from_file+0x76>
jmp    11fc <read_from_file+0x9c>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
xor    %edi,%edi
call   1070 <insert_task@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    11a4 <read_from_file+0x44>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_from_file>:
push   %r15
push   %r14
push   %rbx
lea    0xe94(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11df <read_from_file+0x7f>
mov    %rax,%r14
mov    %r14,%rdi
call   1080 <read_input@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1080 <read_input@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <feof@plt>
test   %rax,%rax
jne    11c2 <read_from_file+0x62>
xor    %edi,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <insert_task@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1180 <read_from_file+0x20>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"daily219todolist.txt\00"
@.str.1 = [2 x i8] c"r\00"
define void @read_from_file() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32*
%4 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %3
store i8* null, i8** %2
store i8* null, i8** %1
%5 = load i32*, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %8
7: ; preds = %0
br label %33
8: ; preds = %0
br label %9
9: ; preds = %18, %8
%10 = load i32*, i32** %3
%11 = call i8* @read_input(i32* %10)
store i8* %11, i8** %1
%12 = load i32*, i32** %3
%13 = call i8* @read_input(i32* %12)
store i8* %13, i8** %2
%14 = load i32*, i32** %3
%15 = call i64 @feof(i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %9
br label %26
18: ; preds = %9
%19 = load i8*, i8** %1
%20 = load i8*, i8** %2
%21 = call i32 @insert_task(i32 0, i8* %19, i8* %20)
%22 = load i8*, i8** %1
%23 = call i32 @free(i8* %22)
%24 = load i8*, i8** %2
%25 = call i32 @free(i8* %24)
br label %9
26: ; preds = %17
%27 = load i32*, i32** %3
%28 = call i32 @fclose(i32* %27)
%29 = load i8*, i8** %1
%30 = call i32 @free(i8* %29)
%31 = load i8*, i8** %2
%32 = call i32 @free(i8* %31)
br label %33
33: ; preds = %26, %7
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"daily219todolist.txt\00"
@.str.1 = [2 x i8] c"r\00"
define void @read_from_file() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %24, label %3
3: ; preds = %0
%4 = tail call i8* @read_input(i32* %1)
%5 = tail call i8* @read_input(i32* %1)
%6 = tail call i64 @feof(i32* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %3, %8
%9 = phi i8* [ %15, %8 ], [ %5, %3 ]
%10 = phi i8* [ %14, %8 ], [ %4, %3 ]
%11 = tail call i32 @insert_task(i32 0, i8* %10, i8* %9)
%12 = tail call i32 @free(i8* %10)
%13 = tail call i32 @free(i8* %9)
%14 = tail call i8* @read_input(i32* %1)
%15 = tail call i8* @read_input(i32* %1)
%16 = tail call i64 @feof(i32* %1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %8, label %18
18: ; preds = %8, %3
%19 = phi i8* [ %4, %3 ], [ %14, %8 ]
%20 = phi i8* [ %5, %3 ], [ %15, %8 ]
%21 = tail call i32 @fclose(i32* %1)
%22 = tail call i32 @free(i8* %19)
%23 = tail call i32 @free(i8* %20)
br label %24
24: ; preds = %0, %18
ret void
}