#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 scan_any(char *, int *, char);
int scanto(char *, int *, char);
int /*<<< orphan*/ show_result(char const *, int);
void show_OperatingStatus(char *report) {
  int pos = 0;
  int Ps1 = scan_any(report, &pos, 'n');
  int Ps2 = scanto(report, &pos, 'n');
  const char *show;
  switch (Ps1) {
  case 0:
    show = "Terminal is in good operating condition";
    break;
  case 3:
    show = "Terminal has a malfunction";
    break;
  default:
    show = "failed";
  }
  show_result(show, Ps2);
}


x86 assembly (clang, -O0):
<show_OperatingStatus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    %rsi,-0x30(%rbp)
mov    $0x6e,%edx
mov    %edx,-0x28(%rbp)
call   1040 <scan_any@plt>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <scanto@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
test   %eax,%eax
je     1196 <show_OperatingStatus+0x66>
jmp    1185 <show_OperatingStatus+0x55>
mov    -0x24(%rbp),%eax
sub    $0x3,%eax
je     11a6 <show_OperatingStatus+0x76>
jmp    11b6 <show_OperatingStatus+0x86>
lea    0xe63(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11c1 <show_OperatingStatus+0x91>
lea    0xe7b(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11c1 <show_OperatingStatus+0x91>
lea    0xe86(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <show_result@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_OperatingStatus>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%r14
mov    %r14,%rsi
mov    $0x6e,%edx
call   1040 <scan_any@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6e,%edx
call   1030 <scanto@plt>
cmp    $0x3,%ebp
lea    0xeb7(%rip),%rcx
lea    0xecb(%rip),%rdx
cmove  %rcx,%rdx
test   %ebp,%ebp
lea    0xe7b(%rip),%rdi
cmovne %rdx,%rdi
mov    %eax,%esi
call   1050 <show_result@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Terminal is in good operating condition\00"
@.str.1 = [27 x i8] c"Terminal has a malfunction\00"
@.str.2 = [7 x i8] c"failed\00"
define void @show_OperatingStatus(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
%7 = load i8*, i8** %2
%8 = call i32 @scan_any(i8* %7, i32* %3, i8 signext 110)
store i32 %8, i32* %4
%9 = load i8*, i8** %2
%10 = call i32 @scanto(i8* %9, i32* %3, i8 signext 110)
store i32 %10, i32* %5
%11 = load i32, i32* %4
switch i32 %11, label %14 [
i32 0, label %12
i32 3, label %13
]
12: ; preds = %1
store i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8** %6
br label %15
13: ; preds = %1
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %15
14: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %6
br label %15
15: ; preds = %14, %13, %12
%16 = load i8*, i8** %6
%17 = load i32, i32* %5
%18 = call i32 @show_result(i8* %16, i32 %17)
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"Terminal is in good operating condition\00"
@.str.1 = [27 x i8] c"Terminal has a malfunction\00"
@.str.2 = [7 x i8] c"failed\00"
define void @show_OperatingStatus(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = call i32 @scan_any(i8* %0, i32* %2, i8 signext 110)
%5 = call i32 @scanto(i8* %0, i32* %2, i8 signext 110)
%6 = icmp eq i32 %4, 3
%7 = select i1 %6, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0)
%8 = icmp eq i32 %4, 0
%9 = select i1 %8, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %7
%10 = call i32 @show_result(i8* %9, i32 %5)
ret void
}