#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 */
void __assert(char *, int);
int strncmp(const char *a, const char *b, int n) {
  ((n > 0) ? (void)0
           : __assert("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/Touhid18/Nachos/refs/"
                      "heads/master/bin/nachos/test/strncmp.c",
                      6));
  do {
    if (*a < *b)
      return -1;
    if (*a > *b)
      return 1;
    n--;
    a++;
    b++;
  } while (n > 0);
  return 0;
}


x86 assembly (clang, -O0):
<strncmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1132 <strncmp+0x22>
jmp    1143 <strncmp+0x33>
lea    0xec7(%rip),%rdi
mov    $0x6,%esi
call   1030 <__assert@plt>
jmp    1148 <strncmp+0x38>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jge    116a <strncmp+0x5a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11be <strncmp+0xae>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jle    118c <strncmp+0x7c>
movl   $0x1,-0x4(%rbp)
jmp    11be <strncmp+0xae>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     1148 <strncmp+0x38>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strncmp>:
push   %r15
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
test   %edx,%edx
jg     1132 <strncmp+0x22>
lea    0xed8(%rip),%rdi
mov    $0x6,%esi
call   1030 <__assert@plt>
add    $0x1,%ebx
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rax,1),%ecx
cmp    %cl,(%r15,%rax,1)
jl     115d <strncmp+0x4d>
jg     1164 <strncmp+0x54>
add    $0x1,%rax
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     1140 <strncmp+0x30>
xor    %eax,%eax
jmp    1169 <strncmp+0x59>
mov    $0xffffffff,%eax
jmp    1169 <strncmp+0x59>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [150 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Touhid18/Nachos/refs/heads/master/bin/nachos/test/strncmp.c\00"
define i32 @strncmp(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %3
br label %12
11: ; preds = %3
br label %12
12: ; preds = %11, %10
br label %13
13: ; preds = %38, %12
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = load i8*, i8** %6
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp slt i32 %16, %19
br i1 %20, label %21, label %22
21: ; preds = %13
store i32 -1, i32* %4
br label %42
22: ; preds = %13
%23 = load i8*, i8** %5
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = load i8*, i8** %6
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp sgt i32 %25, %28
br i1 %29, label %30, label %31
30: ; preds = %22
store i32 1, i32* %4
br label %42
31: ; preds = %22
%32 = load i32, i32* %7
%33 = add nsw i32 %32, -1
store i32 %33, i32* %7
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %5
%36 = load i8*, i8** %6
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %6
br label %38
38: ; preds = %31
%39 = load i32, i32* %7
%40 = icmp sgt i32 %39, 0
br i1 %40, label %13, label %41
41: ; preds = %38
store i32 0, i32* %4
br label %42
42: ; preds = %41, %30, %21
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
@.str = [150 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Touhid18/Nachos/refs/heads/master/bin/nachos/test/strncmp.c\00"
define i32 @strncmp(i8* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %6, label %5
5: ; preds = %3
tail call void @__assert(i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str, i64 0, i64 0), i32 6)
br label %6
6: ; preds = %3, %5
br label %7
7: ; preds = %6, %16
%8 = phi i8* [ %18, %16 ], [ %0, %6 ]
%9 = phi i8* [ %19, %16 ], [ %1, %6 ]
%10 = phi i32 [ %17, %16 ], [ %2, %6 ]
%11 = load i8, i8* %8
%12 = load i8, i8* %9
%13 = icmp slt i8 %11, %12
br i1 %13, label %21, label %14
14: ; preds = %7
%15 = icmp sgt i8 %11, %12
br i1 %15, label %21, label %16
16: ; preds = %14
%17 = add nsw i32 %10, -1
%18 = getelementptr inbounds i8, i8* %8, i64 1
%19 = getelementptr inbounds i8, i8* %9, i64 1
%20 = icmp sgt i32 %10, 1
br i1 %20, label %7, label %21
21: ; preds = %16, %14, %7
%22 = phi i32 [ -1, %7 ], [ 1, %14 ], [ 0, %16 ]
ret i32 %22
}