#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 scanto(char *, int *, char);
int /*<<< orphan*/ show_result(char *, char const *);
void show_PrinterStatus(char *report) {
  int pos = 0;
  int code = scanto(report, &pos, 'n');
  const char *show;
  switch (code) {
  case 13:
    show = "No printer";
    break;
  case 10:
    show = "Printer ready";
    break;
  case 11:
    show = "Printer not ready";
    break;
  case 18:
    show = "Printer busy";
    break;
  case 19:
    show = "Printer assigned to other session";
    break;
  default:
    show = "failed";
  }
  show_result("%s", show);
}


x86 assembly (clang, -O0):
<show_PrinterStatus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x6e,%edx
call   1030 <scanto@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x9,%eax
ja     11c1 <show_PrinterStatus+0xa1>
mov    -0x20(%rbp),%rax
lea    0xe98(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb0(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11cc <show_PrinterStatus+0xac>
lea    0xeab(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11cc <show_PrinterStatus+0xac>
lea    0xea9(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11cc <show_PrinterStatus+0xac>
lea    0xeab(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11cc <show_PrinterStatus+0xac>
lea    0xea8(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11cc <show_PrinterStatus+0xac>
lea    0xeba(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1040 <show_result@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_PrinterStatus>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    $0x6e,%edx
call   1030 <scanto@plt>
add    $0xfffffff6,%eax
cmp    $0x9,%eax
ja     1152 <show_PrinterStatus+0x32>
cltq
lea    0xf1b(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
jmp    1159 <show_PrinterStatus+0x39>
lea    0xf01(%rip),%rsi
lea    0xf01(%rip),%rdi
call   1040 <show_result@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [11 x i8] c"No printer\00"
@.str.1 = [14 x i8] c"Printer ready\00"
@.str.2 = [18 x i8] c"Printer not ready\00"
@.str.3 = [13 x i8] c"Printer busy\00"
@.str.4 = [34 x i8] c"Printer assigned to other session\00"
@.str.5 = [7 x i8] c"failed\00"
@.str.6 = [3 x i8] c"%s\00"
define void @show_PrinterStatus(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
%6 = load i8*, i8** %2
%7 = call i32 @scanto(i8* %6, i32* %3, i8 signext 110)
store i32 %7, i32* %4
%8 = load i32, i32* %4
switch i32 %8, label %14 [
i32 13, label %9
i32 10, label %10
i32 11, label %11
i32 18, label %12
i32 19, label %13
]
9: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %5
br label %15
10: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %15
11: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8** %5
br label %15
12: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %5
br label %15
13: ; preds = %1
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8** %5
br label %15
14: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8** %5
br label %15
15: ; preds = %14, %13, %12, %11, %10, %9
%16 = load i8*, i8** %5
%17 = call i32 @show_result(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %16)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"No printer\00"
@.str.1 = [14 x i8] c"Printer ready\00"
@.str.2 = [18 x i8] c"Printer not ready\00"
@.str.3 = [13 x i8] c"Printer busy\00"
@.str.4 = [34 x i8] c"Printer assigned to other session\00"
@.str.5 = [7 x i8] c"failed\00"
@.str.6 = [3 x i8] c"%s\00"
@reltable.show_PrinterStatus = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.show_PrinterStatus to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.show_PrinterStatus to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.show_PrinterStatus to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.show_PrinterStatus to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.show_PrinterStatus to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.show_PrinterStatus to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.show_PrinterStatus to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.show_PrinterStatus to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.show_PrinterStatus to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.show_PrinterStatus to i64)) to i32)]
define void @show_PrinterStatus(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = call i32 @scanto(i8* %0, i32* %2, i8 signext 110)
%5 = add i32 %4, -10
%6 = icmp ult i32 %5, 10
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.show_PrinterStatus to i8*), i64 %9)
br label %11
11: ; preds = %1, %7
%12 = phi i8* [ %10, %7 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), %1 ]
%13 = call i32 @show_result(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %12)
ret void
}