#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 */
struct Listy {
  int dummy;
};

/* Variables and functions */
struct Listy *createListy();
int findIndex(struct Listy *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/, char *, int *);
int /*<<< orphan*/ printListy(struct Listy *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(void) {
  struct Listy *list = createListy();
  printListy(list);
  int search = 0;
  fprintf(stdout, "Please enter element for searh: ");
  fscanf(stdin, "%i", &search);
  fprintf(stdout, "Element %i has index %i in a given Listy structure\n",
          search, findIndex(list, search));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <createListy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <printListy@plt>
movl   $0x0,-0x14(%rbp)
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <fscanf@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <findIndex@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
lea    0xe4d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1060 <createListy@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1070 <printListy@plt>
movl   $0x0,0xc(%rsp)
mov    0x2e5f(%rip),%rbx
mov    (%rbx),%edi
lea    0xe7e(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <fscanf@plt>
mov    (%rbx),%ebp
mov    0xc(%rsp),%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <findIndex@plt>
lea    0xe6a(%rip),%rsi
mov    %ebp,%edi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.Listy = type { i32 }
@stdout = global i32 0
@.str = [33 x i8] c"Please enter element for searh: \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [52 x i8] c"Element %i has index %i in a given Listy structure\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Listy*
%3 = alloca i32
store i32 0, i32* %1
%4 = call %struct.Listy* (...) @createListy()
store %struct.Listy* %4, %struct.Listy** %2
%5 = load %struct.Listy*, %struct.Listy** %2
%6 = call i32 @printListy(%struct.Listy* %5)
store i32 0, i32* %3
%7 = load i32, i32* @stdout
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @stdin
%10 = call i32 @fscanf(i32 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* @stdout
%12 = load i32, i32* %3
%13 = load %struct.Listy*, %struct.Listy** %2
%14 = load i32, i32* %3
%15 = call i32 @findIndex(%struct.Listy* %13, i32 %14)
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %15)
ret i32 0
}

LLVM IR (-O2):
%struct.Listy = type { i32 }
@stdout = global i32 0
@.str = [33 x i8] c"Please enter element for searh: \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [52 x i8] c"Element %i has index %i in a given Listy structure\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call %struct.Listy* (...) @createListy()
%3 = tail call i32 @printListy(%struct.Listy* %2)
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = load i32, i32* @stdout
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fscanf(i32 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* @stdout
%10 = load i32, i32* %1
%11 = call i32 @findIndex(%struct.Listy* %2, i32 %10)
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %11)
ret i32 0
}