#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 */
int /*<<< orphan*/ assert(int);
int mx_stribeginswith(char *, char *, char **);
scalar_t__ strcmp(char *, char *);
void test_mx_stribeginswith(void) {
  char *end = NULL;
  assert(mx_stribeginswith("blahblubb", "", NULL));
  assert(mx_stribeginswith("blahblubb", "", &end));
  assert(strcmp(end, "blahblubb") == 0);
  assert(mx_stribeginswith("BlahBlubb", "Blah", &end));
  assert(strcmp(end, "Blubb") == 0);
  assert(mx_stribeginswith("BlahBlubb", "bLaH", &end));
  assert(strcmp(end, "Blubb") == 0);
  assert(mx_stribeginswith("blahblubb", "BlahBluBB", &end));
  assert(*end == 0);
  end = NULL;
  assert(mx_stribeginswith("blahblubb", "blubb", &end) == 0);
  assert(end == NULL);
  assert(mx_stribeginswith("blah", "blahblubb", &end) == 0);
  assert(end == NULL);
  assert(mx_stribeginswith("", "blah", &end) == 0);
  assert(end == NULL);
}


x86 assembly (clang, -O0):
<test_mx_stribeginswith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
lea    0xeb9(%rip),%rdi
lea    0xed9(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <mx_stribeginswith@plt>
mov    %eax,%edi
call   1040 <assert@plt>
lea    0xe9b(%rip),%rdi
lea    0xebb(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <mx_stribeginswith@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe66(%rip),%rdi
lea    0xe69(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <mx_stribeginswith@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe27(%rip),%rdi
lea    0xe2f(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <mx_stribeginswith@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xdde(%rip),%rdi
lea    0xdf5(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <mx_stribeginswith@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movq   $0x0,-0x8(%rbp)
lea    0xda1(%rip),%rdi
lea    0xd9e(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <mx_stribeginswith@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xd90(%rip),%rdi
lea    0xd61(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <mx_stribeginswith@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xd56(%rip),%rdi
lea    0xd50(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <mx_stribeginswith@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_mx_stribeginswith>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0xeb3(%rip),%r15
lea    0xed3(%rip),%r14
mov    %r15,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1050 <mx_stribeginswith@plt>
mov    %eax,%edi
call   1040 <assert@plt>
lea    0x8(%rsp),%r12
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <mx_stribeginswith@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xe66(%rip),%r13
lea    0xe69(%rip),%rsi
mov    %r13,%rdi
mov    %r12,%rdx
call   1050 <mx_stribeginswith@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    0x8(%rsp),%rdi
lea    0xe45(%rip),%rbx
mov    %rbx,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xe33(%rip),%rsi
mov    %r13,%rdi
mov    %r12,%rdx
call   1050 <mx_stribeginswith@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xe04(%rip),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
call   1050 <mx_stribeginswith@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    0x8(%rsp),%rax
xor    %edi,%edi
cmpb   $0x0,(%rax)
sete   %dil
call   1040 <assert@plt>
movq   $0x0,0x8(%rsp)
lea    0xdb5(%rip),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
call   1050 <mx_stribeginswith@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,0x8(%rsp)
sete   %dil
call   1040 <assert@plt>
lea    0xda9(%rip),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <mx_stribeginswith@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,0x8(%rsp)
sete   %dil
call   1040 <assert@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1050 <mx_stribeginswith@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,0x8(%rsp)
sete   %dil
call   1040 <assert@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"blahblubb\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [10 x i8] c"BlahBlubb\00"
@.str.3 = [5 x i8] c"Blah\00"
@.str.4 = [6 x i8] c"Blubb\00"
@.str.5 = [5 x i8] c"bLaH\00"
@.str.6 = [10 x i8] c"BlahBluBB\00"
@.str.7 = [6 x i8] c"blubb\00"
@.str.8 = [5 x i8] c"blah\00"
define void @test_mx_stribeginswith() {
%1 = alloca i8*
store i8* null, i8** %1
%2 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** null)
%3 = call i32 @assert(i32 %2)
%4 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %1)
%5 = call i32 @assert(i32 %4)
%6 = load i8*, i8** %1
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %1)
%12 = call i32 @assert(i32 %11)
%13 = load i8*, i8** %1
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %1)
%19 = call i32 @assert(i32 %18)
%20 = load i8*, i8** %1
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8** %1)
%26 = call i32 @assert(i32 %25)
%27 = load i8*, i8** %1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
store i8* null, i8** %1
%33 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8** %1)
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i8*, i8** %1
%38 = icmp eq i8* %37, null
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %1)
%42 = icmp eq i32 %41, 0
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load i8*, i8** %1
%46 = icmp eq i8* %45, null
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %1)
%50 = icmp eq i32 %49, 0
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = load i8*, i8** %1
%54 = icmp eq i8* %53, null
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"blahblubb\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [10 x i8] c"BlahBlubb\00"
@.str.3 = [5 x i8] c"Blah\00"
@.str.4 = [6 x i8] c"Blubb\00"
@.str.5 = [5 x i8] c"bLaH\00"
@.str.6 = [10 x i8] c"BlahBluBB\00"
@.str.7 = [6 x i8] c"blubb\00"
@.str.8 = [5 x i8] c"blah\00"
define void @test_mx_stribeginswith() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%3 = tail call i32 @mx_stribeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** null)
%4 = tail call i32 @assert(i32 %3)
%5 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %1)
%6 = call i32 @assert(i32 %5)
%7 = load i8*, i8** %1
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %1)
%13 = call i32 @assert(i32 %12)
%14 = load i8*, i8** %1
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %1)
%20 = call i32 @assert(i32 %19)
%21 = load i8*, i8** %1
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8** %1)
%27 = call i32 @assert(i32 %26)
%28 = load i8*, i8** %1
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
store i8* null, i8** %1
%33 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8** %1)
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i8*, i8** %1
%38 = icmp eq i8* %37, null
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %1)
%42 = icmp eq i32 %41, 0
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load i8*, i8** %1
%46 = icmp eq i8* %45, null
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = call i32 @mx_stribeginswith(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %1)
%50 = icmp eq i32 %49, 0
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = load i8*, i8** %1
%54 = icmp eq i8* %53, null
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
ret void
}