#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 *strchr(char *, char);
main() {
  int k;
  char *rez;
  char str1[] = "Beograd";
  rez = strchr(str1, 'x');
  if (rez == NULL)
    printf("Slovo x se ne pojavljuje\n");
  else
    printf("Slovo x se pojavljuje na poziciji %ld\n", rez - str1);
  rez = strchr(str1, 'a');
  if (rez == NULL)
    printf("Slovo a se ne pojavljuje\n");
  else
    printf("Slovo a 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
mov    $0x78,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116a <main+0x4a>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1183 <main+0x63>
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rax
sub    %rax,%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
mov    $0x61,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b3 <main+0x93>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11cc <main+0xac>
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rax
sub    %rax,%rsi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <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    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x78,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1171 <main+0x41>
sub    %rbx,%rax
lea    0xe9b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    117d <main+0x4d>
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x61,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11aa <main+0x7a>
sub    %rbx,%rax
lea    0xe89(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b6 <main+0x86>
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 = [26 x i8] c"Slovo x se ne pojavljuje\0A\00"
@.str.1 = [39 x i8] c"Slovo x se pojavljuje na poziciji %ld\0A\00"
@.str.2 = [26 x i8] c"Slovo a se ne pojavljuje\0A\00"
@.str.3 = [39 x i8] c"Slovo a 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* @strchr(i8* %6, i8 signext 120)
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 ([26 x i8], [26 x i8]* @.str, 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 ([39 x i8], [39 x i8]* @.str.1, 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* @strchr(i8* %20, i8 signext 97)
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 ([26 x i8], [26 x i8]* @.str.2, 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 ([39 x i8], [39 x i8]* @.str.3, 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.1 = [39 x i8] c"Slovo x se pojavljuje na poziciji %ld\0A\00"
@.str.3 = [39 x i8] c"Slovo a se pojavljuje na poziciji %ld\0A\00"
@str = [25 x i8] c"Slovo a se ne pojavljuje\00"
@str.4 = [25 x i8] c"Slovo x se ne pojavljuje\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 28254641660585282, i64* %1
%3 = call i8* @strchr(i8* %2, i8 signext 120)
%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 ([25 x i8], [25 x i8]* @str.4, 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 ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i64 %10)
br label %12
12: ; preds = %7, %5
%13 = call i8* @strchr(i8* %2, i8 signext 97)
%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 ([25 x i8], [25 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 ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i64 %20)
br label %22
22: ; preds = %17, %15
ret i32 0
}