#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 *strstr(char *, char *);
main() {
  int k;
  char *rez;
  char str1[] = "Beograd";
  rez = strstr(str1, "selo");
  if (rez == NULL)
    printf("selo se ne pojavljuje\n");
  else
    printf("selo se pojavljuje na poziciji %ld\n", rez - str1);
  rez = strstr(str1, "grad");
  if (rez == NULL)
    printf("grad se ne pojavljuje\n");
  else
    printf("grad se pojavljuje na poziciji %ld\n", rez - str1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xec3(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116c <main+0x4c>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1185 <main+0x65>
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rax
sub    %rax,%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b7 <main+0x97>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d0 <main+0xb0>
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rax
sub    %rax,%rsi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x646172676f6542,%rax
mov    %rax,0x8(%rsp)
lea    0xeb5(%rip),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     1173 <main+0x43>
sub    %rbx,%rax
lea    0xe9e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117f <main+0x4f>
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0xea3(%rip),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     11ae <main+0x7e>
sub    %rbx,%rax
lea    0xe8c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ba <main+0x8a>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.str1 = [8 x i8] c"Beograd\00"
@.str = [5 x i8] c"selo\00"
@.str.1 = [23 x i8] c"selo se ne pojavljuje\0A\00"
@.str.2 = [36 x i8] c"selo se pojavljuje na poziciji %ld\0A\00"
@.str.3 = [5 x i8] c"grad\00"
@.str.4 = [23 x i8] c"grad se ne pojavljuje\0A\00"
@.str.5 = [36 x i8] c"grad se pojavljuje na poziciji %ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [8 x i8]
store i32 0, i32* %1
%5 = bitcast [8 x i8]* %4 to i8*
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%7 = call i8* @strstr(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %19
12: ; preds = %0
%13 = load i8*, i8** %3
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%15 = ptrtoint i8* %13 to i64
%16 = ptrtoint i8* %14 to i64
%17 = sub i64 %15, %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i64 %17)
br label %19
19: ; preds = %12, %10
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%21 = call i8* @strstr(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i8* %21, i8** %3
%22 = load i8*, i8** %3
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %33
26: ; preds = %19
%27 = load i8*, i8** %3
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%29 = ptrtoint i8* %27 to i64
%30 = ptrtoint i8* %28 to i64
%31 = sub i64 %29, %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i64 %31)
br label %33
33: ; preds = %26, %24
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str = [5 x i8] c"selo\00"
@.str.2 = [36 x i8] c"selo se pojavljuje na poziciji %ld\0A\00"
@.str.3 = [5 x i8] c"grad\00"
@.str.5 = [36 x i8] c"grad se pojavljuje na poziciji %ld\0A\00"
@str = [22 x i8] c"grad se ne pojavljuje\00"
@str.6 = [22 x i8] c"selo se ne pojavljuje\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 28254641660585282, i64* %1
%3 = call i8* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0))
br label %12
7: ; preds = %0
%8 = ptrtoint i8* %3 to i64
%9 = ptrtoint i64* %1 to i64
%10 = sub i64 %8, %9
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i64 %10)
br label %12
12: ; preds = %7, %5
%13 = call i8* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %22
17: ; preds = %12
%18 = ptrtoint i8* %13 to i64
%19 = ptrtoint i64* %1 to i64
%20 = sub i64 %18, %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i64 %20)
br label %22
22: ; preds = %17, %15
ret i32 0
}