#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 */
char EOF;
char getchar();
int /*<<< orphan*/ listsessions();
int /*<<< orphan*/ login();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int prompt_run(void) {
  char c = '\0';
  do {
    if (c != '\0') {
      printf("\nInvalid input \"%c\"\n", c);
      printf("Iteration\n");
    }
    printf("Choose action [login(l)/listSessions(s)] default is login:");
    c = getchar();
    if (c == EOF) {
      perror("Error while read ");
      return 0;
    }
    printf("\n");
    if (c == '\n') {
      c = 'l';
    } else {
      getchar();
    }
  } while (c != 'l' && c != 's');
  switch (c) {
  case 'l':
    login();
    break;
  case 's':
    listsessions();
    break;
  }
  return 1;
}


x86 assembly (clang, -O0):
<prompt_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x0,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
je     1189 <prompt_run+0x39>
movsbl -0x5(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
mov    0x2e3c(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11cf <prompt_run+0x7f>
lea    0xe9d(%rip),%rdi
call   1070 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1269 <prompt_run+0x119>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    11f3 <prompt_run+0xa3>
movb   $0x6c,-0x5(%rbp)
jmp    11fa <prompt_run+0xaa>
mov    $0x0,%al
call   1050 <getchar@plt>
jmp    11ff <prompt_run+0xaf>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x6c,%ecx
mov    %al,-0x6(%rbp)
je     121e <prompt_run+0xce>
movsbl -0x5(%rbp),%eax
cmp    $0x73,%eax
setne  %al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
test   $0x1,%al
jne    115c <prompt_run+0xc>
movsbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x6c,%eax
je     124f <prompt_run+0xff>
jmp    123e <prompt_run+0xee>
mov    -0xc(%rbp),%eax
sub    $0x73,%eax
je     125b <prompt_run+0x10b>
jmp    1262 <prompt_run+0x112>
mov    $0x0,%al
call   1040 <login@plt>
jmp    1262 <prompt_run+0x112>
mov    $0x0,%al
call   1060 <listsessions@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prompt_run>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xe96(%rip),%r12
mov    0x2e62(%rip),%rbx
lea    0xe73(%rip),%r14
lea    0xece(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
test   %bpl,%bpl
je     11bb <prompt_run+0x4b>
movsbl %bpl,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    (%rbx),%al
je     1213 <prompt_run+0xa3>
mov    %eax,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0xa,%bpl
je     11f5 <prompt_run+0x85>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0x73,%bpl
je     11fe <prompt_run+0x8e>
cmp    $0x6c,%bpl
jne    11a0 <prompt_run+0x30>
xor    %eax,%eax
call   1060 <login@plt>
jmp    1205 <prompt_run+0x95>
xor    %eax,%eax
call   1080 <listsessions@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe36(%rip),%rdi
call   1090 <perror@plt>
xor    %eax,%eax
jmp    120a <prompt_run+0x9a>

LLVM IR (-O0):
@.str = [21 x i8] c"\0AInvalid input \22%c\22\0A\00"
@.str.1 = [11 x i8] c"Iteration\0A\00"
@.str.2 = [59 x i8] c"Choose action [login(l)/listSessions(s)] default is login:\00"
@EOF = global i8 0
@.str.3 = [18 x i8] c"Error while read \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @prompt_run() {
%1 = alloca i32
%2 = alloca i8
store i8 0, i8* %2
br label %3
3: ; preds = %39, %0
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %3
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %7, %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%14 = call signext i8 (...) @getchar()
store i8 %14, i8* %2
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = load i8, i8* @EOF
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %16, %18
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %49
22: ; preds = %12
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%24 = load i8, i8* %2
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 10
br i1 %26, label %27, label %28
27: ; preds = %22
store i8 108, i8* %2
br label %30
28: ; preds = %22
%29 = call signext i8 (...) @getchar()
br label %30
30: ; preds = %28, %27
br label %31
31: ; preds = %30
%32 = load i8, i8* %2
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 108
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i8, i8* %2
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 115
br label %39
39: ; preds = %35, %31
%40 = phi i1 [ false, %31 ], [ %38, %35 ]
br i1 %40, label %3, label %41
41: ; preds = %39
%42 = load i8, i8* %2
%43 = sext i8 %42 to i32
switch i32 %43, label %48 [
i32 108, label %44
i32 115, label %46
]
44: ; preds = %41
%45 = call i32 (...) @login()
br label %48
46: ; preds = %41
%47 = call i32 (...) @listsessions()
br label %48
48: ; preds = %41, %46, %44
store i32 1, i32* %1
br label %49
49: ; preds = %48, %20
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
@.str = [21 x i8] c"\0AInvalid input \22%c\22\0A\00"
@.str.2 = [59 x i8] c"Choose action [login(l)/listSessions(s)] default is login:\00"
@EOF = global i8 0
@.str.3 = [18 x i8] c"Error while read \00"
@str = [10 x i8] c"Iteration\00"
define i32 @prompt_run() {
br label %1
1: ; preds = %18, %0
%2 = phi i8 [ 0, %0 ], [ %10, %18 ]
%3 = icmp eq i8 %2, 0
br i1 %3, label %8, label %4
4: ; preds = %1
%5 = sext i8 %2 to i32
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %4, %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call signext i8 (...) @getchar()
%11 = load i8, i8* @EOF
%12 = icmp eq i8 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %24
15: ; preds = %8
%16 = tail call i32 @putchar(i32 10)
%17 = icmp eq i8 %10, 10
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call signext i8 (...) @getchar()
switch i8 %10, label %1 [
i8 108, label %20
i8 115, label %22
]
20: ; preds = %18, %15
%21 = tail call i32 (...) @login()
br label %24
22: ; preds = %18
%23 = tail call i32 (...) @listsessions()
br label %24
24: ; preds = %20, %22, %13
%25 = phi i32 [ 0, %13 ], [ 1, %22 ], [ 1, %20 ]
ret i32 %25
}