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 = malloc((unsigned)(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),%eax
add    $0x1,%eax
mov    %eax,%eax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%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,%r14
movabs $0xffffffff00000000,%r12
ff ff ff
mov    (%rdi),%r15
lea    0x1(%r15),%r13
mov    %r15,%rax
shl    $0x20,%rax
mov    %r12,%rbp
sub    %rax,%rbp
lea    0x2(%r15),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x0(%r13),%eax
add    $0x1,%r13
add    %r12,%rbp
add    $0x1,%rbx
cmp    $0x27,%al
je     1199 <findchrconst+0x69>
test   %al,%al
jne    1170 <findchrconst+0x40>
lea    0xe71(%rip),%rdi
xor    %eax,%eax
call   1050 <error@plt>
mov    (%r14),%r15
mov    %ebx,%eax
sub    %r15d,%eax
cmp    $0x4,%eax
je     11b1 <findchrconst+0x81>
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1050 <error@plt>
sub    %r15d,%ebx
mov    %rbx,%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    (%rsp),%rax
mov    %rbx,(%rax)
mov    (%r14),%rsi
imul   %r15,%r12
sub    %rbp,%r12
sar    $0x20,%r12
mov    %rbx,%rdi
mov    %r12,%rdx
call   1030 <strncpy@plt>
movb   $0x0,(%rbx,%r12,1)
mov    %r13,(%r14)
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 = zext i32 %47 to i64
%49 = call i8* @malloc(i64 %48)
%50 = load i8**, i8*** %4
store i8* %49, i8** %50
%51 = load i8**, i8*** %4
%52 = load i8*, i8** %51
%53 = load i8**, i8*** %3
%54 = load i8*, i8** %53
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = call i8* @strncpy(i8* %52, i8* %54, i64 %56)
%58 = load i8**, i8*** %4
%59 = load i8*, i8** %58
%60 = load i32, i32* %6
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
store i8 0, i8* %62
%63 = load i8*, i8** %5
%64 = load i8**, i8*** %3
store i8* %63, i8** %64
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 writeonly %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 i64 %16, 1
%23 = and i64 %22, 4294967295
%24 = tail call i8* @malloc(i64 %23)
store i8* %24, i8** %1
%25 = load i8*, i8** %0
%26 = shl i64 %16, 32
%27 = ashr exact i64 %26, 32
%28 = tail call i8* @strncpy(i8* dereferenceable(1) %24, i8* %25, i64 %27)
%29 = getelementptr inbounds i8, i8* %24, i64 %27
store i8 0, i8* %29
store i8* %13, i8** %0
ret void
}