#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*/ find_str(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
int main() {
  char *s = "GoldenGlobalView";
  char *l = "lob";
  char *p;
  p = strstr(s, l);
  if (p) {
    printf("%s\n", p);
    printf("first occurrence %d\n", (int)(p - s));
  } else
    printf("NotFound!\n");
  char *str = "one two three";
  find_str(str, "two");
  find_str(str, "");
  find_str(str, "nine");
  find_str(str, "n");
  char str2[] = "This is a simple string";
  char *pch;
  pch = strstr(str2, "simple");
  strncpy(pch, "sample", 6);
  puts(str2);
  puts(pch);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xea0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11c3 <main+0x73>
mov    -0x20(%rbp),%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    11d1 <main+0x81>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe61(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1050 <find_str@plt>
mov    -0x28(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1050 <find_str@plt>
mov    -0x28(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1050 <find_str@plt>
mov    -0x28(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1050 <find_str@plt>
mov    0xe3d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe3a(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe37(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xdfd(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncpy@plt>
lea    -0x40(%rbp),%rdi
call   1040 <puts@plt>
mov    -0x48(%rbp),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xea9(%rip),%rdi
call   1040 <puts@plt>
lea    0xea7(%rip),%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea9(%rip),%rbx
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1050 <find_str@plt>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1050 <find_str@plt>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1050 <find_str@plt>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1050 <find_str@plt>
movaps 0xe90(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x676e6972747320,%rax
mov    %rax,0x10(%rsp)
lea    0xe65(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1070 <strstr@plt>
mov    %rax,%rbx
lea    0xe57(%rip),%rsi
mov    %rax,%rdi
mov    $0x6,%edx
call   1030 <strncpy@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"GoldenGlobalView\00"
@.str.1 = [4 x i8] c"lob\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [21 x i8] c"first occurrence %d\0A\00"
@.str.4 = [11 x i8] c"NotFound!\0A\00"
@.str.5 = [14 x i8] c"one two three\00"
@.str.6 = [4 x i8] c"two\00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [5 x i8] c"nine\00"
@.str.9 = [2 x i8] c"n\00"
@__const.main.str2 = [24 x i8] c"This is a simple string\00"
@.str.10 = [7 x i8] c"simple\00"
@.str.11 = [7 x i8] c"sample\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [24 x i8]
%7 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([17 x i8], [17 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
%8 = load i8*, i8** %2
%9 = load i8*, i8** %3
%10 = call i8* @strstr(i8* %8, i8* %9)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %23
13: ; preds = %0
%14 = load i8*, i8** %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %4
%17 = load i8*, i8** %2
%18 = ptrtoint i8* %16 to i64
%19 = ptrtoint i8* %17 to i64
%20 = sub i64 %18, %19
%21 = trunc i64 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %21)
br label %25
23: ; preds = %0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %23, %13
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %5
%26 = load i8*, i8** %5
%27 = call i32 @find_str(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%28 = load i8*, i8** %5
%29 = call i32 @find_str(i8* %28, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%30 = load i8*, i8** %5
%31 = call i32 @find_str(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%32 = load i8*, i8** %5
%33 = call i32 @find_str(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%34 = bitcast [24 x i8]* %6 to i8*
%35 = getelementptr inbounds [24 x i8], [24 x i8]* %6, i64 0, i64 0
%36 = call i8* @strstr(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
store i8* %36, i8** %7
%37 = load i8*, i8** %7
%38 = call i32 @strncpy(i8* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 6)
%39 = getelementptr inbounds [24 x i8], [24 x i8]* %6, i64 0, i64 0
%40 = call i32 @puts(i8* %39)
%41 = load i8*, i8** %7
%42 = call i32 @puts(i8* %41)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"GoldenGlobalView\00"
@.str.3 = [21 x i8] c"first occurrence %d\0A\00"
@.str.5 = [14 x i8] c"one two three\00"
@.str.6 = [4 x i8] c"two\00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [5 x i8] c"nine\00"
@.str.9 = [2 x i8] c"n\00"
@__const.main.str2 = [24 x i8] c"This is a simple string\00"
@.str.10 = [7 x i8] c"simple\00"
@.str.11 = [7 x i8] c"sample\00"
define i32 @main() {
%1 = alloca [24 x i8]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 7))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 7)
%4 = tail call i32 @find_str(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%5 = tail call i32 @find_str(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%6 = tail call i32 @find_str(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%7 = tail call i32 @find_str(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%8 = getelementptr inbounds [24 x i8], [24 x i8]* %1, i64 0, i64 0
%9 = call i8* @strstr(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%10 = call i32 @strncpy(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 6)
%11 = call i32 @puts(i8* %8)
%12 = call i32 @puts(i8* dereferenceable(1) %9)
ret i32 0
}