#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 EXIT_SUCCESS;
char *find_occurence(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *, char *);
int main(void) {
  char *buf = "Get up Stand up, Stand up for your rights, Bob Marley";
  char *str = "BCD";
  char *temp = find_occurence(buf, str);
  printf("Find the first occurence of: \'%s\'\n"
         "          within the string: \"%s\"\n"
         "              The result is: \'%s\'\n",
         str, buf, temp);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xef5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <find_occurence@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xed1(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%r14
lea    0xf04(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <find_occurence@plt>
lea    0xef6(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %rax,%rcx
call   1040 <printf@plt>
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [54 x i8] c"Get up Stand up, Stand up for your rights, Bob Marley\00"
@.str.1 = [4 x i8] c"BCD\00"
@.str.2 = [103 x i8] c"Find the first occurence of: '%s'\0A within the string: \22%s\22\0A The result is: '%s'\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([54 x i8], [54 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
%5 = load i8*, i8** %2
%6 = load i8*, i8** %3
%7 = call i8* @find_occurence(i8* %5, i8* %6)
store i8* %7, i8** %4
%8 = load i8*, i8** %3
%9 = load i8*, i8** %2
%10 = load i8*, i8** %4
%11 = call i32 @printf(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %9, i8* %10)
%12 = load i32, i32* @EXIT_SUCCESS
ret i32 %12
}

LLVM IR (-O2):
@.str = [54 x i8] c"Get up Stand up, Stand up for your rights, Bob Marley\00"
@.str.1 = [4 x i8] c"BCD\00"
@.str.2 = [103 x i8] c"Find the first occurence of: '%s'\0A within the string: \22%s\22\0A The result is: '%s'\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i8* @find_occurence(i8* getelementptr inbounds ([54 x i8], [54 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 ([103 x i8], [103 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* %1)
%3 = load i32, i32* @EXIT_SUCCESS
ret i32 %3
}