#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__ rdz_strcmp(char *, char *, char *, int /*<<< orphan*/);
char *rdz_string_expected(char *, char *, char *);
int /*<<< orphan*/ strlen(char *);
char *rdz_string_start(char *operator, char * result, char *expected) {
  int success =
      result && rdz_strcmp(operator, result, expected, strlen(expected)) == 0;
  if (operator[0] == '!') {
    return success ? rdz_string_expected(result, "not to start with", expected)
                   : NULL;
  }
  return success ? NULL
                 : rdz_string_expected(result, "to start with", expected);
}


x86 assembly (clang, -O0):
<rdz_string_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x25(%rbp)
je     1192 <rdz_string_start+0x62>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    %eax,%ecx
call   1030 <rdz_strcmp@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x21,%eax
jne    11ec <rdz_string_start+0xbc>
cmpl   $0x0,-0x24(%rbp)
je     11d4 <rdz_string_start+0xa4>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe3a(%rip),%rsi
call   1050 <rdz_string_expected@plt>
mov    %rax,-0x48(%rbp)
jmp    11df <rdz_string_start+0xaf>
xor    %eax,%eax
mov    %rax,-0x48(%rbp)
jmp    11df <rdz_string_start+0xaf>
mov    -0x48(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1221 <rdz_string_start+0xf1>
cmpl   $0x0,-0x24(%rbp)
je     1201 <rdz_string_start+0xd1>
xor    %eax,%eax
mov    %rax,-0x50(%rbp)
jmp    1219 <rdz_string_start+0xe9>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xdf4(%rip),%rsi
call   1050 <rdz_string_expected@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rdz_string_start>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
test   %rsi,%rsi
je     116e <rdz_string_start+0x3e>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
call   1030 <rdz_strcmp@plt>
cmpb   $0x21,(%rbx)
jne    117b <rdz_string_start+0x4b>
test   %rax,%rax
jne    1173 <rdz_string_start+0x43>
lea    0xe94(%rip),%rsi
jmp    1187 <rdz_string_start+0x57>
cmpb   $0x21,(%rbx)
jne    1180 <rdz_string_start+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
test   %rax,%rax
je     1173 <rdz_string_start+0x43>
lea    0xe7d(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <rdz_string_expected@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"not to start with\00"
@.str.1 = [14 x i8] c"to start with\00"
define i8* @rdz_string_start(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %19
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = load i8*, i8** %6
%14 = load i8*, i8** %7
%15 = load i8*, i8** %7
%16 = call i32 @strlen(i8* %15)
%17 = call i64 @rdz_strcmp(i8* %12, i8* %13, i8* %14, i32 %16)
%18 = icmp eq i64 %17, 0
br label %19
19: ; preds = %11, %3
%20 = phi i1 [ false, %3 ], [ %18, %11 ]
%21 = zext i1 %20 to i32
store i32 %21, i32* %8
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 33
br i1 %26, label %27, label %37
27: ; preds = %19
%28 = load i32, i32* %8
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load i8*, i8** %6
%32 = load i8*, i8** %7
%33 = call i8* @rdz_string_expected(i8* %31, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %32)
br label %35
34: ; preds = %27
br label %35
35: ; preds = %34, %30
%36 = phi i8* [ %33, %30 ], [ null, %34 ]
store i8* %36, i8** %4
br label %47
37: ; preds = %19
%38 = load i32, i32* %8
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %37
br label %45
41: ; preds = %37
%42 = load i8*, i8** %6
%43 = load i8*, i8** %7
%44 = call i8* @rdz_string_expected(i8* %42, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %41, %40
%46 = phi i8* [ null, %40 ], [ %44, %41 ]
store i8* %46, i8** %4
br label %47
47: ; preds = %45, %35
%48 = load i8*, i8** %4
ret i8* %48
}

LLVM IR (-O2):
@.str = [18 x i8] c"not to start with\00"
@.str.1 = [14 x i8] c"to start with\00"
define i8* @rdz_string_start(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = tail call i32 @strlen(i8* %2)
%7 = tail call i64 @rdz_strcmp(i8* %0, i8* %1, i8* %2, i32 %6)
%8 = icmp eq i64 %7, 0
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 33
br i1 %10, label %14, label %17
11: ; preds = %3
%12 = load i8, i8* %0
%13 = icmp eq i8 %12, 33
br i1 %13, label %20, label %18
14: ; preds = %5
br i1 %8, label %15, label %20
15: ; preds = %14
%16 = tail call i8* @rdz_string_expected(i8* %1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %20
17: ; preds = %5
br i1 %8, label %20, label %18
18: ; preds = %11, %17
%19 = tail call i8* @rdz_string_expected(i8* %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %20
20: ; preds = %11, %18, %17, %15, %14
%21 = phi i8* [ %16, %15 ], [ null, %14 ], [ %19, %18 ], [ null, %17 ], [ null, %11 ]
ret i8* %21
}