#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
char *proc_search_keyword(char *file, char *keyword) {
  FILE *fp;
  char buffer[1024], scan_buf[1024];
  char *read_ind;
  char *buffptr;
  char *result = malloc(1024);
  char blanco_dummy[1024];
  if ((fp = fopen(file, "r")) == NULL) {
    perror("fopen()");
    exit(EXIT_FAILURE);
  }
  do {
    read_ind = fgets(buffer, 1024, fp);
    buffptr = strstr(buffer, keyword);
  } while (buffptr == NULL && read_ind != NULL);
  fclose(fp);
  if (read_ind == NULL && buffptr == NULL)
    return "Nothing";
  strncpy(scan_buf, keyword, 996);
  strcat(scan_buf, ": %[a-zA-Z0-9 \t()]s");
  sscanf(buffptr, scan_buf, result);
  return result;
}


x86 assembly (clang, -O0):
<proc_search_keyword>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,-0x838(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11fc <proc_search_keyword+0x5c>
lea    0xe19(%rip),%rdi
call   1090 <perror@plt>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
jmp    1201 <proc_search_keyword+0x61>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
mov    %rax,-0x828(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x830(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x830(%rbp)
mov    %al,-0xc41(%rbp)
jne    125b <proc_search_keyword+0xbb>
cmpq   $0x0,-0x828(%rbp)
setne  %al
mov    %al,-0xc41(%rbp)
mov    -0xc41(%rbp),%al
test   $0x1,%al
jne    1201 <proc_search_keyword+0x61>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
cmpq   $0x0,-0x828(%rbp)
jne    129e <proc_search_keyword+0xfe>
cmpq   $0x0,-0x830(%rbp)
jne    129e <proc_search_keyword+0xfe>
lea    0xd75(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12eb <proc_search_keyword+0x14b>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x3e4,%edx
call   1030 <strncpy@plt>
lea    -0x820(%rbp),%rdi
lea    0xd51(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x830(%rbp),%rdi
lea    -0x820(%rbp),%rsi
mov    -0x838(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x838(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xc50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proc_search_keyword>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xe35(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1276 <proc_search_keyword+0xd6>
mov    %rax,%r12
lea    0x400(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x400,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %r15,%rsi
call   10c0 <strstr@plt>
mov    %rax,%rbx
test   %rbp,%rbp
je     121b <proc_search_keyword+0x7b>
test   %rbx,%rbx
je     11f0 <proc_search_keyword+0x50>
mov    %r12,%rdi
call   1040 <fclose@plt>
or     %rbx,%rbp
jne    1231 <proc_search_keyword+0x91>
lea    0xddb(%rip),%r14
jmp    1261 <proc_search_keyword+0xc1>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0x3e4,%edx
call   1030 <strncpy@plt>
lea    0xdc7(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1070 <sscanf@plt>
mov    %r14,%rax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd85(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [8 x i8] c"fopen()\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [8 x i8] c"Nothing\00"
@.str.3 = [20 x i8] c": %[a-zA-Z0-9 \09()]s\00"
define i8* @proc_search_keyword(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [1024 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%13 = call i8* @malloc(i32 1024)
store i8* %13, i8** %11
%14 = load i8*, i8** %4
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %6
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
br label %22
22: ; preds = %35, %21
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%24 = load i32*, i32** %6
%25 = call i8* @fgets(i8* %23, i32 1024, i32* %24)
store i8* %25, i8** %9
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%27 = load i8*, i8** %5
%28 = call i8* @strstr(i8* %26, i8* %27)
store i8* %28, i8** %10
br label %29
29: ; preds = %22
%30 = load i8*, i8** %10
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i8*, i8** %9
%34 = icmp ne i8* %33, null
br label %35
35: ; preds = %32, %29
%36 = phi i1 [ false, %29 ], [ %34, %32 ]
br i1 %36, label %22, label %37
37: ; preds = %35
%38 = load i32*, i32** %6
%39 = call i32 @fclose(i32* %38)
%40 = load i8*, i8** %9
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %46
42: ; preds = %37
%43 = load i8*, i8** %10
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %46
45: ; preds = %42
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %57
46: ; preds = %42, %37
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%48 = load i8*, i8** %5
%49 = call i32 @strncpy(i8* %47, i8* %48, i32 996)
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%51 = call i32 @strcat(i8* %50, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%52 = load i8*, i8** %10
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%54 = load i8*, i8** %11
%55 = call i32 @sscanf(i8* %52, i8* %53, i8* %54)
%56 = load i8*, i8** %11
store i8* %56, i8** %3
br label %57
57: ; preds = %46, %45
%58 = load i8*, i8** %3
ret i8* %58
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [8 x i8] c"fopen()\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [8 x i8] c"Nothing\00"
@.str.3 = [20 x i8] c": %[a-zA-Z0-9 \09()]s\00"
define i8* @proc_search_keyword(i8* nocapture %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2, %14
%15 = call i8* @fgets(i8* %5, i32 1024, i32* %8)
%16 = call i8* @strstr(i8* %5, i8* dereferenceable(1) %1)
%17 = icmp eq i8* %16, null
%18 = icmp ne i8* %15, null
%19 = and i1 %18, %17
br i1 %19, label %14, label %20
20: ; preds = %14
%21 = call i32 @fclose(i32* %8)
%22 = icmp eq i8* %15, null
%23 = select i1 %22, i1 %17, i1 false
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = call i32 @strncpy(i8* %6, i8* %1, i32 996)
%26 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @sscanf(i8* %16, i8* %6, i8* %7)
br label %28
28: ; preds = %20, %24
%29 = phi i8* [ %7, %24 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %20 ]
ret i8* %29
}