#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*/ printf(char *, char);
char *strpbrk(char *, char *);
int main() {
  char *haystack = "The quick brown fox jumps over the lazy dog";
  char *cur = haystack;
  while (1) {
    cur = strpbrk(cur, "rho");
    if (cur == NULL) {
      break;
    } else {
      printf("found: %c\n", *cur);
      cur++;
    }
  };
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xedf(%rip),%rsi
call   1040 <strpbrk@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1166 <main+0x46>
jmp    118a <main+0x6a>
mov    -0x18(%rbp),%rax
lea    0xebf(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1142 <main+0x22>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xed5(%rip),%rbx
lea    0xefd(%rip),%r14
lea    0xef2(%rip),%r15
nopw   0x0(%rax,%rax,1)
movsbl (%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strpbrk@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"The quick brown fox jumps over the lazy dog\00"
@.str.1 = [4 x i8] c"rho\00"
@.str.2 = [11 x i8] c"found: %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %0, %17
%6 = load i8*, i8** %3
%7 = call i8* @strpbrk(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %5
br label %18
11: ; preds = %5
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8 signext %13)
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
br label %17
17: ; preds = %11
br label %5
18: ; preds = %10
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [44 x i8] c"The quick brown fox jumps over the lazy dog\00"
@.str.1 = [4 x i8] c"rho\00"
@.str.2 = [11 x i8] c"found: %c\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i8* [ %6, %1 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 1), %0 ]
%3 = load i8, i8* %2
%4 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8 signext %3)
%5 = getelementptr inbounds i8, i8* %2, i64 1
%6 = tail call i8* @strpbrk(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %1
8: ; preds = %1
ret i32 0
}