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


x86 assembly (clang, -O0):
<rdz_string_end>:
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     11b1 <rdz_string_end+0x81>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdi
movslq %eax,%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rsi
mov    -0x20(%rbp),%rdx
mov    $0xffffffff,%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    120b <rdz_string_end+0xdb>
cmpl   $0x0,-0x24(%rbp)
je     11f3 <rdz_string_end+0xc3>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe1b(%rip),%rsi
call   1050 <rdz_string_expected@plt>
mov    %rax,-0x48(%rbp)
jmp    11fe <rdz_string_end+0xce>
xor    %eax,%eax
mov    %rax,-0x48(%rbp)
jmp    11fe <rdz_string_end+0xce>
mov    -0x48(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1240 <rdz_string_end+0x110>
cmpl   $0x0,-0x24(%rbp)
je     1220 <rdz_string_end+0xf0>
xor    %eax,%eax
mov    %rax,-0x50(%rbp)
jmp    1238 <rdz_string_end+0x108>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xdd5(%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_end>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
test   %rsi,%rsi
je     1188 <rdz_string_end+0x58>
mov    %r12,%rdi
call   1040 <strlen@plt>
movslq %eax,%rbx
add    %r12,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
sub    %rax,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0xffffffff,%ecx
call   1030 <rdz_strcmp@plt>
cmpb   $0x21,(%r15)
jne    119c <rdz_string_end+0x6c>
test   %rax,%rax
jne    118e <rdz_string_end+0x5e>
lea    0xe7a(%rip),%rsi
jmp    11a8 <rdz_string_end+0x78>
cmpb   $0x21,(%r15)
jne    11a1 <rdz_string_end+0x71>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
test   %rax,%rax
je     118e <rdz_string_end+0x5e>
lea    0xe5c(%rip),%rsi
mov    %r12,%rdi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <rdz_string_expected@plt>

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

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