#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 */
scalar_t__ strncmp(char *, char *, int);
int is_c_type(char *t, char *types[], int type_len, int maxlen) {
  int i;
  for (i = 0; i < type_len; i++) {
    if (strncmp(t, types[i], maxlen) == 0) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<is_c_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    117a <is_c_type+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x20(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1167 <is_c_type+0x57>
movl   $0x1,-0x4(%rbp)
jmp    1181 <is_c_type+0x71>
jmp    116c <is_c_type+0x5c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112d <is_c_type+0x1d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_c_type>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
jle    114d <is_c_type+0x3d>
mov    %ecx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
mov    %edx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r15,%rbp,8),%rsi
mov    %r12,%rdi
mov    %r14d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1151 <is_c_type+0x41>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1130 <is_c_type+0x20>
xor    %eax,%eax
jmp    1156 <is_c_type+0x46>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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