#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 strmi(char *str1, char *str2) {
  int i = 0;
  for (;; i++) {
    if (tolower(str1[i]) != tolower(str2[i]))
      return 0;
    if (str1[i] == '\0')
      return 1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<strmi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     1169 <strmi+0x59>
movl   $0x0,-0x4(%rbp)
jmp    119d <strmi+0x8d>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    118a <strmi+0x7a>
movl   $0x1,-0x4(%rbp)
jmp    119d <strmi+0x8d>
jmp    118f <strmi+0x7f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <strmi+0x17>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strmi>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
movsbl (%rdi),%edi
call   1030 <tolower@plt>
mov    %rax,%rbp
movsbl (%r14),%edi
call   1030 <tolower@plt>
xor    %r15d,%r15d
cmp    %rax,%rbp
jne    1170 <strmi+0x60>
mov    $0x1,%ebx
nop
cmpb   $0x0,-0x1(%r12,%rbx,1)
je     116a <strmi+0x5a>
movsbl (%r12,%rbx,1),%edi
call   1030 <tolower@plt>
mov    %rax,%rbp
movsbl (%r14,%rbx,1),%edi
call   1030 <tolower@plt>
add    $0x1,%rbx
cmp    %rax,%rbp
je     1140 <strmi+0x30>
jmp    1170 <strmi+0x60>
mov    $0x1,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @strmi(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 %16, label %22
8: ; preds = %16
%9 = getelementptr inbounds i8, i8* %0, i64 %21
%10 = load i8, i8* %9
%11 = tail call i64 @tolower(i8 signext %10)
%12 = getelementptr inbounds i8, i8* %1, i64 %21
%13 = load i8, i8* %12
%14 = tail call i64 @tolower(i8 signext %13)
%15 = icmp eq i64 %11, %14
br i1 %15, label %16, label %22
16: ; preds = %2, %8
%17 = phi i64 [ %21, %8 ], [ 0, %2 ]
%18 = phi i8* [ %9, %8 ], [ %0, %2 ]
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
%21 = add nuw i64 %17, 1
br i1 %20, label %22, label %8
22: ; preds = %8, %16, %2
%23 = phi i32 [ 0, %2 ], [ 1, %16 ], [ 0, %8 ]
ret i32 %23
}