#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 add(int);
int /*<<< orphan*/ deltop();
int /*<<< orphan*/ init();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ show();
int /*<<< orphan*/ system(char *);
int main() {
  int id;
  while (1) {
    printf("1.Inisiasi Double link list\n2.Tambah data\n3.cetak semua "
           "data\n4.Hapus data\n0.Exit\n");
    int pilihan;
    scanf("%d", &pilihan);
    switch (pilihan) {
    case 1:
      init();
      printf("Double linklist terinisialisasi\n");
      break;
    case 2:
      printf("Ketik angka");
      scanf("%d", &id);
      int hasil = add(id);
      if (hasil == 1)
        printf("Data berhasil ditambahkan\n");
      else
        printf("Data gagal diinput\n");
      break;
    case 3:
      show();
      system("pause");
      break;
    case 4:
      deltop();
      printf("Data berhasil dihapus\n");
      break;
    case 0:
      return 0;
      break;
    default:
      printf("Salah pilihan,ulangi lagi\n");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8e(%rip),%rdi
call   1060 <printf@plt>
lea    0xed4(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x4,%rax
ja     1263 <main+0xf3>
mov    -0x18(%rbp),%rax
lea    0xe49(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1080 <init@plt>
lea    0xe9b(%rip),%rdi
call   1060 <printf@plt>
jmp    126f <main+0xff>
lea    0xeab(%rip),%rdi
call   1060 <printf@plt>
lea    0xe7b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1030 <add@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    121a <main+0xaa>
lea    0xe86(%rip),%rdi
call   1060 <printf@plt>
jmp    1226 <main+0xb6>
lea    0xe90(%rip),%rdi
call   1060 <printf@plt>
jmp    126f <main+0xff>
mov    $0x0,%al
call   1070 <show@plt>
lea    0xe8c(%rip),%rdi
call   1050 <system@plt>
jmp    126f <main+0xff>
mov    $0x0,%al
call   1040 <deltop@plt>
lea    0xe7a(%rip),%rdi
call   1060 <printf@plt>
jmp    126f <main+0xff>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret
lea    0xe78(%rip),%rdi
call   1060 <printf@plt>
jmp    117f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe97(%rip),%r14
lea    0xe7b(%rip),%rbx
mov    %rsp,%r15
lea    0xe5d(%rip),%r12
lea    0xe79(%rip),%r13
lea    0xec9(%rip),%rbp
jmp    11d0 <main+0x50>
xor    %eax,%eax
call   1040 <deltop@plt>
mov    %rbp,%rdi
call   1050 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <scanf@plt>
mov    (%rsp),%eax
cmp    $0x4,%rax
ja     120a <main+0x8a>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %eax,%eax
call   1090 <init@plt>
lea    0xeba(%rip),%rdi
call   1050 <puts@plt>
jmp    11d0 <main+0x50>
lea    0xecc(%rip),%rdi
call   1050 <puts@plt>
jmp    11d0 <main+0x50>
lea    0xdf8(%rip),%rdi
call   1070 <printf@plt>
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   10a0 <scanf@plt>
mov    0x4(%rsp),%edi
call   1030 <add@plt>
cmp    $0x1,%eax
jne    1261 <main+0xe1>
lea    0xe5d(%rip),%rdi
call   1050 <puts@plt>
jmp    11d0 <main+0x50>
xor    %eax,%eax
call   1080 <show@plt>
mov    %r13,%rdi
call   1060 <system@plt>
jmp    11d0 <main+0x50>
lea    0xe28(%rip),%rdi
call   1050 <puts@plt>
jmp    11d0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [82 x i8] c"1.Inisiasi Double link list\0A2.Tambah data\0A3.cetak semua data\0A4.Hapus data\0A0.Exit\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"Double linklist terinisialisasi\0A\00"
@.str.3 = [12 x i8] c"Ketik angka\00"
@.str.4 = [27 x i8] c"Data berhasil ditambahkan\0A\00"
@.str.5 = [20 x i8] c"Data gagal diinput\0A\00"
@.str.6 = [6 x i8] c"pause\00"
@.str.7 = [23 x i8] c"Data berhasil dihapus\0A\00"
@.str.8 = [27 x i8] c"Salah pilihan,ulangi lagi\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %0, %33
%6 = call i32 @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
switch i32 %8, label %31 [
i32 1, label %9
i32 2, label %12
i32 3, label %24
i32 4, label %27
i32 0, label %30
]
9: ; preds = %5
%10 = call i32 (...) @init()
%11 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %33
12: ; preds = %5
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = call i32 @add(i32 %15)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %23
21: ; preds = %12
%22 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
br label %33
24: ; preds = %5
%25 = call i32 (...) @show()
%26 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %33
27: ; preds = %5
%28 = call i32 (...) @deltop()
%29 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %33
30: ; preds = %5
ret i32 0
31: ; preds = %5
%32 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
br label %33
33: ; preds = %31, %27, %24, %23, %9
br label %5
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [12 x i8] c"Ketik angka\00"
@.str.6 = [6 x i8] c"pause\00"
@str = [81 x i8] c"1.Inisiasi Double link list\0A2.Tambah data\0A3.cetak semua data\0A4.Hapus data\0A0.Exit\00"
@str.9 = [22 x i8] c"Data berhasil dihapus\00"
@str.10 = [19 x i8] c"Data gagal diinput\00"
@str.11 = [26 x i8] c"Data berhasil ditambahkan\00"
@str.12 = [32 x i8] c"Double linklist terinisialisasi\00"
@str.13 = [26 x i8] c"Salah pilihan,ulangi lagi\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %30, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
switch i32 %8, label %28 [
i32 1, label %9
i32 2, label %12
i32 3, label %22
i32 4, label %25
i32 0, label %31
]
9: ; preds = %5
%10 = call i32 (...) @init()
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.12, i64 0, i64 0))
br label %30
12: ; preds = %5
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = call i32 @add(i32 %15)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.11, i64 0, i64 0))
br label %30
20: ; preds = %12
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0))
br label %30
22: ; preds = %5
%23 = call i32 (...) @show()
%24 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %30
25: ; preds = %5
%26 = call i32 (...) @deltop()
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
br label %30
28: ; preds = %5
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.13, i64 0, i64 0))
br label %30
30: ; preds = %9, %22, %25, %28, %20, %18
br label %5
31: ; preds = %5
ret i32 0
}