void findchrconst(str, val) char **str;
char **val;
{
  char *p;
  int size;
  p = *str;
  do {
    p++;
  } while (*p && *p != '\'');
  if (*p == 0) {
    error("unterminated string constant");
  }
  p++;
  size = p - *str;
  if (size != 3) {
    error("empty char string");
  }
  *val = xmalloc(size + 1);
  (void)strncpy(*val, *str, size);
  (*val)[size] = 0;
  *str = p;
}


x86 assembly (clang, -O0):
<findchrconst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     117c <findchrconst+0x4c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    114b <findchrconst+0x1b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11a5 <findchrconst+0x75>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1050 <error@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
mov    %eax,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
je     11da <findchrconst+0xaa>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <error@plt>
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
mov    $0x0,%al
call   1040 <xmalloc@plt>
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
movslq -0x1c(%rbp),%rdx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findchrconst>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
mov    %rdi,%r15
movabs $0xffffffff00000000,%r12
ff ff ff
mov    (%rdi),%r14
lea    0x1(%r14),%r13
mov    %r14,%rax
shl    $0x20,%rax
mov    %r12,%rbp
sub    %rax,%rbp
mov    $0xfffffffe,%ebx
sub    %r14d,%ebx
nopl   0x0(%rax,%rax,1)
movzbl 0x0(%r13),%eax
add    $0x1,%r13
add    %r12,%rbp
add    $0xffffffff,%ebx
cmp    $0x27,%al
je     1198 <findchrconst+0x68>
test   %al,%al
jne    1170 <findchrconst+0x40>
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1050 <error@plt>
mov    (%r15),%r14
lea    (%r14,%rbx,1),%eax
cmp    $0xfffffffc,%eax
je     11af <findchrconst+0x7f>
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1050 <error@plt>
add    %r14d,%ebx
neg    %ebx
mov    %ebx,%edi
xor    %eax,%eax
call   1040 <xmalloc@plt>
movslq %eax,%rdi
mov    (%rsp),%rbx
mov    %rdi,(%rbx)
mov    (%r15),%rsi
imul   %r14,%r12
sub    %rbp,%r12
sar    $0x20,%r12
mov    %r12,%rdx
call   1030 <strncpy@plt>
mov    (%rbx),%rax
movb   $0x0,(%rax,%r12,1)
mov    %r13,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"unterminated string constant\00"
@.str.1 = [18 x i8] c"empty char string\00"
define void @findchrconst(i8** %0, i8** %1) {
%3 = alloca i8**
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
store i8** %0, i8*** %3
store i8** %1, i8*** %4
%7 = load i8**, i8*** %3
%8 = load i8*, i8** %7
store i8* %8, i8** %5
br label %9
9: ; preds = %22, %2
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %5
br label %12
12: ; preds = %9
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 39
br label %22
22: ; preds = %17, %12
%23 = phi i1 [ false, %12 ], [ %21, %17 ]
br i1 %23, label %9, label %24
24: ; preds = %22
%25 = load i8*, i8** %5
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 (i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, ...)*)(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %24
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
%34 = load i8*, i8** %5
%35 = load i8**, i8*** %3
%36 = load i8*, i8** %35
%37 = ptrtoint i8* %34 to i64
%38 = ptrtoint i8* %36 to i64
%39 = sub i64 %37, %38
%40 = trunc i64 %39 to i32
store i32 %40, i32* %6
%41 = load i32, i32* %6
%42 = icmp ne i32 %41, 3
br i1 %42, label %43, label %45
43: ; preds = %31
%44 = call i32 (i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %45
45: ; preds = %43, %31
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
%48 = call i32 (i32, ...) bitcast (i32 (...)* @xmalloc to i32 (i32, ...)*)(i32 %47)
%49 = sext i32 %48 to i64
%50 = inttoptr i64 %49 to i8*
%51 = load i8**, i8*** %4
store i8* %50, i8** %51
%52 = load i8**, i8*** %4
%53 = load i8*, i8** %52
%54 = load i8**, i8*** %3
%55 = load i8*, i8** %54
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = call i8* @strncpy(i8* %53, i8* %55, i64 %57)
%59 = load i8**, i8*** %4
%60 = load i8*, i8** %59
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
store i8 0, i8* %63
%64 = load i8*, i8** %5
%65 = load i8**, i8*** %3
store i8* %64, i8** %65
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"unterminated string constant\00"
@.str.1 = [18 x i8] c"empty char string\00"
define void @findchrconst(i8** nocapture %0, i8** nocapture %1) {
%3 = load i8*, i8** %0
br label %4
4: ; preds = %4, %2
%5 = phi i8* [ %3, %2 ], [ %6, %4 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %6
switch i8 %7, label %4 [
i8 0, label %8
i8 39, label %11
]
8: ; preds = %4
%9 = tail call i32 (i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, ...)*)(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%10 = load i8*, i8** %0
br label %11
11: ; preds = %4, %8
%12 = phi i8* [ %10, %8 ], [ %3, %4 ]
%13 = getelementptr inbounds i8, i8* %5, i64 2
%14 = ptrtoint i8* %13 to i64
%15 = ptrtoint i8* %12 to i64
%16 = sub i64 %14, %15
%17 = trunc i64 %16 to i32
%18 = icmp eq i32 %17, 3
br i1 %18, label %21, label %19
19: ; preds = %11
%20 = tail call i32 (i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %11
%22 = add nsw i32 %17, 1
%23 = tail call i32 (i32, ...) bitcast (i32 (...)* @xmalloc to i32 (i32, ...)*)(i32 %22)
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %1
%26 = load i8*, i8** %0
%27 = shl i64 %16, 32
%28 = ashr exact i64 %27, 32
%29 = tail call i8* @strncpy(i8* dereferenceable(1) %25, i8* %26, i64 %28)
%30 = load i8*, i8** %1
%31 = getelementptr inbounds i8, i8* %30, i64 %28
store i8 0, i8* %31
store i8* %13, i8** %0
ret void
}