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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8b(%rip),%rdi
call   1040 <system@plt>
lea    0xe83(%rip),%rdi
call   1050 <printf@plt>
lea    0xec4(%rip),%rdi
xor    %eax,%eax
lea    -0x74(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x74(%rbp),%eax
mov    %rax,-0x80(%rbp)
sub    $0x4,%rax
ja     12b3 <main+0x143>
mov    -0x80(%rbp),%rax
lea    0xe38(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1080 <init@plt>
lea    0xe89(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9a(%rip),%rdi
call   1040 <system@plt>
jmp    12bf <main+0x14f>
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1090 <scanf@plt>
lea    0xe4b(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <add@plt>
mov    %eax,-0x78(%rbp)
cmpl   $0x1,-0x78(%rbp)
jne    124f <main+0xdf>
lea    0xe65(%rip),%rdi
call   1050 <printf@plt>
jmp    125b <main+0xeb>
lea    0xe6f(%rip),%rdi
call   1050 <printf@plt>
lea    0xe23(%rip),%rdi
call   1040 <system@plt>
jmp    12bf <main+0x14f>
mov    $0x0,%al
call   1060 <print@plt>
lea    0xe0b(%rip),%rdi
call   1040 <system@plt>
jmp    12bf <main+0x14f>
mov    $0x0,%al
call   1070 <hapus_depan@plt>
lea    0xe47(%rip),%rdi
call   1050 <printf@plt>
lea    0xde7(%rip),%rdi
call   1040 <system@plt>
jmp    12bf <main+0x14f>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret
lea    0xe36(%rip),%rdi
call   1050 <printf@plt>
jmp    1182 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe7f(%rip),%rbp
lea    0xea4(%rip),%r13
lea    0xe75(%rip),%r14
lea    0x8(%rsp),%r12
lea    0xe51(%rip),%r15
lea    0xe65(%rip),%rbx
jmp    11d0 <main+0x50>
lea    0xf2c(%rip),%rdi
call   1040 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
call   1050 <system@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    0x8(%rsp),%eax
cmp    $0x4,%rax
ja     11b8 <main+0x38>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
xor    %eax,%eax
call   1090 <init@plt>
lea    0xec1(%rip),%rdi
jmp    128e <main+0x10e>
lea    0xe0a(%rip),%rdi
call   1060 <printf@plt>
lea    0xe17(%rip),%rdi
mov    %r12,%rbx
mov    %r13,%r12
lea    0x10(%rsp),%r13
mov    %r13,%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    %r14,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %r13,%rdi
mov    %r12,%r13
mov    %rbx,%r12
lea    0xdc0(%rip),%rbx
call   1030 <add@plt>
cmp    $0x1,%eax
lea    0xe38(%rip),%rdi
lea    0xe44(%rip),%rax
cmove  %rax,%rdi
jmp    128e <main+0x10e>
xor    %eax,%eax
call   1070 <print@plt>
jmp    1293 <main+0x113>
xor    %eax,%eax
call   1080 <hapus_depan@plt>
lea    0xdfe(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
jmp    11d0 <main+0x50>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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