#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*/ STDOUT_FILENO;
int get_schar(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int get_prompt(void) {
  char c;
  if (get_schar(&c) == 1) {
    write(STDOUT_FILENO, &c, 1);
    if ((c == 13) || (c == 10)) {
      if (get_schar(&c) == 1) {
        write(STDOUT_FILENO, &c, 1);
        if (c == 'P') {
          if (get_schar(&c) == 1) {
            write(STDOUT_FILENO, &c, 1);
            if (c == 'U') {
              if (get_schar(&c) == 1) {
                write(STDOUT_FILENO, &c, 1);
                if (c == '>') {
                  return (1);
                } else {
                  printf("not a >\n");
                }
              } else {
                printf("no char 4\n");
              }
            } else {
              printf("not a U\n");
            }
          } else {
            printf("no char 3\n");
          }
        } else {
          printf("not a P\n");
        }
      } else {
        printf("no char 2\n");
      }
    } else {
      printf("not a CR\n");
    }
  } else {
    printf("no char 1\n");
  }
  return (0);
}


x86 assembly (clang, -O0):
<get_prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x5(%rbp),%rdi
call   1030 <get_schar@plt>
cmp    $0x1,%eax
jne    12a0 <get_prompt+0x170>
mov    0x2e9f(%rip),%rax
mov    (%rax),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
movsbl -0x5(%rbp),%eax
cmp    $0xd,%eax
je     117b <get_prompt+0x4b>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    128f <get_prompt+0x15f>
lea    -0x5(%rbp),%rdi
call   1030 <get_schar@plt>
cmp    $0x1,%eax
jne    127e <get_prompt+0x14e>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x50,%eax
jne    126d <get_prompt+0x13d>
lea    -0x5(%rbp),%rdi
call   1030 <get_schar@plt>
cmp    $0x1,%eax
jne    125c <get_prompt+0x12c>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x55,%eax
jne    124b <get_prompt+0x11b>
lea    -0x5(%rbp),%rdi
call   1030 <get_schar@plt>
cmp    $0x1,%eax
jne    123a <get_prompt+0x10a>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x3e,%eax
jne    1229 <get_prompt+0xf9>
movl   $0x1,-0x4(%rbp)
jmp    12b3 <get_prompt+0x183>
lea    0xdd0(%rip),%rdi
call   1050 <printf@plt>
jmp    1246 <get_prompt+0x116>
lea    0xdc8(%rip),%rdi
call   1050 <printf@plt>
jmp    1257 <get_prompt+0x127>
lea    0xdc2(%rip),%rdi
call   1050 <printf@plt>
jmp    1268 <get_prompt+0x138>
lea    0xdba(%rip),%rdi
call   1050 <printf@plt>
jmp    1279 <get_prompt+0x149>
lea    0xdb4(%rip),%rdi
call   1050 <printf@plt>
jmp    128a <get_prompt+0x15a>
lea    0xdac(%rip),%rdi
call   1050 <printf@plt>
jmp    129b <get_prompt+0x16b>
lea    0xda6(%rip),%rdi
call   1050 <printf@plt>
jmp    12ac <get_prompt+0x17c>
lea    0xd9f(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_prompt>:
push   %rbx
sub    $0x10,%rsp
lea    0xf(%rsp),%rdi
call   1040 <get_schar@plt>
cmp    $0x1,%eax
jne    11f7 <get_prompt+0xc7>
mov    0x2ea1(%rip),%rbx
mov    (%rbx),%edi
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    0xf(%rsp),%al
cmp    $0xd,%al
je     1170 <get_prompt+0x40>
cmp    $0xa,%al
jne    1200 <get_prompt+0xd0>
lea    0xf(%rsp),%rdi
call   1040 <get_schar@plt>
cmp    $0x1,%eax
jne    1209 <get_prompt+0xd9>
mov    (%rbx),%edi
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
cmpb   $0x50,0xf(%rsp)
jne    1212 <get_prompt+0xe2>
lea    0xf(%rsp),%rdi
call   1040 <get_schar@plt>
cmp    $0x1,%eax
jne    121b <get_prompt+0xeb>
mov    (%rbx),%edi
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
cmpb   $0x55,0xf(%rsp)
jne    1224 <get_prompt+0xf4>
lea    0xf(%rsp),%rdi
call   1040 <get_schar@plt>
cmp    $0x1,%eax
jne    122d <get_prompt+0xfd>
mov    (%rbx),%edi
lea    0xf(%rsp),%rsi
mov    $0x1,%ebx
mov    $0x1,%edx
call   1050 <write@plt>
cmpb   $0x3e,0xf(%rsp)
je     123b <get_prompt+0x10b>
lea    0xe4c(%rip),%rdi
jmp    1234 <get_prompt+0x104>
lea    0xe02(%rip),%rdi
jmp    1234 <get_prompt+0x104>
lea    0xe03(%rip),%rdi
jmp    1234 <get_prompt+0x104>
lea    0xe03(%rip),%rdi
jmp    1234 <get_prompt+0x104>
lea    0xe04(%rip),%rdi
jmp    1234 <get_prompt+0x104>
lea    0xe03(%rip),%rdi
jmp    1234 <get_prompt+0x104>
lea    0xe04(%rip),%rdi
jmp    1234 <get_prompt+0x104>
lea    0xe03(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@.str = [9 x i8] c"not a >\0A\00"
@.str.1 = [11 x i8] c"no char 4\0A\00"
@.str.2 = [9 x i8] c"not a U\0A\00"
@.str.3 = [11 x i8] c"no char 3\0A\00"
@.str.4 = [9 x i8] c"not a P\0A\00"
@.str.5 = [11 x i8] c"no char 2\0A\00"
@.str.6 = [10 x i8] c"not a CR\0A\00"
@.str.7 = [11 x i8] c"no char 1\0A\00"
define i32 @get_prompt() {
%1 = alloca i32
%2 = alloca i8
%3 = call i32 @get_schar(i8* %2)
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %64
5: ; preds = %0
%6 = load i32, i32* @STDOUT_FILENO
%7 = call i32 @write(i32 %6, i8* %2, i32 1)
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 13
br i1 %10, label %15, label %11
11: ; preds = %5
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 10
br i1 %14, label %15, label %61
15: ; preds = %11, %5
%16 = call i32 @get_schar(i8* %2)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %58
18: ; preds = %15
%19 = load i32, i32* @STDOUT_FILENO
%20 = call i32 @write(i32 %19, i8* %2, i32 1)
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 80
br i1 %23, label %24, label %55
24: ; preds = %18
%25 = call i32 @get_schar(i8* %2)
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %52
27: ; preds = %24
%28 = load i32, i32* @STDOUT_FILENO
%29 = call i32 @write(i32 %28, i8* %2, i32 1)
%30 = load i8, i8* %2
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 85
br i1 %32, label %33, label %49
33: ; preds = %27
%34 = call i32 @get_schar(i8* %2)
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %46
36: ; preds = %33
%37 = load i32, i32* @STDOUT_FILENO
%38 = call i32 @write(i32 %37, i8* %2, i32 1)
%39 = load i8, i8* %2
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 62
br i1 %41, label %42, label %43
42: ; preds = %36
store i32 1, i32* %1
br label %67
43: ; preds = %36
%44 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %45
45: ; preds = %43
br label %48
46: ; preds = %33
%47 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %46, %45
br label %51
49: ; preds = %27
%50 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %49, %48
br label %54
52: ; preds = %24
%53 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %54
54: ; preds = %52, %51
br label %57
55: ; preds = %18
%56 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %57
57: ; preds = %55, %54
br label %60
58: ; preds = %15
%59 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %60
60: ; preds = %58, %57
br label %63
61: ; preds = %11
%62 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
br label %63
63: ; preds = %61, %60
br label %66
64: ; preds = %0
%65 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
br label %66
66: ; preds = %64, %63
store i32 0, i32* %1
br label %67
67: ; preds = %66, %42
%68 = load i32, i32* %1
ret i32 %68
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@str = [10 x i8] c"no char 1\00"
@str.8 = [9 x i8] c"not a CR\00"
@str.9 = [10 x i8] c"no char 2\00"
@str.10 = [8 x i8] c"not a P\00"
@str.11 = [10 x i8] c"no char 3\00"
@str.12 = [8 x i8] c"not a U\00"
@str.13 = [10 x i8] c"no char 4\00"
@str.14 = [8 x i8] c"not a >\00"
define i32 @get_prompt() {
%1 = alloca i8
%2 = call i32 @get_schar(i8* %1)
%3 = icmp eq i32 %2, 1
br i1 %3, label %4, label %32
4: ; preds = %0
%5 = load i32, i32* @STDOUT_FILENO
%6 = call i32 @write(i32 %5, i8* %1, i32 1)
%7 = load i8, i8* %1
switch i8 %7, label %32 [
i8 13, label %8
i8 10, label %8
]
8: ; preds = %4, %4
%9 = call i32 @get_schar(i8* %1)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load i32, i32* @STDOUT_FILENO
%13 = call i32 @write(i32 %12, i8* %1, i32 1)
%14 = load i8, i8* %1
%15 = icmp eq i8 %14, 80
br i1 %15, label %16, label %32
16: ; preds = %11
%17 = call i32 @get_schar(i8* %1)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %32
19: ; preds = %16
%20 = load i32, i32* @STDOUT_FILENO
%21 = call i32 @write(i32 %20, i8* %1, i32 1)
%22 = load i8, i8* %1
%23 = icmp eq i8 %22, 85
br i1 %23, label %24, label %32
24: ; preds = %19
%25 = call i32 @get_schar(i8* %1)
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i32, i32* @STDOUT_FILENO
%29 = call i32 @write(i32 %28, i8* %1, i32 1)
%30 = load i8, i8* %1
%31 = icmp eq i8 %30, 62
br i1 %31, label %35, label %32
32: ; preds = %0, %4, %8, %11, %16, %19, %24, %27
%33 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.14, i64 0, i64 0), %27 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.13, i64 0, i64 0), %24 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.12, i64 0, i64 0), %19 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.11, i64 0, i64 0), %16 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.10, i64 0, i64 0), %11 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.9, i64 0, i64 0), %8 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.8, i64 0, i64 0), %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0), %0 ]
%34 = call i32 @puts(i8* dereferenceable(1) %33)
br label %35
35: ; preds = %32, %27
%36 = phi i32 [ 1, %27 ], [ 0, %32 ]
ret i32 %36
}