#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*/ binarnoPretrazivanje(char *, char, int, int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
char *realloc(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char *nizZnakova, trazeniZnak;
  int duzinaNiza;
  nizZnakova = (char *)malloc(1000 * sizeof(char));
  printf("Unesite niz znakova: ");
  scanf("%s", nizZnakova);
  duzinaNiza = strlen(nizZnakova);
  nizZnakova = realloc(nizZnakova, duzinaNiza + 1);
  printf("Unesite trazeni znak: ");
  scanf(" %c", &trazeniZnak);
  printf("Ispis:\n");
  binarnoPretrazivanje(nizZnakova, trazeniZnak, duzinaNiza, 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe82(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
call   1060 <realloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe65(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x11(%rbp),%al
mov    -0x18(%rbp),%edx
xor    %ecx,%ecx
movsbl %al,%esi
call   1080 <binarnoPretrazivanje@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x3e8,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe78(%rip),%rdi
call   1050 <printf@plt>
lea    0xe82(%rip),%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
lea    0x1(%r14),%esi
mov    %rbx,%rdi
call   1070 <realloc@plt>
mov    %rax,%rbx
lea    0xe5c(%rip),%rdi
call   1050 <printf@plt>
lea    0xe67(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1080 <scanf@plt>
lea    0xe5a(%rip),%rdi
call   1030 <puts@plt>
movsbl 0x7(%rsp),%esi
mov    %rbx,%rdi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1090 <binarnoPretrazivanje@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Unesite niz znakova: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [23 x i8] c"Unesite trazeni znak: \00"
@.str.3 = [4 x i8] c" %c\00"
@.str.4 = [8 x i8] c"Ispis:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i32
store i32 0, i32* %1
%5 = call i64 @malloc(i32 1000)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %2
%7 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %2
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %4
%12 = load i8*, i8** %2
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
%15 = call i8* @realloc(i8* %12, i32 %14)
store i8* %15, i8** %2
%16 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%18 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%19 = load i8*, i8** %2
%20 = load i8, i8* %3
%21 = load i32, i32* %4
%22 = call i32 @binarnoPretrazivanje(i8* %19, i8 signext %20, i32 %21, i32 0)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Unesite niz znakova: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [23 x i8] c"Unesite trazeni znak: \00"
@.str.3 = [4 x i8] c" %c\00"
@str = [7 x i8] c"Ispis:\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i64 @malloc(i32 1000)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%6 = tail call i32 @strlen(i8* %3)
%7 = add nsw i32 %6, 1
%8 = tail call i8* @realloc(i8* %3, i32 %7)
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%12 = load i8, i8* %1
%13 = call i32 @binarnoPretrazivanje(i8* %8, i8 signext %12, i32 %6, i32 0)
ret i32 0
}