#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 chdir(char *);
int /*<<< orphan*/ mfm_input_goto(int, int);
int /*<<< orphan*/ mfm_scr_size(int *, int *);
int mfm_simple_menu(char **);
int /*<<< orphan*/ printf(char *, char *);
void mfm_goto(char **bookmarks) {
  printf("%s", "\e[1;1H\e[33;41m\e[2K");
  printf("%s", "Go to the directory:");
  int h, w;
  mfm_scr_size(&h, &w);
  if (!bookmarks) {
    mfm_input_goto(h, w);
    return;
  }
  int choice = mfm_simple_menu(bookmarks);
  if (choice == -1) {
    return;
  }
  int res = chdir(bookmarks[choice]);
}


x86 assembly (clang, -O0):
<mfm_goto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1040 <printf@plt>
lea    0xe8a(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1040 <printf@plt>
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <mfm_scr_size@plt>
cmpq   $0x0,-0x8(%rbp)
jne    11aa <mfm_goto+0x5a>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <mfm_input_goto@plt>
jmp    11d9 <mfm_goto+0x89>
mov    -0x8(%rbp),%rdi
call   1070 <mfm_simple_menu@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11c5 <mfm_goto+0x75>
jmp    11d9 <mfm_goto+0x89>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <chdir@plt>
mov    %eax,-0x18(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mfm_goto>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xea2(%rip),%r14
lea    0xe9e(%rip),%rsi
mov    %r14,%rdi
call   1040 <printf@plt>
lea    0xea2(%rip),%rsi
mov    %r14,%rdi
call   1040 <printf@plt>
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1060 <mfm_scr_size@plt>
test   %rbx,%rbx
je     11a8 <mfm_goto+0x58>
mov    %rbx,%rdi
call   1070 <mfm_simple_menu@plt>
cmp    $0xffffffff,%eax
je     11b4 <mfm_goto+0x64>
cltq
mov    (%rbx,%rax,8),%rdi
call   1030 <chdir@plt>
jmp    11b4 <mfm_goto+0x64>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1050 <mfm_input_goto@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [19 x i8] c"\1B[1;1H\1B[33;41m\1B[2K\00"
@.str.2 = [21 x i8] c"Go to the directory:\00"
define void @mfm_goto(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8** %0, i8*** %2
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @mfm_scr_size(i32* %3, i32* %4)
%10 = load i8**, i8*** %2
%11 = icmp ne i8** %10, null
br i1 %11, label %16, label %12
12: ; preds = %1
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i32 @mfm_input_goto(i32 %13, i32 %14)
br label %29
16: ; preds = %1
%17 = load i8**, i8*** %2
%18 = call i32 @mfm_simple_menu(i8** %17)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %22
21: ; preds = %16
br label %29
22: ; preds = %16
%23 = load i8**, i8*** %2
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @chdir(i8* %27)
store i32 %28, i32* %6
br label %29
29: ; preds = %22, %21, %12
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [19 x i8] c"\1B[1;1H\1B[33;41m\1B[2K\00"
@.str.2 = [21 x i8] c"Go to the directory:\00"
define void @mfm_goto(i8** %0) {
%2 = alloca i32
%3 = alloca i32
%4 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = call i32 @mfm_scr_size(i32* %2, i32* %3)
%9 = icmp eq i8** %0, null
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 @mfm_input_goto(i32 %11, i32 %12)
br label %22
14: ; preds = %1
%15 = call i32 @mfm_simple_menu(i8** %0)
%16 = icmp eq i32 %15, -1
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = sext i32 %15 to i64
%19 = getelementptr inbounds i8*, i8** %0, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @chdir(i8* %20)
br label %22
22: ; preds = %17, %14, %10
ret void
}