#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 studentData {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ addStudent(struct studentData **, int, char *);
int delete (struct studentData **, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int search(struct studentData **, char *);
main() {
  int numOfStudents, i, loc, rollNumber;
  char *str;
  struct studentData *student;
  printf("Enter the number of students in the linked list:");
  scanf("%d", &numOfStudents);
  for (i = 0; i < numOfStudents; i++) {
    printf("Enter the name of the student");
    scanf("%s", str);
    printf("Enter the Roll number");
    scanf("%d", &rollNumber);
    addStudent(&student, rollNumber, str);
  }
  printf("Enter the name of the student looking for");
  scanf("%s", str);
  loc = search(&student, str);
  if (loc > -1) {
    printf("The location where we found the name was %d", loc);
  } else {
    printf("The string was not found");
  }
  printf("Enter the name of the student to delete");
  scanf("%s", str);
  loc = delete (&student, str);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf47(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f0 <main+0xa0>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rdi
call   1050 <addStudent@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1186 <main+0x36>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdi
call   1040 <search@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jle    1240 <main+0xf0>
mov    -0x10(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124e <main+0xfe>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdi
call   1070 <delete@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf48(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11f6 <main+0xa6>
lea    0xec2(%rip),%r15
lea    0xebe(%rip),%r12
lea    0xf20(%rip),%r13
lea    0xc(%rsp),%rbx
lea    0x10(%rsp),%rbp
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %rbp,%rdi
call   1050 <addStudent@plt>
add    $0x1,%r14d
cmp    0x8(%rsp),%r14d
jl     11b0 <main+0x60>
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe44(%rip),%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x10(%rsp),%rdi
call   1040 <search@plt>
test   %eax,%eax
js     1232 <main+0xe2>
lea    0xe6b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1240 <main+0xf0>
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdfa(%rip),%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0x10(%rsp),%rdi
call   1070 <delete@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.studentData = type { i32 }
@.str = [49 x i8] c"Enter the number of students in the linked list:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Enter the name of the student\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [22 x i8] c"Enter the Roll number\00"
@.str.5 = [42 x i8] c"Enter the name of the student looking for\00"
@.str.6 = [44 x i8] c"The location where we found the name was %d\00"
@.str.7 = [25 x i8] c"The string was not found\00"
@.str.8 = [40 x i8] c"Enter the name of the student to delete\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.studentData*
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %10
10: ; preds = %23, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%16 = load i8*, i8** %6
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%20 = load i32, i32* %5
%21 = load i8*, i8** %6
%22 = call i32 @addStudent(%struct.studentData** %7, i32 %20, i8* %21)
br label %23
23: ; preds = %14
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %10
26: ; preds = %10
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%28 = load i8*, i8** %6
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %6
%31 = call i32 @search(%struct.studentData** %7, i8* %30)
store i32 %31, i32* %4
%32 = load i32, i32* %4
%33 = icmp sgt i32 %32, -1
br i1 %33, label %34, label %37
34: ; preds = %26
%35 = load i32, i32* %4
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %35)
br label %39
37: ; preds = %26
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
br label %39
39: ; preds = %37, %34
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
%41 = load i8*, i8** %6
%42 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %41)
%43 = load i8*, i8** %6
%44 = call i32 @delete(%struct.studentData** %7, i8* %43)
store i32 %44, i32* %4
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
%struct.studentData = type { i32 }
@.str = [49 x i8] c"Enter the number of students in the linked list:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Enter the name of the student\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [22 x i8] c"Enter the Roll number\00"
@.str.5 = [42 x i8] c"Enter the name of the student looking for\00"
@.str.6 = [44 x i8] c"The location where we found the name was %d\00"
@.str.7 = [25 x i8] c"The string was not found\00"
@.str.8 = [40 x i8] c"Enter the name of the student to delete\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.studentData*
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast %struct.studentData** %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %0, %11
%12 = phi i32 [ %19, %11 ], [ 0, %0 ]
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* undef)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%17 = load i32, i32* %2
%18 = call i32 @addStudent(%struct.studentData** %3, i32 %17, i8* undef)
%19 = add nuw nsw i32 %12, 1
%20 = load i32, i32* %1
%21 = icmp slt i32 %19, %20
br i1 %21, label %11, label %22
22: ; preds = %11, %0
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* undef)
%25 = call i32 @search(%struct.studentData** %3, i8* undef)
%26 = icmp sgt i32 %25, -1
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %25)
br label %31
29: ; preds = %22
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* undef)
%34 = call i32 @delete(%struct.studentData** %3, i8* undef)
ret i32 0
}