#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 *);
char *find(char *haystack, char needle) {
  int size;
  int answer;
  char row;
  char *base;
  int ct;
  size = strlen(haystack);
  for (ct = 0; ct < size; ct++) {
    if (haystack[ct] == needle) {
      answer = ct;
      break;
    }
  }
  if (answer == ct) {
    row = answer;
    base = &row;
    return base;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1177 <find+0x67>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    1164 <find+0x54>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1177 <find+0x67>
jmp    1169 <find+0x59>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1135 <find+0x25>
mov    -0x1c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    119e <find+0x8e>
mov    -0x1c(%rbp),%eax
mov    %al,-0x1d(%rbp)
lea    -0x1d(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a6 <find+0x96>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find>:
push   %rax
call   1030 <strlen@plt>
lea    0x7(%rsp),%rax
pop    %rcx
ret

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

LLVM IR (-O2):
define noalias i8* @find(i8* %0, i8 signext %1) {
%3 = alloca i8
%4 = tail call i32 @strlen(i8* %0)
ret i8* %3
}