char *scan_diff_line(scan_ptr, set_start, set_length, limit, firstchar)
char *scan_ptr, **set_start;
int *set_length;
char *limit;
char firstchar;
{
  char *line_ptr = scan_ptr + 2;
  if (!(scan_ptr[0] == (firstchar) && scan_ptr[1] == ' '))
    fatal("Bad diff format; incorrect leading line chars");
  *set_start = line_ptr;
  while (*line_ptr != '\n')
    line_ptr++;
  if (line_ptr >= limit)
    fatal("Bad diff format; overflow in parse");
  *set_length = line_ptr - *set_start;
  return line_ptr + 1;
}


x86 assembly (clang, -O0):
<scan_diff_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8b,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %al,-0x21(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x21(%rbp),%ecx
cmp    %ecx,%eax
jne    115e <scan_diff_line+0x4e>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x20,%eax
je     116c <scan_diff_line+0x5c>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <fatal@plt>
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1198 <scan_diff_line+0x88>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1177 <scan_diff_line+0x67>
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jb     11b4 <scan_diff_line+0xa4>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <fatal@plt>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_diff_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
lea    0x2(%rdi),%rbp
movsbl (%rdi),%eax
movsbl %r8b,%ecx
cmp    %eax,%ecx
jne    113d <scan_diff_line+0x2d>
cmpb   $0x20,0x1(%r13)
je     114b <scan_diff_line+0x3b>
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1030 <fatal@plt>
mov    %rbp,(%r15)
add    $0x1,%r13d
mov    %rbp,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r13d
cmpb   $0xa,(%rbx)
lea    0x1(%rbx),%rbx
jne    1160 <scan_diff_line+0x50>
lea    -0x1(%rbx),%rax
cmp    %r12,%rax
jb     1187 <scan_diff_line+0x77>
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1030 <fatal@plt>
mov    (%r15),%rbp
sub    %ebp,%r13d
mov    %r13d,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Bad diff format; incorrect leading line chars\00"
@.str.1 = [35 x i8] c"Bad diff format; overflow in parse\00"
define i8* @scan_diff_line(i8* %0, i8** %1, i32* %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8
%11 = alloca i8*
%12 = trunc i32 %4 to i8
store i8* %0, i8** %6
store i8** %1, i8*** %7
store i32* %2, i32** %8
store i8* %3, i8** %9
store i8 %12, i8* %10
%13 = load i8*, i8** %6
%14 = getelementptr inbounds i8, i8* %13, i64 2
store i8* %14, i8** %11
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = load i8, i8* %10
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %18, %20
br i1 %21, label %22, label %28
22: ; preds = %5
%23 = load i8*, i8** %6
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 32
br i1 %27, label %30, label %28
28: ; preds = %22, %5
%29 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28, %22
%31 = load i8*, i8** %11
%32 = load i8**, i8*** %7
store i8* %31, i8** %32
br label %33
33: ; preds = %38, %30
%34 = load i8*, i8** %11
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 10
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i8*, i8** %11
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %11
br label %33
41: ; preds = %33
%42 = load i8*, i8** %11
%43 = load i8*, i8** %9
%44 = icmp uge i8* %42, %43
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %47
47: ; preds = %45, %41
%48 = load i8*, i8** %11
%49 = load i8**, i8*** %7
%50 = load i8*, i8** %49
%51 = ptrtoint i8* %48 to i64
%52 = ptrtoint i8* %50 to i64
%53 = sub i64 %51, %52
%54 = trunc i64 %53 to i32
%55 = load i32*, i32** %8
store i32 %54, i32* %55
%56 = load i8*, i8** %11
%57 = getelementptr inbounds i8, i8* %56, i64 1
ret i8* %57
}

LLVM IR (-O2):
@.str = [46 x i8] c"Bad diff format; incorrect leading line chars\00"
@.str.1 = [35 x i8] c"Bad diff format; overflow in parse\00"
define i8* @scan_diff_line(i8* %0, i8** nocapture %1, i32* nocapture writeonly %2, i8* readnone %3, i32 %4) {
%6 = getelementptr inbounds i8, i8* %0, i64 2
%7 = load i8, i8* %0
%8 = sext i8 %7 to i32
%9 = shl i32 %4, 24
%10 = ashr exact i32 %9, 24
%11 = icmp eq i32 %10, %8
br i1 %11, label %12, label %16
12: ; preds = %5
%13 = getelementptr inbounds i8, i8* %0, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 32
br i1 %15, label %18, label %16
16: ; preds = %12, %5
%17 = tail call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
store i8* %6, i8** %1
br label %19
19: ; preds = %19, %18
%20 = phi i8* [ %6, %18 ], [ %23, %19 ]
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 10
%23 = getelementptr inbounds i8, i8* %20, i64 1
br i1 %22, label %24, label %19
24: ; preds = %19
%25 = icmp ult i8* %20, %3
br i1 %25, label %29, label %26
26: ; preds = %24
%27 = tail call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%28 = load i8*, i8** %1
br label %29
29: ; preds = %26, %24
%30 = phi i8* [ %28, %26 ], [ %6, %24 ]
%31 = ptrtoint i8* %20 to i64
%32 = ptrtoint i8* %30 to i64
%33 = sub i64 %31, %32
%34 = trunc i64 %33 to i32
store i32 %34, i32* %2
ret i8* %23
}