#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*/ backward();
int /*<<< orphan*/ forward();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void display() {
  int m;
  printf("1. forward order of list\n2. Backward order of list\n");
  scanf("%d", &m);
  switch (m) {
  case 1:
    forward();
    break;
  case 2:
    backward();
    break;
  default:
    printf("invalid\n");
  }
}


x86 assembly (clang, -O0):
<display>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x1,%eax
je     1189 <display+0x49>
jmp    1178 <display+0x38>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     1195 <display+0x55>
jmp    11a1 <display+0x61>
mov    $0x0,%al
call   1050 <forward@plt>
jmp    11ad <display+0x6d>
mov    $0x0,%al
call   1040 <backward@plt>
jmp    11ad <display+0x6d>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display>:
push   %rax
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
je     1175 <display+0x35>
cmp    $0x1,%eax
jne    117e <display+0x3e>
xor    %eax,%eax
call   1050 <forward@plt>
pop    %rax
ret
xor    %eax,%eax
call   1040 <backward@plt>
pop    %rax
ret
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [52 x i8] c"1. forward order of list\0A2. Backward order of list\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"invalid\0A\00"
define void @display() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
switch i32 %4, label %9 [
i32 1, label %5
i32 2, label %7
]
5: ; preds = %0
%6 = call i32 (...) @forward()
br label %11
7: ; preds = %0
%8 = call i32 (...) @backward()
br label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9, %7, %5
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [51 x i8] c"1. forward order of list\0A2. Backward order of list\00"
@str.3 = [8 x i8] c"invalid\00"
define void @display() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
switch i32 %5, label %10 [
i32 1, label %6
i32 2, label %8
]
6: ; preds = %0
%7 = call i32 (...) @forward()
br label %12
8: ; preds = %0
%9 = call i32 (...) @backward()
br label %12
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %8, %6
ret void
}