#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_strbeginswith(char *, char *, char **);
scalar_t__ strcmp(char *, char *);
void test_mx_strbeginswith(void) {
  char *end = NULL;
  assert(mx_strbeginswith("blahblubb", "", NULL));
  assert(mx_strbeginswith("blahblubb", "", &end));
  assert(strcmp(end, "blahblubb") == 0);
  assert(mx_strbeginswith("BlahBlubb", "Blah", &end));
  assert(strcmp(end, "Blubb") == 0);
  assert(mx_strbeginswith("blahblubb", "blahblubb", &end));
  assert(*end == 0);
  end = NULL;
  assert(mx_strbeginswith("blahblubb", "blubb", &end) == 0);
  assert(end == NULL);
  assert(mx_strbeginswith("blah", "blahblubb", &end) == 0);
  assert(end == NULL);
  assert(mx_strbeginswith("Blahblubb", "blah", &end) == 0);
  assert(end == NULL);
  assert(mx_strbeginswith("", "blah", &end) == 0);
  assert(end == NULL);
}


x86 assembly (clang, -O0):
<test_mx_strbeginswith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
lea    0xeb9(%rip),%rdi
lea    0xec5(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <mx_strbeginswith@plt>
mov    %eax,%edi
call   1050 <assert@plt>
lea    0xe9b(%rip),%rdi
lea    0xea7(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1030 <mx_strbeginswith@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe66(%rip),%rdi
lea    0xe69(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1030 <mx_strbeginswith@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe1d(%rip),%rsi
lea    -0x8(%rbp),%rdx
mov    %rsi,%rdi
call   1030 <mx_strbeginswith@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movq   $0x0,-0x8(%rbp)
lea    0xde4(%rip),%rdi
lea    0xdff(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1030 <mx_strbeginswith@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xdc4(%rip),%rdi
lea    0xda4(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1030 <mx_strbeginswith@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xd90(%rip),%rdi
lea    0xd84(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1030 <mx_strbeginswith@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xd4c(%rip),%rdi
lea    0xd4b(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1030 <mx_strbeginswith@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_mx_strbeginswith>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movq   $0x0,(%rsp)
lea    0xeb9(%rip),%rbx
lea    0xec5(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <mx_strbeginswith@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <mx_strbeginswith@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
lea    0xe6f(%rip),%rdi
lea    0xe72(%rip),%rsi
mov    %r15,%rdx
call   1030 <mx_strbeginswith@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    (%rsp),%rdi
lea    0xe52(%rip),%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1030 <mx_strbeginswith@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    (%rsp),%rax
xor    %edi,%edi
cmpb   $0x0,(%rax)
sete   %dil
call   1050 <assert@plt>
movq   $0x0,(%rsp)
lea    0xe1d(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1030 <mx_strbeginswith@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%rsp)
sete   %dil
call   1050 <assert@plt>
lea    0xde5(%rip),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1030 <mx_strbeginswith@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%rsp)
sete   %dil
call   1050 <assert@plt>
lea    0xdb8(%rip),%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <mx_strbeginswith@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%rsp)
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <mx_strbeginswith@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%rsp)
sete   %dil
call   1050 <assert@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
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 = [6 x i8] c"blubb\00"
@.str.6 = [5 x i8] c"blah\00"
@.str.7 = [10 x i8] c"Blahblubb\00"
define void @test_mx_strbeginswith() {
%1 = alloca i8*
store i8* null, i8** %1
%2 = call i32 @mx_strbeginswith(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_strbeginswith(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_strbeginswith(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_strbeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %1)
%19 = call i32 @assert(i32 %18)
%20 = load i8*, i8** %1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
store i8* null, i8** %1
%26 = call i32 @mx_strbeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %1)
%27 = icmp eq i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i8*, i8** %1
%31 = icmp eq i8* %30, null
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = call i32 @mx_strbeginswith(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %1)
%35 = icmp eq i32 %34, 0
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i8*, i8** %1
%39 = icmp eq i8* %38, null
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = call i32 @mx_strbeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %1)
%43 = icmp eq i32 %42, 0
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = load i8*, i8** %1
%47 = icmp eq i8* %46, null
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = call i32 @mx_strbeginswith(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.6, i64 0, i64 0), i8** %1)
%51 = icmp eq i32 %50, 0
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = load i8*, i8** %1
%55 = icmp eq i8* %54, null
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
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 = [6 x i8] c"blubb\00"
@.str.6 = [5 x i8] c"blah\00"
@.str.7 = [10 x i8] c"Blahblubb\00"
define void @test_mx_strbeginswith() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%3 = tail call i32 @mx_strbeginswith(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_strbeginswith(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_strbeginswith(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_strbeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %1)
%20 = call i32 @assert(i32 %19)
%21 = load i8*, i8** %1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
store i8* null, i8** %1
%26 = call i32 @mx_strbeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %1)
%27 = icmp eq i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i8*, i8** %1
%31 = icmp eq i8* %30, null
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = call i32 @mx_strbeginswith(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %1)
%35 = icmp eq i32 %34, 0
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i8*, i8** %1
%39 = icmp eq i8* %38, null
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = call i32 @mx_strbeginswith(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %1)
%43 = icmp eq i32 %42, 0
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = load i8*, i8** %1
%47 = icmp eq i8* %46, null
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = call i32 @mx_strbeginswith(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.6, i64 0, i64 0), i8** %1)
%51 = icmp eq i32 %50, 0
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = load i8*, i8** %1
%55 = icmp eq i8* %54, null
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
ret void
}