int strcmp(const char *a_, const char *b_) {
  const unsigned char *a = (const unsigned char *)a_;
  const unsigned char *b = (const unsigned char *)b_;
  if (a != ((void *)0)) {
  } else {
    debug_panic("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/Coding-Headache/CNOS/refs/"
                "heads/master/OS_Dev/pintos/lib/string.c",
                78, __func__, "assertion `%s' failed.", "a != NULL");
  };
  if (b != ((void *)0)) {
  } else {
    debug_panic("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/Coding-Headache/CNOS/refs/"
                "heads/master/OS_Dev/pintos/lib/string.c",
                79, __func__, "assertion `%s' failed.", "b != NULL");
  };
  while (*a != '\0' && *a == *b) {
    a++;
    b++;
  }
  return *a < *b ? -1 : *a > *b;
}


x86 assembly (clang, -O0):
<strcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1140 <strcmp+0x30>
jmp    1168 <strcmp+0x58>
lea    0xeb9(%rip),%rdi
mov    $0x4e,%esi
lea    0xf49(%rip),%rdx
lea    0xf49(%rip),%rcx
lea    0xf59(%rip),%r8
mov    $0x0,%al
call   1030 <debug_panic@plt>
cmpq   $0x0,-0x20(%rbp)
je     1178 <strcmp+0x68>
jmp    11a0 <strcmp+0x90>
lea    0xe81(%rip),%rdi
mov    $0x4f,%esi
lea    0xf11(%rip),%rdx
lea    0xf11(%rip),%rcx
lea    0xf2b(%rip),%r8
mov    $0x0,%al
call   1030 <debug_panic@plt>
jmp    11a5 <strcmp+0x95>
mov    -0x18(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     11d0 <strcmp+0xc0>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
mov    -0x20(%rbp),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11e0 <strcmp+0xd0>
jmp    11fd <strcmp+0xed>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11a5 <strcmp+0x95>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
mov    -0x20(%rbp),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
jge    1220 <strcmp+0x110>
mov    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    123b <strcmp+0x12b>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
mov    -0x20(%rbp),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
je     115e <strcmp+0x4e>
test   %r14,%r14
je     118b <strcmp+0x7b>
mov    (%rbx),%al
test   %al,%al
je     1144 <strcmp+0x34>
add    $0x1,%rbx
xchg   %ax,%ax
cmp    (%r14),%al
jne    1146 <strcmp+0x36>
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <strcmp+0x20>
xor    %eax,%eax
xor    %ecx,%ecx
cmp    (%r14),%al
seta   %cl
mov    $0xffffffff,%eax
cmovae %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe9b(%rip),%rdi
lea    0xf30(%rip),%rdx
lea    0xf30(%rip),%rcx
lea    0xf40(%rip),%r8
mov    $0x4e,%esi
xor    %eax,%eax
call   1030 <debug_panic@plt>
test   %r14,%r14
jne    1124 <strcmp+0x14>
lea    0xe6e(%rip),%rdi
lea    0xf03(%rip),%rdx
lea    0xf03(%rip),%rcx
lea    0xf1d(%rip),%r8
mov    $0x4f,%esi
xor    %eax,%eax
call   1030 <debug_panic@plt>
jmp    1124 <strcmp+0x14>

LLVM IR (-O0):
@.str = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Coding-Headache/CNOS/refs/heads/master/OS_Dev/pintos/lib/string.c\00"
@__func__.strcmp = [7 x i8] c"strcmp\00"
@.str.1 = [23 x i8] c"assertion `%s' failed.\00"
@.str.2 = [10 x i8] c"a != NULL\00"
@.str.3 = [10 x i8] c"b != NULL\00"
define i32 @strcmp(i8* %0, i8* %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** %5
%8 = load i8*, i8** %4
store i8* %8, i8** %6
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
br label %14
12: ; preds = %2
%13 = call i32 (i8*, i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @debug_panic to i32 (i8*, i32, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str, i64 0, i64 0), i32 78, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @__func__.strcmp, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %11
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %18
17: ; preds = %14
br label %20
18: ; preds = %14
%19 = call i32 (i8*, i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @debug_panic to i32 (i8*, i32, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str, i64 0, i64 0), i32 79, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @__func__.strcmp, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %17
br label %21
21: ; preds = %36, %20
%22 = load i8*, i8** %5
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %21
%27 = load i8*, i8** %5
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = load i8*, i8** %6
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = icmp eq i32 %29, %32
br label %34
34: ; preds = %26, %21
%35 = phi i1 [ false, %21 ], [ %33, %26 ]
br i1 %35, label %36, label %41
36: ; preds = %34
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %5
%39 = load i8*, i8** %6
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %6
br label %21
41: ; preds = %34
%42 = load i8*, i8** %5
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = load i8*, i8** %6
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = icmp slt i32 %44, %47
br i1 %48, label %49, label %50
49: ; preds = %41
br label %59
50: ; preds = %41
%51 = load i8*, i8** %5
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = load i8*, i8** %6
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = icmp sgt i32 %53, %56
%58 = zext i1 %57 to i32
br label %59
59: ; preds = %50, %49
%60 = phi i32 [ -1, %49 ], [ %58, %50 ]
ret i32 %60
}

LLVM IR (-O2):
@.str = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Coding-Headache/CNOS/refs/heads/master/OS_Dev/pintos/lib/string.c\00"
@__func__.strcmp = [7 x i8] c"strcmp\00"
@.str.1 = [23 x i8] c"assertion `%s' failed.\00"
@.str.2 = [10 x i8] c"a != NULL\00"
@.str.3 = [10 x i8] c"b != NULL\00"
define i32 @strcmp(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @debug_panic to i32 (i8*, i32, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str, i64 0, i64 0), i32 78, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @__func__.strcmp, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %6
6: ; preds = %2, %4
%7 = icmp eq i8* %1, null
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @debug_panic to i32 (i8*, i32, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str, i64 0, i64 0), i32 79, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @__func__.strcmp, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %10
10: ; preds = %6, %8
%11 = load i8, i8* %0
%12 = icmp eq i8 %11, 0
br i1 %12, label %24, label %13
13: ; preds = %10, %19
%14 = phi i8 [ %22, %19 ], [ %11, %10 ]
%15 = phi i8* [ %21, %19 ], [ %1, %10 ]
%16 = phi i8* [ %20, %19 ], [ %0, %10 ]
%17 = load i8, i8* %15
%18 = icmp eq i8 %14, %17
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = getelementptr inbounds i8, i8* %16, i64 1
%21 = getelementptr inbounds i8, i8* %15, i64 1
%22 = load i8, i8* %20
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %13
24: ; preds = %13, %19, %10
%25 = phi i8* [ %1, %10 ], [ %21, %19 ], [ %15, %13 ]
%26 = phi i8 [ 0, %10 ], [ 0, %19 ], [ %14, %13 ]
%27 = load i8, i8* %25
%28 = icmp ult i8 %26, %27
%29 = icmp ugt i8 %26, %27
%30 = zext i1 %29 to i32
%31 = select i1 %28, i32 -1, i32 %30
ret i32 %31
}