#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__ toupper(unsigned char const);
const unsigned char *str_leftis(const unsigned char *buf, const char *left) {
  while (*left != '\0' && toupper(*left) == toupper(*buf)) {
    ++buf;
    ++left;
  }
  if (*left == '\0')
    return buf;
  return NULL;
}


x86 assembly (clang, -O0):
<str_leftis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1161 <str_leftis+0x51>
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1171 <str_leftis+0x61>
jmp    118e <str_leftis+0x7e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <str_leftis+0x10>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11ab <str_leftis+0x9b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <str_leftis+0xa3>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_leftis>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rsi),%al
test   %al,%al
je     1163 <str_leftis+0x53>
mov    %rsi,%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl %al,%edi
call   1030 <toupper@plt>
mov    %rax,%r15
movzbl (%r14),%edi
call   1030 <toupper@plt>
cmp    %rax,%r15
jne    115a <str_leftis+0x4a>
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <str_leftis+0x20>
jmp    1163 <str_leftis+0x53>
cmpb   $0x0,-0x1(%rbx)
je     1163 <str_leftis+0x53>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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