#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char const *, int);
char *strchr(char const *, char);
scalar_t__ strstr(char *, char *);
int is_include(const char *buf) {
  char *p, *sub;
  int len;
  if (buf[0] != '#')
    return 0;
  p = strchr(buf, '\n');
  if (!p)
    return 0;
  ++buf;
  len = p - buf;
  sub = malloc(len + 1);
  memcpy(sub, buf, len);
  sub[len] = 0;
  if (strstr(sub, "include")) {
    free(sub);
    return 1;
  }
  free(sub);
  return 0;
}


x86 assembly (clang, -O0):
<is_include>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     1178 <is_include+0x28>
movl   $0x0,-0x4(%rbp)
jmp    1225 <is_include+0xd5>
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a1 <is_include+0x51>
movl   $0x0,-0x4(%rbp)
jmp    1225 <is_include+0xd5>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1215 <is_include+0xc5>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1225 <is_include+0xd5>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_include>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebp,%ebp
cmpb   $0x23,(%rdi)
jne    11bc <is_include+0x6c>
mov    %rdi,%rbx
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11bc <is_include+0x6c>
mov    %rax,%r14
add    $0x1,%rbx
sub    %rbx,%r14
lea    0x1(%r14),%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <memcpy@plt>
movslq %r14d,%rax
movb   $0x0,(%r15,%rax,1)
lea    0xe5d(%rip),%rsi
mov    %r15,%rdi
call   1070 <strstr@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"include\00"
define i32 @is_include(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 35
br i1 %3, label %4, label %23
4: ; preds = %1
%5 = tail call i8* @strchr(i8* %0, i8 signext 10)
%6 = icmp eq i8* %5, null
br i1 %6, label %23, label %7
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = ptrtoint i8* %5 to i64
%10 = ptrtoint i8* %8 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = add nsw i32 %12, 1
%14 = tail call i8* @malloc(i32 %13)
%15 = tail call i32 @memcpy(i8* %14, i8* %8, i32 %12)
%16 = shl i64 %11, 32
%17 = ashr exact i64 %16, 32
%18 = getelementptr inbounds i8, i8* %14, i64 %17
store i8 0, i8* %18
%19 = tail call i64 @strstr(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
%21 = tail call i32 @free(i8* %14)
%22 = zext i1 %20 to i32
br label %23
23: ; preds = %7, %4, %1
%24 = phi i32 [ 0, %1 ], [ 0, %4 ], [ %22, %7 ]
ret i32 %24
}