#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 strlen(char const *);
char *strstr(char const *, char const *);
const char *field_in_record(const char *field, const char *record) {
  const char *curr = 0, *next = 0;
  int flen = strlen(field);
  for (curr = record; curr != 0; curr = next) {
    next = strstr(curr, field);
    if (next) {
      char s = (next == record ? 0 : next[-1]);
      char e = next[flen + 1];
      if ((s == 0 || s == ',' || s == ' ') &&
          (e == 0 || e == ',' || e == ' ')) {
        return next;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<field_in_record>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1229 <field_in_record+0x109>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1217 <field_in_record+0xf7>
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1193 <field_in_record+0x73>
xor    %eax,%eax
mov    %eax,-0x34(%rbp)
jmp    119e <field_in_record+0x7e>
mov    -0x28(%rbp),%rax
movsbl -0x1(%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %al,-0x2d(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x2e(%rbp)
movsbl -0x2d(%rbp),%eax
cmp    $0x0,%eax
je     11de <field_in_record+0xbe>
movsbl -0x2d(%rbp),%eax
cmp    $0x2c,%eax
je     11de <field_in_record+0xbe>
movsbl -0x2d(%rbp),%eax
cmp    $0x20,%eax
jne    1212 <field_in_record+0xf2>
movsbl -0x2e(%rbp),%eax
cmp    $0x0,%eax
je     1205 <field_in_record+0xe5>
movsbl -0x2e(%rbp),%eax
cmp    $0x2c,%eax
je     1205 <field_in_record+0xe5>
movsbl -0x2e(%rbp),%eax
cmp    $0x20,%eax
jne    1212 <field_in_record+0xf2>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1231 <field_in_record+0x111>
jmp    1217 <field_in_record+0xf7>
jmp    121c <field_in_record+0xfc>
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1154 <field_in_record+0x34>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<field_in_record>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %rbx,%rbx
je     1198 <field_in_record+0x78>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     1198 <field_in_record+0x78>
movslq %ebp,%rbp
movabs $0x100100000001,%r15
jmp    1170 <field_in_record+0x50>
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     1198 <field_in_record+0x78>
cmp    %rbx,%rax
je     1185 <field_in_record+0x65>
movzbl -0x1(%rax),%ecx
cmp    $0x2c,%rcx
ja     1160 <field_in_record+0x40>
bt     %rcx,%r15
jae    1160 <field_in_record+0x40>
movzbl 0x1(%rax,%rbp,1),%ecx
cmp    $0x2c,%rcx
ja     1160 <field_in_record+0x40>
bt     %rcx,%r15
jae    1160 <field_in_record+0x40>
jmp    119a <field_in_record+0x7a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @field_in_record(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8
%10 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* null, i8** %6
store i8* null, i8** %7
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %8
%13 = load i8*, i8** %5
store i8* %13, i8** %6
br label %14
14: ; preds = %69, %2
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %71
17: ; preds = %14
%18 = load i8*, i8** %6
%19 = load i8*, i8** %4
%20 = call i8* @strstr(i8* %18, i8* %19)
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %68
23: ; preds = %17
%24 = load i8*, i8** %7
%25 = load i8*, i8** %5
%26 = icmp eq i8* %24, %25
br i1 %26, label %27, label %28
27: ; preds = %23
br label %33
28: ; preds = %23
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 -1
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
br label %33
33: ; preds = %28, %27
%34 = phi i32 [ 0, %27 ], [ %32, %28 ]
%35 = trunc i32 %34 to i8
store i8 %35, i8* %9
%36 = load i8*, i8** %7
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
%41 = load i8, i8* %40
store i8 %41, i8* %10
%42 = load i8, i8* %9
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 0
br i1 %44, label %53, label %45
45: ; preds = %33
%46 = load i8, i8* %9
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 44
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = load i8, i8* %9
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 32
br i1 %52, label %53, label %67
53: ; preds = %49, %45, %33
%54 = load i8, i8* %10
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 0
br i1 %56, label %65, label %57
57: ; preds = %53
%58 = load i8, i8* %10
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 44
br i1 %60, label %65, label %61
61: ; preds = %57
%62 = load i8, i8* %10
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 32
br i1 %64, label %65, label %67
65: ; preds = %61, %57, %53
%66 = load i8*, i8** %7
store i8* %66, i8** %3
br label %72
67: ; preds = %61, %49
br label %68
68: ; preds = %67, %17
br label %69
69: ; preds = %68
%70 = load i8*, i8** %7
store i8* %70, i8** %6
br label %14
71: ; preds = %14
store i8* null, i8** %3
br label %72
72: ; preds = %71, %65
%73 = load i8*, i8** %3
ret i8* %73
}

LLVM IR (-O2):
define i8* @field_in_record(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp eq i8* %1, null
br i1 %4, label %22, label %5
5: ; preds = %2
%6 = add nsw i32 %3, 1
%7 = sext i32 %6 to i64
%8 = tail call i8* @strstr(i8* %1, i8* dereferenceable(1) %0)
%9 = icmp eq i8* %8, null
br i1 %9, label %22, label %10
10: ; preds = %5, %19
%11 = phi i8* [ %20, %19 ], [ %8, %5 ]
%12 = icmp eq i8* %11, %1
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = getelementptr inbounds i8, i8* %11, i64 -1
%15 = load i8, i8* %14
switch i8 %15, label %19 [
i8 44, label %16
i8 32, label %16
i8 0, label %16
]
16: ; preds = %10, %13, %13, %13
%17 = getelementptr inbounds i8, i8* %11, i64 %7
%18 = load i8, i8* %17
switch i8 %18, label %19 [
i8 44, label %22
i8 32, label %22
i8 0, label %22
]
19: ; preds = %16, %13
%20 = tail call i8* @strstr(i8* %11, i8* dereferenceable(1) %0)
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %10
22: ; preds = %16, %16, %16, %19, %5, %2
%23 = phi i8* [ null, %2 ], [ null, %5 ], [ null, %19 ], [ %11, %16 ], [ %11, %16 ], [ %11, %16 ]
ret i8* %23
}