#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char const *);
scalar_t__ strncmp(char *, char const *, int);
void findstring(const char *date, FILE *fileptr) {
  char buffer[120];
  int length = strlen(date);
  while (fgets(buffer, 120, fileptr) != NULL) {
    if (strncmp(buffer, date, length) == 0)
      printf("%s", buffer + length);
    else
      continue;
  }
}


x86 assembly (clang, -O0):
<findstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x78,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     11cd <findstring+0x8d>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x94(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11c3 <findstring+0x83>
lea    -0x90(%rbp),%rsi
movslq -0x94(%rbp),%rax
add    %rax,%rsi
lea    0xe47(%rip),%rdi
call   1050 <printf@plt>
jmp    11c8 <findstring+0x88>
jmp    1162 <findstring+0x22>
jmp    1162 <findstring+0x22>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findstring>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %rsp,%rdi
mov    $0x78,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11c4 <findstring+0x84>
movslq %ebp,%rax
lea    (%rsp,%rax,1),%r15
mov    %rsp,%rbx
lea    0xe7f(%rip),%r13
jmp    11a5 <findstring+0x65>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x78,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11c4 <findstring+0x84>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1190 <findstring+0x50>
mov    %r13,%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
jmp    1190 <findstring+0x50>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @findstring(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [120 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %6
br label %9
9: ; preds = %27, %26, %2
%10 = getelementptr inbounds [120 x i8], [120 x i8]* %5, i64 0, i64 0
%11 = load i32*, i32** %4
%12 = call i32* @fgets(i8* %10, i32 120, i32* %11)
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %28
14: ; preds = %9
%15 = getelementptr inbounds [120 x i8], [120 x i8]* %5, i64 0, i64 0
%16 = load i8*, i8** %3
%17 = load i32, i32* %6
%18 = call i64 @strncmp(i8* %15, i8* %16, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %14
%21 = getelementptr inbounds [120 x i8], [120 x i8]* %5, i64 0, i64 0
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %24)
br label %27
26: ; preds = %14
br label %9
27: ; preds = %20
br label %9
28: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @findstring(i8* %0, i32* nocapture %1) {
%3 = alloca [120 x i8]
%4 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %0)
%6 = call i32* @fgets(i8* %4, i32 120, i32* %1)
%7 = icmp eq i32* %6, null
br i1 %7, label %19, label %8
8: ; preds = %2
%9 = sext i32 %5 to i64
%10 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 %9
br label %11
11: ; preds = %8, %16
%12 = call i64 @strncmp(i8* %4, i8* %0, i32 %5)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %16
16: ; preds = %14, %11
%17 = call i32* @fgets(i8* %4, i32 120, i32* %1)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %11
19: ; preds = %16, %2
ret void
}