#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*/ error_print(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
void prompt(char *hotel_current, int *echo_allowed, char *on_or_off) {
  if (!on_or_off) {
    printf("%s%s\n", *hotel_current ? "@" : "",
           *hotel_current ? hotel_current : "hotel-sh");
    return;
  }
  if (!strcmp(on_or_off, "on"))
    *echo_allowed = 1;
  else if (!strcmp(on_or_off, "off"))
    *echo_allowed = 0;
  else
    error_print("Unrecognised operation! Only on or off allowed.");
}


x86 assembly (clang, -O0):
<prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b5 <prompt+0x85>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
lea    0xea8(%rip),%rax
lea    0xea2(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118c <prompt+0x5c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    119c <prompt+0x6c>
lea    0xe75(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    119c <prompt+0x6c>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
jmp    1216 <prompt+0xe6>
mov    -0x18(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11dd <prompt+0xad>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    1216 <prompt+0xe6>
mov    -0x18(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1205 <prompt+0xd5>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    1211 <prompt+0xe1>
lea    0xe0c(%rip),%rdi
call   1050 <error_print@plt>
jmp    1216 <prompt+0xe6>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prompt>:
push   %r14
push   %rbx
push   %rax
test   %rdx,%rdx
je     1178 <prompt+0x48>
mov    %rdx,%rbx
mov    %rsi,%r14
lea    0xecb(%rip),%rsi
mov    %rdx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ab <prompt+0x7b>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11b4 <prompt+0x84>
lea    0xeac(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <error_print@plt>
cmpb   $0x0,(%rdi)
lea    0xe83(%rip),%rax
lea    0xe7d(%rip),%rsi
cmove  %rax,%rsi
lea    0xe74(%rip),%rdx
cmovne %rdi,%rdx
lea    0xe61(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>
movl   $0x1,(%r14)
jmp    11bb <prompt+0x8b>
movl   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s%s\0A\00"
@.str.1 = [2 x i8] c"@\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [9 x i8] c"hotel-sh\00"
@.str.4 = [3 x i8] c"on\00"
@.str.5 = [4 x i8] c"off\00"
@.str.6 = [48 x i8] c"Unrecognised operation! Only on or off allowed.\00"
define void @prompt(i8* %0, i32* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %6
%8 = icmp ne i8* %7, null
br i1 %8, label %26, label %9
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %9
%21 = load i8*, i8** %4
br label %23
22: ; preds = %9
br label %23
23: ; preds = %22, %20
%24 = phi i8* [ %21, %20 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), %22 ]
%25 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %24)
br label %41
26: ; preds = %3
%27 = load i8*, i8** %6
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = load i32*, i32** %5
store i32 1, i32* %31
br label %41
32: ; preds = %26
%33 = load i8*, i8** %6
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %32
%37 = load i32*, i32** %5
store i32 0, i32* %37
br label %40
38: ; preds = %32
%39 = call i32 @error_print(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
br label %41
41: ; preds = %23, %40, %30
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s%s\0A\00"
@.str.1 = [2 x i8] c"@\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [9 x i8] c"hotel-sh\00"
@.str.4 = [3 x i8] c"on\00"
@.str.5 = [4 x i8] c"off\00"
@.str.6 = [48 x i8] c"Unrecognised operation! Only on or off allowed.\00"
define void @prompt(i8* %0, i32* nocapture writeonly %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %5, label %11
5: ; preds = %3
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%9 = select i1 %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %0
%10 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
br label %21
11: ; preds = %3
%12 = tail call i32 @strcmp(i8* %2, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 1, i32* %1
br label %21
15: ; preds = %11
%16 = tail call i32 @strcmp(i8* %2, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 0, i32* %1
br label %21
19: ; preds = %15
%20 = tail call i32 @error_print(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
br label %21
21: ; preds = %18, %19, %5, %14
ret void
}