#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*/ *open_list(char *);
int /*<<< orphan*/ print_line_colored(char *);
scalar_t__ strstr(char *, char *);
void list_id(char *id) {
  FILE *fp;
  fp = open_list("r");
  char line[4096];
  while (fp && fgets(line, sizeof(line), fp)) {
    if (strstr(line, id)) {
      print_line_colored(line);
    }
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<list_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9a(%rip),%rdi
call   1060 <open_list@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x1011(%rbp)
je     11a4 <list_id+0x54>
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1000,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1011(%rbp)
mov    -0x1011(%rbp),%al
test   $0x1,%al
jne    11b7 <list_id+0x67>
jmp    11e2 <list_id+0x92>
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     11dd <list_id+0x8d>
lea    -0x1010(%rbp),%rdi
call   1050 <print_line_colored@plt>
jmp    116f <list_id+0x1f>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_id>:
push   %r15
push   %r14
push   %rbx
sub    $0x1000,%rsp
mov    %rdi,%r14
lea    0xe9a(%rip),%rdi
call   1060 <open_list@plt>
mov    %rax,%r15
test   %rax,%rax
je     11bf <list_id+0x6f>
mov    %rsp,%rdi
mov    $0x1000,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11bf <list_id+0x6f>
mov    %rsp,%rbx
jmp    11a5 <list_id+0x55>
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11bf <list_id+0x6f>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strstr@plt>
test   %rax,%rax
je     1190 <list_id+0x40>
mov    %rbx,%rdi
call   1050 <print_line_colored@plt>
jmp    1190 <list_id+0x40>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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