#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*/ m_strcat(char *, char *);
int /*<<< orphan*/ memset(char *, char, size_t);
int /*<<< orphan*/ sprintf(char *, char *, size_t);
int /*<<< orphan*/ strcpy(char *, char *);
size_t strlen(char const *);
char *get_mismatch(char *match, const char *seq, const char *base, char *pos) {
  if (pos[0] == 0) {
    strcpy(match, "\n");
    return match;
  }
  size_t i = 0, temp = 0, first = 0;
  char num[30] = {'\0'};
  for (i = 0; i < strlen(seq); i++) {
    if (*(seq + i) != *(base + i)) {
      temp = i - first;
      sprintf(num, "%zu", temp);
      first = i;
      m_strcat(match, num);
      match[strlen(match)] = *(seq + i);
      memset(num, '\0', strlen(num));
    }
  }
  match[strlen(match)] = '\n';
  return match;
}


x86 assembly (clang, -O0):
<get_mismatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1198 <get_mismatch+0x48>
mov    -0x10(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12c9 <get_mismatch+0x179>
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
cmp    %rcx,%rax
jae    129f <get_mismatch+0x14f>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1289 <get_mismatch+0x139>
mov    -0x30(%rbp),%rax
sub    -0x40(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xdde(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1060 <m_strcat@plt>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x79(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x79(%rbp),%dl
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
mov    %dl,(%rax,%rcx,1)
lea    -0x60(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x70(%rbp),%rdi
mov    %rax,%rdx
xor    %esi,%esi
call   1050 <memset@plt>
jmp    128e <get_mismatch+0x13e>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11c8 <get_mismatch+0x78>
mov    -0x10(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
movb   $0xa,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mismatch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r15
cmpb   $0x0,(%rcx)
je     1224 <get_mismatch+0xd4>
mov    %rsi,%r13
xorps  %xmm0,%xmm0
movups %xmm0,0xe(%rsp)
movaps %xmm0,(%rsp)
mov    (%rsi),%al
test   %al,%al
je     1215 <get_mismatch+0xc5>
mov    %rdx,%rbx
xor    %r14d,%r14d
xor    %r12d,%r12d
cmp    (%rbx,%r12,1),%al
je     11f2 <get_mismatch+0xa2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdx
sub    %r14,%rdx
mov    %rsp,%r14
mov    %r14,%rdi
lea    0xe4f(%rip),%rsi
call   1070 <sprintf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <m_strcat@plt>
mov    %rbx,%rbp
mov    0x0(%r13,%r12,1),%bl
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %bl,(%r15,%rax,1)
mov    %rbp,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %rax,%rdx
call   1050 <memset@plt>
mov    %r12,%r14
lea    0x1(%r12),%rbp
mov    %r13,%rdi
call   1040 <strlen@plt>
cmp    %rax,%rbp
jae    1215 <get_mismatch+0xc5>
movzbl 0x1(%r13,%r12,1),%eax
mov    %rbp,%r12
cmp    (%rbx,%r12,1),%al
jne    11a0 <get_mismatch+0x50>
jmp    11f2 <get_mismatch+0xa2>
mov    %r15,%rdi
call   1040 <strlen@plt>
movb   $0xa,(%r15,%rax,1)
jmp    1233 <get_mismatch+0xe3>
lea    0xdd5(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [4 x i8] c"%zu\00"
define i8* @get_mismatch(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca [30 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%14 = load i8*, i8** %9
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %4
%20 = load i8*, i8** %6
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = load i8*, i8** %6
store i8* %22, i8** %5
br label %75
23: ; preds = %4
store i64 0, i64* %10
store i64 0, i64* %11
store i64 0, i64* %12
%24 = bitcast [30 x i8]* %13 to i8*
store i64 0, i64* %10
br label %25
25: ; preds = %66, %23
%26 = load i64, i64* %10
%27 = load i8*, i8** %7
%28 = call i64 @strlen(i8* %27)
%29 = icmp ult i64 %26, %28
br i1 %29, label %30, label %69
30: ; preds = %25
%31 = load i8*, i8** %7
%32 = load i64, i64* %10
%33 = getelementptr inbounds i8, i8* %31, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = load i8*, i8** %8
%37 = load i64, i64* %10
%38 = getelementptr inbounds i8, i8* %36, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %35, %40
br i1 %41, label %42, label %65
42: ; preds = %30
%43 = load i64, i64* %10
%44 = load i64, i64* %12
%45 = sub i64 %43, %44
store i64 %45, i64* %11
%46 = getelementptr inbounds [30 x i8], [30 x i8]* %13, i64 0, i64 0
%47 = load i64, i64* %11
%48 = call i32 @sprintf(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %47)
%49 = load i64, i64* %10
store i64 %49, i64* %12
%50 = load i8*, i8** %6
%51 = getelementptr inbounds [30 x i8], [30 x i8]* %13, i64 0, i64 0
%52 = call i32 @m_strcat(i8* %50, i8* %51)
%53 = load i8*, i8** %7
%54 = load i64, i64* %10
%55 = getelementptr inbounds i8, i8* %53, i64 %54
%56 = load i8, i8* %55
%57 = load i8*, i8** %6
%58 = load i8*, i8** %6
%59 = call i64 @strlen(i8* %58)
%60 = getelementptr inbounds i8, i8* %57, i64 %59
store i8 %56, i8* %60
%61 = getelementptr inbounds [30 x i8], [30 x i8]* %13, i64 0, i64 0
%62 = getelementptr inbounds [30 x i8], [30 x i8]* %13, i64 0, i64 0
%63 = call i64 @strlen(i8* %62)
%64 = call i32 @memset(i8* %61, i8 signext 0, i64 %63)
br label %65
65: ; preds = %42, %30
br label %66
66: ; preds = %65
%67 = load i64, i64* %10
%68 = add i64 %67, 1
store i64 %68, i64* %10
br label %25
69: ; preds = %25
%70 = load i8*, i8** %6
%71 = load i8*, i8** %6
%72 = call i64 @strlen(i8* %71)
%73 = getelementptr inbounds i8, i8* %70, i64 %72
store i8 10, i8* %73
%74 = load i8*, i8** %6
store i8* %74, i8** %5
br label %75
75: ; preds = %69, %19
%76 = load i8*, i8** %5
ret i8* %76
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [4 x i8] c"%zu\00"
define i8* @get_mismatch(i8* returned %0, i8* nocapture %1, i8* nocapture %2, i8* nocapture %3) {
%5 = alloca [30 x i8]
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %42
10: ; preds = %4
%11 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%12 = load i8, i8* %1
%13 = icmp eq i8 %12, 0
br i1 %13, label %39, label %14
14: ; preds = %10, %36
%15 = phi i8 [ %38, %36 ], [ %12, %10 ]
%16 = phi i64 [ %32, %36 ], [ 0, %10 ]
%17 = phi i64 [ %33, %36 ], [ 0, %10 ]
%18 = getelementptr inbounds i8, i8* %2, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %15, %19
br i1 %20, label %31, label %21
21: ; preds = %14
%22 = getelementptr inbounds i8, i8* %1, i64 %17
%23 = sub i64 %17, %16
%24 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %23)
%25 = call i32 @m_strcat(i8* %0, i8* %11)
%26 = load i8, i8* %22
%27 = call i64 @strlen(i8* dereferenceable(1) %0)
%28 = getelementptr inbounds i8, i8* %0, i64 %27
store i8 %26, i8* %28
%29 = call i64 @strlen(i8* %11)
%30 = call i32 @memset(i8* %11, i8 signext 0, i64 %29)
br label %31
31: ; preds = %14, %21
%32 = phi i64 [ %17, %21 ], [ %16, %14 ]
%33 = add nuw i64 %17, 1
%34 = call i64 @strlen(i8* dereferenceable(1) %1)
%35 = icmp ult i64 %33, %34
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = getelementptr inbounds i8, i8* %1, i64 %33
%38 = load i8, i8* %37
br label %14
39: ; preds = %31, %10
%40 = call i64 @strlen(i8* dereferenceable(1) %0)
%41 = getelementptr inbounds i8, i8* %0, i64 %40
store i8 10, i8* %41
br label %42
42: ; preds = %39, %8
ret i8* %0
}