#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*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ first(char *, char);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ last(char *, char);
int /*<<< orphan*/ printf(char *, ...);
char *strstr(char *, char *);
char *substr2(char *, int, scalar_t__);
void list() {
  FILE *file = fopen("~/.ccmd", "r");
  char line[4096] = "";
  char *line2 = 0;
  char *ccmd = 0;
  char *cmd = 0;
  if (file != NULL) {
    while (fgets(line, sizeof line, file) != NULL) {
      line2 = strstr(line, " ");
      ccmd = substr2(line2, 1, first(line2, '=') - 1);
      line2 = strstr(line2, "\"");
      cmd = substr2(line2, 1, last(line2, '\"'));
      printf("%s : %s \n", ccmd, cmd);
    }
    fclose(file);
  } else {
    printf(" Error: an error occured reading ccmd file \n");
  }
}


x86 assembly (clang, -O0):
<list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
lea    0xe5e(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x8(%rbp)
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
movq   $0x0,-0x1018(%rbp)
movq   $0x0,-0x1020(%rbp)
movq   $0x0,-0x1028(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     12f0 <list+0x160>
jmp    11f6 <list+0x66>
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x1000,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     12e2 <list+0x152>
lea    -0x1010(%rbp),%rdi
lea    0xde7(%rip),%rsi
call   10a0 <strstr@plt>
mov    %rax,-0x1018(%rbp)
mov    -0x1018(%rbp),%rax
mov    %rax,-0x1038(%rbp)
mov    -0x1018(%rbp),%rdi
mov    $0x3d,%esi
call   10b0 <first@plt>
mov    -0x1038(%rbp),%rdi
mov    %rax,%rdx
sub    $0x1,%rdx
mov    $0x1,%esi
call   1080 <substr2@plt>
mov    %rax,-0x1020(%rbp)
mov    -0x1018(%rbp),%rdi
lea    0xd91(%rip),%rsi
call   10a0 <strstr@plt>
mov    %rax,-0x1018(%rbp)
mov    -0x1018(%rbp),%rax
mov    %rax,-0x1030(%rbp)
mov    -0x1018(%rbp),%rdi
mov    $0x22,%esi
call   1050 <last@plt>
mov    -0x1030(%rbp),%rdi
mov    %rax,%rdx
mov    $0x1,%esi
call   1080 <substr2@plt>
mov    %rax,-0x1028(%rbp)
mov    -0x1020(%rbp),%rsi
mov    -0x1028(%rbp),%rdx
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f6 <list+0x66>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
jmp    12fe <list+0x16e>
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1000,%rsp
lea    0xe49(%rip),%rdi
lea    0xe4a(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   1080 <memset@plt>
test   %r14,%r14
je     12b0 <list+0x110>
mov    %rsp,%rdi
mov    $0x1000,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1297 <list+0xf7>
mov    %rsp,%r12
lea    0xe09(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x3d,%esi
call   10c0 <first@plt>
lea    -0x1(%rax),%rdx
mov    %rbx,%rdi
mov    $0x1,%esi
call   10a0 <substr2@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x22,%esi
call   1070 <last@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   10a0 <substr2@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
mov    $0x1000,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
jne    1210 <list+0x70>
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xd5d(%rip),%rdi
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"~/.ccmd\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"\22\00"
@.str.4 = [10 x i8] c"%s : %s \0A\00"
@.str.5 = [45 x i8] c" Error: an error occured reading ccmd file \0A\00"
define void @list() {
%1 = alloca i32*
%2 = alloca [4096 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %1
%7 = bitcast [4096 x i8]* %2 to i8*
store i8* null, i8** %3
store i8* null, i8** %4
store i8* null, i8** %5
%8 = load i32*, i32** %1
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %36
10: ; preds = %0
br label %11
11: ; preds = %16, %10
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%13 = load i32*, i32** %1
%14 = call i32* @fgets(i8* %12, i32 4096, i32* %13)
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %33
16: ; preds = %11
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%18 = call i8* @strstr(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %18, i8** %3
%19 = load i8*, i8** %3
%20 = load i8*, i8** %3
%21 = call i64 @first(i8* %20, i8 signext 61)
%22 = sub nsw i64 %21, 1
%23 = call i8* @substr2(i8* %19, i32 1, i64 %22)
store i8* %23, i8** %4
%24 = load i8*, i8** %3
%25 = call i8* @strstr(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %25, i8** %3
%26 = load i8*, i8** %3
%27 = load i8*, i8** %3
%28 = call i64 @last(i8* %27, i8 signext 34)
%29 = call i8* @substr2(i8* %26, i32 1, i64 %28)
store i8* %29, i8** %5
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %30, i8* %31)
br label %11
33: ; preds = %11
%34 = load i32*, i32** %1
%35 = call i32 @fclose(i32* %34)
br label %38
36: ; preds = %0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
br label %38
38: ; preds = %36, %33
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"~/.ccmd\00"
@.str.1 = [2 x i8] c"r\00"
@.str.4 = [10 x i8] c"%s : %s \0A\00"
@str = [44 x i8] c" Error: an error occured reading ccmd file \00"
define void @list() {
%1 = alloca [4096 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, 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 %21, label %5
5: ; preds = %0
%6 = call i32* @fgets(i8* %3, i32 4096, i32* %2)
%7 = icmp eq i32* %6, null
br i1 %7, label %19, label %8
8: ; preds = %5, %8
%9 = call i8* @strchr(i8* %3, i32 32)
%10 = call i64 @first(i8* %9, i8 signext 61)
%11 = add nsw i64 %10, -1
%12 = call i8* @substr2(i8* %9, i32 1, i64 %11)
%13 = call i8* @strchr(i8* dereferenceable(1) %9, i32 34)
%14 = call i64 @last(i8* %13, i8 signext 34)
%15 = call i8* @substr2(i8* %13, i32 1, i64 %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %12, i8* %15)
%17 = call i32* @fgets(i8* %3, i32 4096, i32* %2)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %8
19: ; preds = %8, %5
%20 = call i32 @fclose(i32* %2)
br label %23
21: ; preds = %0
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
ret void
}