#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 */
size_t strlen(char *);
int string_contains(char *line, char c) {
  int i;
  size_t len = strlen(line);
  for (i = 0; i < len; i++) {
    if (line[i] == c)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<string_contains>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    117b <string_contains+0x6b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    1168 <string_contains+0x58>
movl   $0x1,-0x4(%rbp)
jmp    1182 <string_contains+0x72>
jmp    116d <string_contains+0x5d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1136 <string_contains+0x26>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_contains>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %rax,%rax
je     113f <string_contains+0x2f>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %bpl,(%rbx,%rcx,1)
je     1143 <string_contains+0x33>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1130 <string_contains+0x20>
xor    %eax,%eax
jmp    1148 <string_contains+0x38>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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