#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 */
scalar_t__ tolower(char);
int nsubstring(char *s1, char *s2) {
  while (tolower(*s1) == tolower(*s2)) {
    if (!*(s1++))
      return 0;
    s2++;
  }
  if (*s1 == 0)
    return -1;
  return 1;
}


x86 assembly (clang, -O0):
<nsubstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jne    1181 <nsubstring+0x71>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmpb   $0x0,(%rax)
jne    1170 <nsubstring+0x60>
movl   $0x0,-0x4(%rbp)
jmp    11a4 <nsubstring+0x94>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <nsubstring+0x10>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    119d <nsubstring+0x8d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a4 <nsubstring+0x94>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nsubstring>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <tolower@plt>
mov    %rax,%r15
movsbl (%r14),%edi
call   1030 <tolower@plt>
cmp    %rax,%r15
jne    1167 <nsubstring+0x57>
add    $0x1,%r14
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
je     1171 <nsubstring+0x61>
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <tolower@plt>
mov    %rax,%r15
movsbl (%r14),%edi
call   1030 <tolower@plt>
add    $0x1,%r14
cmp    %rax,%r15
je     1140 <nsubstring+0x30>
cmpb   $0x1,(%rbx)
sbb    %eax,%eax
or     $0x1,%eax
jmp    1173 <nsubstring+0x63>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @nsubstring(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
br label %6
6: ; preds = %20, %2
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = call i64 @tolower(i8 signext %8)
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = call i64 @tolower(i8 signext %11)
%13 = icmp eq i64 %9, %12
br i1 %13, label %14, label %23
14: ; preds = %6
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
%17 = load i8, i8* %15
%18 = icmp ne i8 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %14
store i32 0, i32* %3
br label %30
20: ; preds = %14
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %5
br label %6
23: ; preds = %6
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 -1, i32* %3
br label %30
29: ; preds = %23
store i32 1, i32* %3
br label %30
30: ; preds = %29, %28, %19
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @nsubstring(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = tail call i64 @tolower(i8 signext %3)
%5 = load i8, i8* %1
%6 = tail call i64 @tolower(i8 signext %5)
%7 = icmp eq i64 %4, %6
br i1 %7, label %8, label %21
8: ; preds = %2, %13
%9 = phi i8* [ %15, %13 ], [ %1, %2 ]
%10 = phi i8* [ %14, %13 ], [ %0, %2 ]
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = getelementptr inbounds i8, i8* %9, i64 1
%16 = load i8, i8* %14
%17 = tail call i64 @tolower(i8 signext %16)
%18 = load i8, i8* %15
%19 = tail call i64 @tolower(i8 signext %18)
%20 = icmp eq i64 %17, %19
br i1 %20, label %8, label %21
21: ; preds = %13, %2
%22 = phi i8* [ %0, %2 ], [ %14, %13 ]
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
%25 = select i1 %24, i32 -1, i32 1
br label %26
26: ; preds = %8, %21
%27 = phi i32 [ %25, %21 ], [ 0, %8 ]
ret i32 %27
}