#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 new_get_prompt(void) {
  char c;
  int nd = 1;
  while ((nd == 1) && (get_schar(&c) == 1)) {
    write(STDOUT_FILENO, &c, 1);
    if ((c != 13) && (c != 10)) {
      nd = 0;
    }
  }
  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");
  }
  return (0);
}


x86 assembly (clang, -O0):
<new_get_prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jne    1160 <new_get_prompt+0x30>
lea    -0x5(%rbp),%rdi
call   1030 <get_schar@plt>
cmp    $0x1,%eax
sete   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1170 <new_get_prompt+0x40>
jmp    11ad <new_get_prompt+0x7d>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
movsbl -0x5(%rbp),%eax
cmp    $0xd,%eax
je     11a8 <new_get_prompt+0x78>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
je     11a8 <new_get_prompt+0x78>
movl   $0x0,-0xc(%rbp)
jmp    113f <new_get_prompt+0xf>
movsbl -0x5(%rbp),%eax
cmp    $0x50,%eax
jne    1276 <new_get_prompt+0x146>
lea    -0x5(%rbp),%rdi
call   1030 <get_schar@plt>
cmp    $0x1,%eax
jne    1265 <new_get_prompt+0x135>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x55,%eax
jne    1254 <new_get_prompt+0x124>
lea    -0x5(%rbp),%rdi
call   1030 <get_schar@plt>
cmp    $0x1,%eax
jne    1243 <new_get_prompt+0x113>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x3e,%eax
jne    1232 <new_get_prompt+0x102>
movl   $0x1,-0x4(%rbp)
jmp    1289 <new_get_prompt+0x159>
lea    0xdc7(%rip),%rdi
call   1050 <printf@plt>
jmp    124f <new_get_prompt+0x11f>
lea    0xdbf(%rip),%rdi
call   1050 <printf@plt>
jmp    1260 <new_get_prompt+0x130>
lea    0xdb9(%rip),%rdi
call   1050 <printf@plt>
jmp    1271 <new_get_prompt+0x141>
lea    0xdb1(%rip),%rdi
call   1050 <printf@plt>
jmp    1282 <new_get_prompt+0x152>
lea    0xdab(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_get_prompt>:
push   %r14
push   %rbx
push   %rax
lea    0x7(%rsp),%rdi
call   1040 <get_schar@plt>
cmp    $0x1,%eax
jne    11f5 <new_get_prompt+0xc5>
mov    0x2ea2(%rip),%r14
lea    0x7(%rsp),%rbx
jmp    1171 <new_get_prompt+0x41>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1040 <get_schar@plt>
cmp    $0x1,%eax
jne    11f5 <new_get_prompt+0xc5>
mov    (%r14),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
movzbl 0x7(%rsp),%eax
cmp    $0xd,%al
je     1160 <new_get_prompt+0x30>
cmp    $0xa,%al
je     1160 <new_get_prompt+0x30>
cmp    $0x50,%al
jne    11fd <new_get_prompt+0xcd>
lea    0x7(%rsp),%rdi
call   1040 <get_schar@plt>
cmp    $0x1,%eax
jne    1206 <new_get_prompt+0xd6>
mov    0x2e48(%rip),%rbx
mov    (%rbx),%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
cmpb   $0x55,0x7(%rsp)
jne    120f <new_get_prompt+0xdf>
lea    0x7(%rsp),%rdi
call   1040 <get_schar@plt>
cmp    $0x1,%eax
jne    1218 <new_get_prompt+0xe8>
mov    (%rbx),%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%ebx
mov    $0x1,%edx
call   1050 <write@plt>
cmpb   $0x3e,0x7(%rsp)
je     1226 <new_get_prompt+0xf6>
lea    0xe31(%rip),%rdi
jmp    121f <new_get_prompt+0xef>
mov    0x7(%rsp),%al
cmp    $0x50,%al
je     1192 <new_get_prompt+0x62>
lea    0xdfc(%rip),%rdi
jmp    121f <new_get_prompt+0xef>
lea    0xdfb(%rip),%rdi
jmp    121f <new_get_prompt+0xef>
lea    0xdfc(%rip),%rdi
jmp    121f <new_get_prompt+0xef>
lea    0xdfb(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
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"
define i32 @new_get_prompt() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 1, i32* %3
br label %4
4: ; preds = %23, %0
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = call i32 @get_schar(i8* %2)
%9 = icmp eq i32 %8, 1
br label %10
10: ; preds = %7, %4
%11 = phi i1 [ false, %4 ], [ %9, %7 ]
br i1 %11, label %12, label %24
12: ; preds = %10
%13 = load i32, i32* @STDOUT_FILENO
%14 = call i32 @write(i32 %13, i8* %2, i32 1)
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 13
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 10
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 0, i32* %3
br label %23
23: ; preds = %22, %18, %12
br label %4
24: ; preds = %10
%25 = load i8, i8* %2
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 80
br i1 %27, label %28, label %59
28: ; preds = %24
%29 = call i32 @get_schar(i8* %2)
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %56
31: ; preds = %28
%32 = load i32, i32* @STDOUT_FILENO
%33 = call i32 @write(i32 %32, i8* %2, i32 1)
%34 = load i8, i8* %2
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 85
br i1 %36, label %37, label %53
37: ; preds = %31
%38 = call i32 @get_schar(i8* %2)
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %50
40: ; preds = %37
%41 = load i32, i32* @STDOUT_FILENO
%42 = call i32 @write(i32 %41, i8* %2, i32 1)
%43 = load i8, i8* %2
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 62
br i1 %45, label %46, label %47
46: ; preds = %40
store i32 1, i32* %1
br label %62
47: ; preds = %40
%48 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %49
49: ; preds = %47
br label %52
50: ; preds = %37
%51 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %52
52: ; preds = %50, %49
br label %55
53: ; preds = %31
%54 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %55
55: ; preds = %53, %52
br label %58
56: ; preds = %28
%57 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %56, %55
br label %61
59: ; preds = %24
%60 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %61
61: ; preds = %59, %58
store i32 0, i32* %1
br label %62
62: ; preds = %61, %46
%63 = load i32, i32* %1
ret i32 %63
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@str = [8 x i8] c"not a P\00"
@str.5 = [10 x i8] c"no char 3\00"
@str.6 = [8 x i8] c"not a U\00"
@str.7 = [10 x i8] c"no char 4\00"
@str.8 = [8 x i8] c"not a >\00"
define i32 @new_get_prompt() {
%1 = alloca i8
%2 = call i32 @get_schar(i8* %1)
%3 = icmp eq i32 %2, 1
br i1 %3, label %6, label %4
4: ; preds = %10, %0
%5 = load i8, i8* %1
br label %13
6: ; preds = %0, %10
%7 = load i32, i32* @STDOUT_FILENO
%8 = call i32 @write(i32 %7, i8* %1, i32 1)
%9 = load i8, i8* %1
switch i8 %9, label %13 [
i8 13, label %10
i8 10, label %10
]
10: ; preds = %6, %6
%11 = call i32 @get_schar(i8* %1)
%12 = icmp eq i32 %11, 1
br i1 %12, label %6, label %4
13: ; preds = %6, %4
%14 = phi i8 [ %5, %4 ], [ %9, %6 ]
%15 = icmp eq i8 %14, 80
br i1 %15, label %16, label %32
16: ; preds = %13
%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 = %13, %16, %19, %24, %27
%33 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.8, i64 0, i64 0), %27 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.7, i64 0, i64 0), %24 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.6, i64 0, i64 0), %19 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0), %16 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0), %13 ]
%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
}