#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 */

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char *, int);
char *stristr(char const *, char *);
char *strstr(char *, char *);
char *get_last_modified(const char *header, char *last_modified, int size) {
  char *pb, *pe;
  int len;
  pb = stristr(header, "Last-Modified: ");
  if (!pb)
    return NULL;
  pb += 15;
  pe = strstr(pb, "\r\n");
  if (!pe)
    return NULL;
  len = pe - pb;
  if (len >= size)
    return NULL;
  memcpy(last_modified, pb, len);
  *(last_modified + len) = 0;
  return last_modified;
}


x86 assembly (clang, -O0):
<get_last_modified>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1030 <stristr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116f <get_last_modified+0x3f>
movq   $0x0,-0x8(%rbp)
jmp    11f2 <get_last_modified+0xc2>
mov    -0x28(%rbp),%rax
add    $0xf,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11a7 <get_last_modified+0x77>
movq   $0x0,-0x8(%rbp)
jmp    11f2 <get_last_modified+0xc2>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     11ce <get_last_modified+0x9e>
movq   $0x0,-0x8(%rbp)
jmp    11f2 <get_last_modified+0xc2>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_last_modified>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
lea    0xebc(%rip),%rsi
call   1030 <stristr@plt>
test   %rax,%rax
je     118b <get_last_modified+0x5b>
mov    %rax,%rbp
add    $0xf,%rbp
lea    0xeb4(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     118b <get_last_modified+0x5b>
mov    %rax,%rbx
sub    %rbp,%rbx
cmp    %r14d,%ebx
jge    118b <get_last_modified+0x5b>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
movslq %ebx,%rax
movb   $0x0,(%r15,%rax,1)
jmp    118e <get_last_modified+0x5e>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Last-Modified: \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define i8* @get_last_modified(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%11 = load i8*, i8** %5
%12 = call i8* @stristr(i8* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %8
%13 = load i8*, i8** %8
%14 = icmp ne i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %3
store i8* null, i8** %4
br label %45
16: ; preds = %3
%17 = load i8*, i8** %8
%18 = getelementptr inbounds i8, i8* %17, i64 15
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = call i8* @strstr(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %20, i8** %9
%21 = load i8*, i8** %9
%22 = icmp ne i8* %21, null
br i1 %22, label %24, label %23
23: ; preds = %16
store i8* null, i8** %4
br label %45
24: ; preds = %16
%25 = load i8*, i8** %9
%26 = load i8*, i8** %8
%27 = ptrtoint i8* %25 to i64
%28 = ptrtoint i8* %26 to i64
%29 = sub i64 %27, %28
%30 = trunc i64 %29 to i32
store i32 %30, i32* %10
%31 = load i32, i32* %10
%32 = load i32, i32* %7
%33 = icmp sge i32 %31, %32
br i1 %33, label %34, label %35
34: ; preds = %24
store i8* null, i8** %4
br label %45
35: ; preds = %24
%36 = load i8*, i8** %6
%37 = load i8*, i8** %8
%38 = load i32, i32* %10
%39 = call i32 @memcpy(i8* %36, i8* %37, i32 %38)
%40 = load i8*, i8** %6
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
store i8 0, i8* %43
%44 = load i8*, i8** %6
store i8* %44, i8** %4
br label %45
45: ; preds = %35, %34, %23, %15
%46 = load i8*, i8** %4
ret i8* %46
}

LLVM IR (-O2):
@.str = [16 x i8] c"Last-Modified: \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define i8* @get_last_modified(i8* %0, i8* %1, i32 %2) {
%4 = tail call i8* @stristr(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 15
%8 = tail call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %21, label %10
10: ; preds = %6
%11 = ptrtoint i8* %8 to i64
%12 = ptrtoint i8* %7 to i64
%13 = sub i64 %11, %12
%14 = trunc i64 %13 to i32
%15 = icmp slt i32 %14, %2
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = tail call i32 @memcpy(i8* %1, i8* %7, i32 %14)
%18 = shl i64 %13, 32
%19 = ashr exact i64 %18, 32
%20 = getelementptr inbounds i8, i8* %1, i64 %19
store i8 0, i8* %20
br label %21
21: ; preds = %10, %6, %3, %16
%22 = phi i8* [ %1, %16 ], [ null, %3 ], [ null, %6 ], [ null, %10 ]
ret i8* %22
}