#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__ strcmp(unsigned char *, char *);
int /*<<< orphan*/ strlen(char *);
unsigned char *sunday(char *, int /*<<< orphan*/, char *, int /*<<< orphan*/);
char *tc_002() {
  unsigned char *rel =
      sunday("1234567890", strlen("1234567890"), "3456", strlen("3456"));
  do {
    return 0 == strcmp(rel, "34567890") ? NULL
                                        : "expect ["
                                          "rel"
                                          "], but got ["
                                          "\"34567890\""
                                          "]";
  } while (0);
  ;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <strlen@plt>
mov    -0xc(%rbp),%esi
mov    %eax,%ecx
lea    0xea1(%rip),%rdi
lea    0xea5(%rip),%rdx
call   1050 <sunday@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    0xe83(%rip),%rax
cmp    %rdx,%rcx
cmove  %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0xebf(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1050 <sunday@plt>
lea    0xe98(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
lea    0xe94(%rip),%rcx
cmovne %rcx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"1234567890\00"
@.str.1 = [5 x i8] c"3456\00"
@.str.2 = [9 x i8] c"34567890\00"
@.str.3 = [35 x i8] c"expect [rel], but got [\2234567890\22]\00"
define i8* @tc_002() {
%1 = alloca i8*
%2 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = call i8* @sunday(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %3)
store i8* %4, i8** %1
br label %5
5: ; preds = %0
%6 = load i8*, i8** %1
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 0, %7
%9 = zext i1 %8 to i64
%10 = select i1 %8, i8* null, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0)
br label %11
11: ; preds = %5
ret i8* %10
}

LLVM IR (-O2):
@.str = [11 x i8] c"1234567890\00"
@.str.1 = [5 x i8] c"3456\00"
@.str.2 = [9 x i8] c"34567890\00"
@.str.3 = [35 x i8] c"expect [rel], but got [\2234567890\22]\00"
define i8* @tc_002() {
%1 = tail call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i8* @sunday(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%4 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* null, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0)
ret i8* %6
}