#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*/ errAbort(char *);
char *findStringEnd(char *start, char endC) {
  char c;
  char *s = start;
  for (;;) {
    c = *s;
    if (c == endC)
      return s;
    else if (c == 0)
      errAbort("Unterminated string");
    ++s;
  }
}


x86 assembly (clang, -O0):
<findStringEnd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0xa(%rbp)
movsbl -0xa(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    114d <findStringEnd+0x3d>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret
movsbl -0xa(%rbp),%eax
cmp    $0x0,%eax
jne    1166 <findStringEnd+0x56>
lea    0xe9f(%rip),%rdi
call   1030 <errAbort@plt>
jmp    116b <findStringEnd+0x5b>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112a <findStringEnd+0x1a>

x86 assembly (clang, -O2):
<findStringEnd>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
mov    (%rdi),%al
cmp    %bpl,%al
jne    1128 <findStringEnd+0x18>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xed1(%rip),%r14
jmp    114d <findStringEnd+0x3d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
cmp    %bpl,%al
je     1120 <findStringEnd+0x10>
test   %al,%al
jne    1140 <findStringEnd+0x30>
mov    %r14,%rdi
call   1030 <errAbort@plt>
jmp    1140 <findStringEnd+0x30>

LLVM IR (-O0):
@.str = [20 x i8] c"Unterminated string\00"
define i8* @findStringEnd(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8*
store i8* %0, i8** %3
store i8 %1, i8* %4
%7 = load i8*, i8** %3
store i8* %7, i8** %6
br label %8
8: ; preds = %25, %2
%9 = load i8*, i8** %6
%10 = load i8, i8* %9
store i8 %10, i8* %5
%11 = load i8, i8* %5
%12 = sext i8 %11 to i32
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %12, %14
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = load i8*, i8** %6
ret i8* %17
18: ; preds = %8
%19 = load i8, i8* %5
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @errAbort(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
br label %25
25: ; preds = %24
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %6
br label %8
}

LLVM IR (-O2):
@.str = [20 x i8] c"Unterminated string\00"
define i8* @findStringEnd(i8* %0, i8 signext %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, %1
br i1 %4, label %5, label %7
5: ; preds = %13, %2
%6 = phi i8* [ %0, %2 ], [ %14, %13 ]
ret i8* %6
7: ; preds = %2, %13
%8 = phi i8 [ %15, %13 ], [ %3, %2 ]
%9 = phi i8* [ %14, %13 ], [ %0, %2 ]
%10 = icmp eq i8 %8, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @errAbort(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %7, %11
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, %1
br i1 %16, label %5, label %7
}