#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 /*<<< orphan*/ display();
int /*<<< orphan*/ insert();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int pilih;
  printf("Single Linked List dengan metode LIFO\n");
  printf("=====================================\n");
  do {
    printf("Pilihan : \n");
    printf("1. Insert\n");
    printf("2. Display\n");
    printf("3. Exit\n");
    printf("Pilihan Anda : ");
    scanf("%d", &pilih);
    switch (pilih) {
    case 1:
      insert();
      break;
    case 2:
      display();
      break;
    case 3:
      printf("Terimakasih");
      break;
    default:
      printf("Pilihan tidak ada di menu, Coba lagi ya");
    }
  } while (pilih != 3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
lea    0xee0(%rip),%rdi
call   1040 <printf@plt>
lea    0xee0(%rip),%rdi
call   1040 <printf@plt>
lea    0xedf(%rip),%rdi
call   1040 <printf@plt>
lea    0xedf(%rip),%rdi
call   1040 <printf@plt>
lea    0xedc(%rip),%rdi
call   1040 <printf@plt>
lea    0xee0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     11e9 <main+0xa9>
jmp    11c7 <main+0x87>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     11f5 <main+0xb5>
jmp    11d8 <main+0x98>
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
je     1201 <main+0xc1>
jmp    1212 <main+0xd2>
mov    $0x0,%al
call   1060 <insert@plt>
jmp    121e <main+0xde>
mov    $0x0,%al
call   1030 <display@plt>
jmp    121e <main+0xde>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
jmp    121e <main+0xde>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
jmp    1223 <main+0xe3>
cmpl   $0x3,-0x8(%rbp)
jne    1167 <main+0x27>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
lea    0xf24(%rip),%r15
lea    0xf27(%rip),%r12
lea    0xf2b(%rip),%r13
lea    0xe71(%rip),%rbx
lea    0xe7a(%rip),%rbp
lea    0x4(%rsp),%r14
jmp    11b3 <main+0x63>
nopl   (%rax)
lea    0xe78(%rip),%rdi
call   1050 <printf@plt>
cmpl   $0x3,0x4(%rsp)
je     122c <main+0xdc>
lea    0xed9(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
je     1220 <main+0xd0>
cmp    $0x2,%eax
je     1210 <main+0xc0>
cmp    $0x1,%eax
jne    11a0 <main+0x50>
xor    %eax,%eax
call   1070 <insert@plt>
jmp    11ac <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <display@plt>
jmp    11ac <main+0x5c>
nopl   0x0(%rax)
lea    0xdec(%rip),%rdi
jmp    11a7 <main+0x57>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Single Linked List dengan metode LIFO\0A\00"
@.str.1 = [39 x i8] c"=====================================\0A\00"
@.str.2 = [12 x i8] c"Pilihan : \0A\00"
@.str.3 = [11 x i8] c"1. Insert\0A\00"
@.str.4 = [12 x i8] c"2. Display\0A\00"
@.str.5 = [9 x i8] c"3. Exit\0A\00"
@.str.6 = [16 x i8] c"Pilihan Anda : \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [12 x i8] c"Terimakasih\00"
@.str.9 = [40 x i8] c"Pilihan tidak ada di menu, Coba lagi ya\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %22, %0
%6 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
switch i32 %12, label %19 [
i32 1, label %13
i32 2, label %15
i32 3, label %17
]
13: ; preds = %5
%14 = call i32 (...) @insert()
br label %21
15: ; preds = %5
%16 = call i32 (...) @display()
br label %21
17: ; preds = %5
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
br label %21
19: ; preds = %5
%20 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0))
br label %21
21: ; preds = %19, %17, %15, %13
br label %22
22: ; preds = %21
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 3
br i1 %24, label %5, label %25
25: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@.str.6 = [16 x i8] c"Pilihan Anda : \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [12 x i8] c"Terimakasih\00"
@.str.9 = [40 x i8] c"Pilihan tidak ada di menu, Coba lagi ya\00"
@str = [38 x i8] c"Single Linked List dengan metode LIFO\00"
@str.10 = [38 x i8] c"=====================================\00"
@str.11 = [11 x i8] c"Pilihan : \00"
@str.12 = [10 x i8] c"1. Insert\00"
@str.13 = [11 x i8] c"2. Display\00"
@str.14 = [8 x i8] c"3. Exit\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.10, i64 0, i64 0))
br label %5
5: ; preds = %21, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.11, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.12, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.13, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.14, i64 0, i64 0))
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
switch i32 %12, label %19 [
i32 1, label %13
i32 2, label %15
i32 3, label %17
]
13: ; preds = %5
%14 = call i32 (...) @insert()
br label %21
15: ; preds = %5
%16 = call i32 (...) @display()
br label %21
17: ; preds = %5
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
br label %21
19: ; preds = %5
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0))
br label %21
21: ; preds = %13, %15, %17, %19
%22 = load i32, i32* %1
%23 = icmp eq i32 %22, 3
br i1 %23, label %24, label %5
24: ; preds = %21
ret i32 0
}