#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*/ out_print(char *);
int shell();
void run_shell() {
  int value;
  do {
    value = shell();
    if (value == 1)
      out_print("\nerror within command function\n");
    else if (value == 2)
      out_print("\ncommand not recognized('help' for all commands)\n");
  } while (value != -1);
}


x86 assembly (clang, -O0):
<run_shell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <shell@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    114d <run_shell+0x2d>
lea    0xebd(%rip),%rdi
call   1030 <out_print@plt>
jmp    1168 <run_shell+0x48>
cmpl   $0x2,-0x4(%rbp)
jne    1163 <run_shell+0x43>
lea    0xec2(%rip),%rdi
call   1030 <out_print@plt>
jmp    1168 <run_shell+0x48>
jmp    116d <run_shell+0x4d>
cmpl   $0xffffffff,-0x4(%rbp)
jne    1128 <run_shell+0x8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_shell>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rbx
lea    0xeee(%rip),%r14
jmp    1148 <run_shell+0x28>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <out_print@plt>
xor    %eax,%eax
call   1040 <shell@plt>
mov    %rbx,%rdi
cmp    $0x1,%eax
je     1143 <run_shell+0x23>
cmp    $0x2,%eax
je     1140 <run_shell+0x20>
cmp    $0xffffffff,%eax
jne    1148 <run_shell+0x28>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"\0Aerror within command function\0A\00"
@.str.1 = [50 x i8] c"\0Acommand not recognized('help' for all commands)\0A\00"
define void @run_shell() {
%1 = alloca i32
br label %2
2: ; preds = %15, %0
%3 = call i32 (...) @shell()
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = call i32 @out_print(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %14
8: ; preds = %2
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @out_print(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
br label %14
14: ; preds = %13, %6
br label %15
15: ; preds = %14
%16 = load i32, i32* %1
%17 = icmp ne i32 %16, -1
br i1 %17, label %2, label %18
18: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"\0Aerror within command function\0A\00"
@.str.1 = [50 x i8] c"\0Acommand not recognized('help' for all commands)\0A\00"
define void @run_shell() {
br label %1
1: ; preds = %6, %0
%2 = tail call i32 (...) @shell()
switch i32 %2, label %6 [
i32 1, label %3
i32 2, label %7
i32 -1, label %8
]
3: ; preds = %1, %7
%4 = phi i8* [ getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), %7 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), %1 ]
%5 = tail call i32 @out_print(i8* %4)
br label %6
6: ; preds = %3, %1
br label %1
7: ; preds = %1
br label %3
8: ; preds = %1
ret void
}