#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*/ printf(char *, char *, char const *, char *, char const *,
                          char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strstr(char const *, char const *);
int main(void) {
  const char *string1 = "abcdefabcdef";
  const char *string2 = "def";
  printf("%s%s\n%s%s\n\n%s\n%s%s\n", "string1 = ", string1,
         "string2 = ", string2, "The remainder of string1 beginning with the",
         "first occurrence of string2 is: ", strstr(string1, string2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xec8(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strstr@plt>
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%r8
lea    0xe9c(%rip),%rdi
lea    0xea9(%rip),%rsi
lea    0xead(%rip),%rcx
lea    0xeb1(%rip),%r9
lea    0xed6(%rip),%r10
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rbx
lea    0xed7(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strstr@plt>
lea    0xf1f(%rip),%r10
lea    0xec2(%rip),%rdi
lea    0xecf(%rip),%rsi
lea    0xed3(%rip),%rcx
lea    0xed7(%rip),%r9
mov    %rbx,%rdx
mov    %r14,%r8
push   %rax
push   %r10
call   1030 <printf@plt>
add    $0x10,%rsp
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"abcdefabcdef\00"
@.str.1 = [4 x i8] c"def\00"
@.str.2 = [20 x i8] c"%s%s\0A%s%s\0A\0A%s\0A%s%s\0A\00"
@.str.3 = [11 x i8] c"string1 = \00"
@.str.4 = [11 x i8] c"string2 = \00"
@.str.5 = [44 x i8] c"The remainder of string1 beginning with the\00"
@.str.6 = [33 x i8] c"first occurrence of string2 is: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %3
%4 = load i8*, i8** %2
%5 = load i8*, i8** %3
%6 = load i8*, i8** %2
%7 = load i8*, i8** %3
%8 = call i32 @strstr(i8* %6, i8* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %8)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"abcdefabcdef\00"
@.str.1 = [4 x i8] c"def\00"
@.str.2 = [20 x i8] c"%s%s\0A%s%s\0A\0A%s\0A%s%s\0A\00"
@.str.3 = [11 x i8] c"string1 = \00"
@.str.4 = [11 x i8] c"string2 = \00"
@.str.5 = [44 x i8] c"The remainder of string1 beginning with the\00"
@.str.6 = [33 x i8] c"first occurrence of string2 is: \00"
define i32 @main() {
%1 = tail call i32 @strstr(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %1)
ret i32 0
}