#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*/ strstr(char const *, char *);
int match_and(const char *line, int termc, char *terms[]) {
  int i = 0;
  int match = 1;
  for (i = 0; i != termc; i++) {
    if (!strstr(line, terms[i])) {
      match = 0;
      break;
    }
  }
  return match;
}


x86 assembly (clang, -O0):
<match_and>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1181 <match_and+0x71>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%eax
jne    116e <match_and+0x5e>
movl   $0x0,-0x20(%rbp)
jmp    1181 <match_and+0x71>
jmp    1173 <match_and+0x63>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1138 <match_and+0x28>
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_and>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%r14d
test   %esi,%esi
je     114e <match_and+0x3e>
mov    %rdx,%r15
mov    %rdi,%r12
mov    %esi,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r15,%rbp,8),%rsi
mov    %r12,%rdi
call   1030 <strstr@plt>
test   %eax,%eax
je     114b <match_and+0x3b>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1130 <match_and+0x20>
jmp    114e <match_and+0x3e>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @match_and(i8* %0, i32 %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
store i32 0, i32* %7
store i32 1, i32* %8
store i32 0, i32* %7
br label %9
9: ; preds = %24, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %27
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = load i8**, i8*** %6
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @strstr(i8* %14, i8* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %13
store i32 0, i32* %8
br label %27
23: ; preds = %13
br label %24
24: ; preds = %23
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %9
27: ; preds = %22, %9
%28 = load i32, i32* %8
ret i32 %28
}

LLVM IR (-O2):
define i32 @match_and(i8* %0, i32 %1, i8** nocapture %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %16, label %5
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %9
7: ; preds = %9
%8 = icmp eq i64 %15, %6
br i1 %8, label %16, label %9
9: ; preds = %5, %7
%10 = phi i64 [ 0, %5 ], [ %15, %7 ]
%11 = getelementptr inbounds i8*, i8** %2, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32 @strstr(i8* %0, i8* %12)
%14 = icmp eq i32 %13, 0
%15 = add nuw nsw i64 %10, 1
br i1 %14, label %16, label %7
16: ; preds = %7, %9, %3
%17 = phi i32 [ 1, %3 ], [ 0, %9 ], [ 1, %7 ]
ret i32 %17
}