#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 book_node {
  int dummy;
};
struct book {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ change_author_id(struct book *, struct book_node *);
int /*<<< orphan*/ change_author_name(struct book *, struct book_node *);
int /*<<< orphan*/ change_author_surname(struct book *, struct book_node *);
int /*<<< orphan*/ change_id(struct book *, struct book_node *);
int /*<<< orphan*/ change_pages(struct book *);
int /*<<< orphan*/ change_quality(struct book *);
int /*<<< orphan*/ change_title(struct book *);
int /*<<< orphan*/ change_year(struct book *);
int get_int(int *);
int /*<<< orphan*/ printf(char *);
void change(struct book *ptr, struct book_node *head) {
  printf("\nWhich field do you want to modify?\n");
  printf("\t[1]Book ID\n");
  printf("\t[2]Book Title\n");
  printf("\t[3]Year of publication\n");
  printf("\t[4]Number of Pages\n");
  printf("\t[5]Quality of the book\n");
  printf("\t[6]Author ID\n");
  printf("\t[7]Author Name\n");
  printf("\t[8]Author Surname\n");
  int opc, status;
  do {
    status = get_int(&opc);
    if (status == 1) {
      return;
    }
    if (opc < 1 || opc > 8) {
      printf("Please only introduce values between 1 and 8:");
    }
  } while (opc < 1 || opc > 8);
  switch (opc) {
  case 1:
    change_id(ptr, head);
    break;
  case 2:
    change_title(ptr);
    break;
  case 3:
    change_year(ptr);
    break;
  case 4:
    change_pages(ptr);
    break;
  case 5:
    change_quality(ptr);
    break;
  case 6:
    change_author_id(ptr, head);
    break;
  case 7:
    change_author_name(ptr, head);
    break;
  case 8:
    change_author_surname(ptr, head);
    break;
  }
}


x86 assembly (clang, -O0):
<change>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe69(%rip),%rdi
call   1060 <printf@plt>
lea    0xe82(%rip),%rdi
call   1060 <printf@plt>
lea    0xe83(%rip),%rdi
call   1060 <printf@plt>
lea    0xe87(%rip),%rdi
call   1060 <printf@plt>
lea    0xe94(%rip),%rdi
call   1060 <printf@plt>
lea    0xe9d(%rip),%rdi
call   1060 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1060 <printf@plt>
lea    0xead(%rip),%rdi
call   1060 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1060 <printf@plt>
lea    -0x14(%rbp),%rdi
call   10c0 <get_int@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    1237 <change+0x97>
jmp    1324 <change+0x184>
cmpl   $0x1,-0x14(%rbp)
jl     124b <change+0xab>
cmpl   $0x8,-0x14(%rbp)
jle    1257 <change+0xb7>
lea    0xe8b(%rip),%rdi
call   1060 <printf@plt>
jmp    125c <change+0xbc>
mov    $0x1,%al
cmpl   $0x1,-0x14(%rbp)
mov    %al,-0x19(%rbp)
jl     1275 <change+0xd5>
cmpl   $0x8,-0x14(%rbp)
setg   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    121c <change+0x7c>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x7,%eax
ja     1324 <change+0x184>
mov    -0x28(%rbp),%rax
lea    0xd60(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10b0 <change_id@plt>
jmp    1324 <change+0x184>
mov    -0x8(%rbp),%rdi
call   1080 <change_title@plt>
jmp    1324 <change+0x184>
mov    -0x8(%rbp),%rdi
call   1050 <change_year@plt>
jmp    1324 <change+0x184>
mov    -0x8(%rbp),%rdi
call   1070 <change_pages@plt>
jmp    1324 <change+0x184>
mov    -0x8(%rbp),%rdi
call   1090 <change_quality@plt>
jmp    1324 <change+0x184>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <change_author_id@plt>
jmp    1324 <change+0x184>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <change_author_name@plt>
jmp    1324 <change+0x184>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <change_author_surname@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
lea    0xea1(%rip),%rdi
call   1040 <puts@plt>
lea    0xea1(%rip),%rdi
call   1040 <puts@plt>
lea    0xea4(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
lea    0xec4(%rip),%rdi
call   1040 <puts@plt>
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
lea    0xeca(%rip),%rdi
call   1040 <puts@plt>
lea    0x4(%rsp),%rbx
lea    0xdea(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10d0 <get_int@plt>
cmp    $0x1,%eax
je     12e3 <change+0x133>
mov    0x4(%rsp),%eax
lea    -0x9(%rax),%ecx
cmp    $0xfffffff7,%ecx
ja     1271 <change+0xc1>
mov    %r12,%rdi
call   1070 <printf@plt>
mov    0x4(%rsp),%eax
lea    -0x9(%rax),%ecx
cmp    $0xfffffff8,%ecx
jb     1240 <change+0x90>
add    $0xffffffff,%eax
cmp    $0x7,%eax
ja     12e3 <change+0x133>
lea    0xd80(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r15,%rdi
mov    %r14,%rsi
call   10c0 <change_id@plt>
jmp    12e3 <change+0x133>
mov    %r15,%rdi
call   1090 <change_title@plt>
jmp    12e3 <change+0x133>
mov    %r15,%rdi
call   1060 <change_year@plt>
jmp    12e3 <change+0x133>
mov    %r15,%rdi
call   1080 <change_pages@plt>
jmp    12e3 <change+0x133>
mov    %r15,%rdi
call   10a0 <change_quality@plt>
jmp    12e3 <change+0x133>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <change_author_id@plt>
jmp    12e3 <change+0x133>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <change_author_name@plt>
jmp    12e3 <change+0x133>
mov    %r15,%rdi
mov    %r14,%rsi
call   10b0 <change_author_surname@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.book = type { i32 }
%struct.book_node = type { i32 }
@.str = [37 x i8] c"\0AWhich field do you want to modify?\0A\00"
@.str.1 = [13 x i8] c"\09[1]Book ID\0A\00"
@.str.2 = [16 x i8] c"\09[2]Book Title\0A\00"
@.str.3 = [25 x i8] c"\09[3]Year of publication\0A\00"
@.str.4 = [21 x i8] c"\09[4]Number of Pages\0A\00"
@.str.5 = [25 x i8] c"\09[5]Quality of the book\0A\00"
@.str.6 = [15 x i8] c"\09[6]Author ID\0A\00"
@.str.7 = [17 x i8] c"\09[7]Author Name\0A\00"
@.str.8 = [20 x i8] c"\09[8]Author Surname\0A\00"
@.str.9 = [46 x i8] c"Please only introduce values between 1 and 8:\00"
define void @change(%struct.book* %0, %struct.book_node* %1) {
%3 = alloca %struct.book*
%4 = alloca %struct.book_node*
%5 = alloca i32
%6 = alloca i32
store %struct.book* %0, %struct.book** %3
store %struct.book_node* %1, %struct.book_node** %4
%7 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %16
16: ; preds = %36, %2
%17 = call i32 @get_int(i32* %5)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %21
20: ; preds = %16
br label %68
21: ; preds = %16
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 1
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* %5
%26 = icmp sgt i32 %25, 8
br i1 %26, label %27, label %29
27: ; preds = %24, %21
%28 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
br label %30
30: ; preds = %29
%31 = load i32, i32* %5
%32 = icmp slt i32 %31, 1
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32, i32* %5
%35 = icmp sgt i32 %34, 8
br label %36
36: ; preds = %33, %30
%37 = phi i1 [ true, %30 ], [ %35, %33 ]
br i1 %37, label %16, label %38
38: ; preds = %36
%39 = load i32, i32* %5
switch i32 %39, label %68 [
i32 1, label %40
i32 2, label %44
i32 3, label %47
i32 4, label %50
i32 5, label %53
i32 6, label %56
i32 7, label %60
i32 8, label %64
]
40: ; preds = %38
%41 = load %struct.book*, %struct.book** %3
%42 = load %struct.book_node*, %struct.book_node** %4
%43 = call i32 @change_id(%struct.book* %41, %struct.book_node* %42)
br label %68
44: ; preds = %38
%45 = load %struct.book*, %struct.book** %3
%46 = call i32 @change_title(%struct.book* %45)
br label %68
47: ; preds = %38
%48 = load %struct.book*, %struct.book** %3
%49 = call i32 @change_year(%struct.book* %48)
br label %68
50: ; preds = %38
%51 = load %struct.book*, %struct.book** %3
%52 = call i32 @change_pages(%struct.book* %51)
br label %68
53: ; preds = %38
%54 = load %struct.book*, %struct.book** %3
%55 = call i32 @change_quality(%struct.book* %54)
br label %68
56: ; preds = %38
%57 = load %struct.book*, %struct.book** %3
%58 = load %struct.book_node*, %struct.book_node** %4
%59 = call i32 @change_author_id(%struct.book* %57, %struct.book_node* %58)
br label %68
60: ; preds = %38
%61 = load %struct.book*, %struct.book** %3
%62 = load %struct.book_node*, %struct.book_node** %4
%63 = call i32 @change_author_name(%struct.book* %61, %struct.book_node* %62)
br label %68
64: ; preds = %38
%65 = load %struct.book*, %struct.book** %3
%66 = load %struct.book_node*, %struct.book_node** %4
%67 = call i32 @change_author_surname(%struct.book* %65, %struct.book_node* %66)
br label %68
68: ; preds = %20, %38, %64, %60, %56, %53, %50, %47, %44, %40
ret void
}

LLVM IR (-O2):
%struct.book = type { i32 }
%struct.book_node = type { i32 }
@.str.9 = [46 x i8] c"Please only introduce values between 1 and 8:\00"
@str = [36 x i8] c"\0AWhich field do you want to modify?\00"
@str.10 = [12 x i8] c"\09[1]Book ID\00"
@str.11 = [15 x i8] c"\09[2]Book Title\00"
@str.12 = [24 x i8] c"\09[3]Year of publication\00"
@str.13 = [20 x i8] c"\09[4]Number of Pages\00"
@str.14 = [24 x i8] c"\09[5]Quality of the book\00"
@str.15 = [14 x i8] c"\09[6]Author ID\00"
@str.16 = [16 x i8] c"\09[7]Author Name\00"
@str.17 = [19 x i8] c"\09[8]Author Surname\00"
define void @change(%struct.book* %0, %struct.book_node* %1) {
%3 = alloca i32
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.10, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.12, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.13, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.14, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.15, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.16, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.17, i64 0, i64 0))
%13 = bitcast i32* %3 to i8*
br label %14
14: ; preds = %21, %2
%15 = call i32 @get_int(i32* %3)
%16 = icmp eq i32 %15, 1
br i1 %16, label %44, label %17
17: ; preds = %14
%18 = load i32, i32* %3
%19 = add i32 %18, -9
%20 = icmp ult i32 %19, -8
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0))
%23 = load i32, i32* %3
%24 = add i32 %23, -9
%25 = icmp ult i32 %24, -8
br i1 %25, label %14, label %26
26: ; preds = %17, %21
%27 = phi i32 [ %23, %21 ], [ %18, %17 ]
switch i32 %27, label %44 [
i32 1, label %28
i32 2, label %30
i32 3, label %32
i32 4, label %34
i32 5, label %36
i32 6, label %38
i32 7, label %40
i32 8, label %42
]
28: ; preds = %26
%29 = call i32 @change_id(%struct.book* %0, %struct.book_node* %1)
br label %44
30: ; preds = %26
%31 = call i32 @change_title(%struct.book* %0)
br label %44
32: ; preds = %26
%33 = call i32 @change_year(%struct.book* %0)
br label %44
34: ; preds = %26
%35 = call i32 @change_pages(%struct.book* %0)
br label %44
36: ; preds = %26
%37 = call i32 @change_quality(%struct.book* %0)
br label %44
38: ; preds = %26
%39 = call i32 @change_author_id(%struct.book* %0, %struct.book_node* %1)
br label %44
40: ; preds = %26
%41 = call i32 @change_author_name(%struct.book* %0, %struct.book_node* %1)
br label %44
42: ; preds = %26
%43 = call i32 @change_author_surname(%struct.book* %0, %struct.book_node* %1)
br label %44
44: ; preds = %14, %28, %30, %32, %34, %36, %38, %40, %42, %26
ret void
}