#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*/ help();
int /*<<< orphan*/ *open_list(char *);
int /*<<< orphan*/ print_line_colored(char *);
int /*<<< orphan*/ printf(char *);
void list_all() {
  FILE *fp;
  fp = open_list("r");
  char line[4096];
  int counter = 0;
  while (fp && fgets(line, sizeof(line), fp)) {
    print_line_colored(line);
    counter++;
  }
  if (!counter) {
    printf("No tasks.\n");
    help();
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<list_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
lea    0xe8e(%rip),%rdi
call   1070 <open_list@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x1014(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x1015(%rbp)
je     11ba <list_all+0x5a>
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x1000,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1015(%rbp)
mov    -0x1015(%rbp),%al
test   $0x1,%al
jne    11cd <list_all+0x6d>
jmp    11ed <list_all+0x8d>
lea    -0x1010(%rbp),%rdi
call   1060 <print_line_colored@plt>
mov    -0x1014(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1014(%rbp)
jmp    1185 <list_all+0x25>
cmpl   $0x0,-0x1014(%rbp)
jne    120d <list_all+0xad>
lea    0xe01(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <help@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_all>:
push   %r15
push   %r14
push   %rbx
sub    $0x1000,%rsp
lea    0xe8d(%rip),%rdi
call   1070 <open_list@plt>
mov    %rax,%r15
test   %rax,%rax
je     11c2 <list_all+0x62>
mov    %rsp,%rdi
mov    $0x1000,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11c2 <list_all+0x62>
mov    %rax,%r14
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <print_line_colored@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11a0 <list_all+0x40>
test   %r14,%r14
jne    11d5 <list_all+0x75>
lea    0xe39(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <help@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [11 x i8] c"No tasks.\0A\00"
define void @list_all() {
%1 = alloca i32*
%2 = alloca [4096 x i8]
%3 = alloca i32
%4 = call i32* @open_list(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %4, i32** %1
store i32 0, i32* %3
br label %5
5: ; preds = %15, %0
%6 = load i32*, i32** %1
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%10 = load i32*, i32** %1
%11 = call i64 @fgets(i8* %9, i32 4096, i32* %10)
%12 = icmp ne i64 %11, 0
br label %13
13: ; preds = %8, %5
%14 = phi i1 [ false, %5 ], [ %12, %8 ]
br i1 %14, label %15, label %20
15: ; preds = %13
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%17 = call i32 @print_line_colored(i8* %16)
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %5
20: ; preds = %13
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 (...) @help()
br label %26
26: ; preds = %23, %20
%27 = load i32*, i32** %1
%28 = call i32 @fclose(i32* %27)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@str = [10 x i8] c"No tasks.\00"
define void @list_all() {
%1 = alloca [4096 x i8]
%2 = tail call i32* @open_list(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%4 = icmp eq i32* %2, null
br i1 %4, label %13, label %5
5: ; preds = %0
%6 = call i64 @fgets(i8* %3, i32 4096, i32* %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %5, %8
%9 = call i32 @print_line_colored(i8* %3)
%10 = call i64 @fgets(i8* %3, i32 4096, i32* %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %8
12: ; preds = %8
br i1 %7, label %13, label %16
13: ; preds = %5, %0, %12
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%15 = call i32 (...) @help()
br label %16
16: ; preds = %13, %12
%17 = call i32 @fclose(i32* %2)
ret void
}