#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 */
typedef int /*<<< orphan*/ str2;
typedef int /*<<< orphan*/ str1;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
int sunday_search(char *, char *);
int main(int argc, const char *argv[]) {
  char str1[256];
  char str2[256];
  printf("input str1:\n");
  fgets(str1, sizeof(str1), stdin);
  *strchr(str1, '\n') = '\0';
  printf("input str2:\n");
  fgets(str2, sizeof(str2), stdin);
  *strchr(str2, '\n') = '\0';
  printf("str2 in str1 index is %d\n", sunday_search(str1, str2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e73(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1050 <fgets@plt>
lea    -0x110(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
movb   $0x0,(%rax)
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x210(%rbp),%rdi
mov    0x2e37(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1050 <fgets@plt>
lea    -0x210(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
movb   $0x0,(%rax)
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1060 <sunday_search@plt>
mov    %eax,%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x208,%rsp
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e7b(%rip),%rbx
mov    (%rbx),%edx
lea    0x100(%rsp),%r14
mov    %r14,%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
movb   $0x0,(%rax)
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <sunday_search@plt>
lea    0xe2c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"input str1:\0A\00"
@stdin = global i32 0
@.str.1 = [13 x i8] c"input str2:\0A\00"
@.str.2 = [26 x i8] c"str2 in str1 index is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 256, i32 %10)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%13 = call i8* @strchr(i8* %12, i8 signext 10)
store i8 0, i8* %13
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %15, i32 256, i32 %16)
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%19 = call i8* @strchr(i8* %18, i8 signext 10)
store i8 0, i8* %19
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%22 = call i32 @sunday_search(i8* %20, i8* %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %22)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.2 = [26 x i8] c"str2 in str1 index is %d\0A\00"
@str = [12 x i8] c"input str1:\00"
@str.3 = [12 x i8] c"input str2:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %5, i32 256, i32 %8)
%10 = call i8* @strchr(i8* %5, i8 signext 10)
store i8 0, i8* %10
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.3, i64 0, i64 0))
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %6, i32 256, i32 %12)
%14 = call i8* @strchr(i8* %6, i8 signext 10)
store i8 0, i8* %14
%15 = call i32 @sunday_search(i8* %5, i8* %6)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %15)
ret i32 0
}