#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 rn_choice(int, int);
int text(int, char *, int);
int /*<<< orphan*/ xmlc_white_space(char);
int textws(int p, char *s, int n) {
  int p1 = text(p, s, n), ws = 1;
  char *end = s + n;
  while (s != end) {
    if (!xmlc_white_space(*s)) {
      ws = 0;
      break;
    }
    ++s;
  }
  return ws ? rn_choice(p, p1) : p1;
}


x86 assembly (clang, -O0):
<textws>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <text@plt>
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     11aa <textws+0x7a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <xmlc_white_space@plt>
cmp    $0x0,%eax
jne    1199 <textws+0x69>
movl   $0x0,-0x1c(%rbp)
jmp    11aa <textws+0x7a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    116a <textws+0x3a>
cmpl   $0x0,-0x1c(%rbp)
je     11c7 <textws+0x97>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <rn_choice@plt>
mov    %eax,-0x2c(%rbp)
jmp    11cd <textws+0x9d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<textws>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r12
mov    %edi,%r15d
call   1030 <text@plt>
mov    %eax,%r14d
test   %ebp,%ebp
je     1177 <textws+0x47>
movslq %ebp,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%r12,%rbx,1),%edi
call   1040 <xmlc_white_space@plt>
test   %eax,%eax
je     118a <textws+0x5a>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <textws+0x30>
mov    %r15d,%edi
mov    %r14d,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <rn_choice@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @textws(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i32, i32* %4
%11 = load i8*, i8** %5
%12 = load i32, i32* %6
%13 = call i32 @text(i32 %10, i8* %11, i32 %12)
store i32 %13, i32* %7
store i32 1, i32* %8
%14 = load i8*, i8** %5
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
store i8* %17, i8** %9
br label %18
18: ; preds = %28, %3
%19 = load i8*, i8** %5
%20 = load i8*, i8** %9
%21 = icmp ne i8* %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i8*, i8** %5
%24 = load i8, i8* %23
%25 = call i32 @xmlc_white_space(i8 signext %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %22
store i32 0, i32* %8
br label %31
28: ; preds = %22
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %5
br label %18
31: ; preds = %27, %18
%32 = load i32, i32* %8
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i32, i32* %4
%36 = load i32, i32* %7
%37 = call i32 @rn_choice(i32 %35, i32 %36)
br label %40
38: ; preds = %31
%39 = load i32, i32* %7
br label %40
40: ; preds = %38, %34
%41 = phi i32 [ %37, %34 ], [ %39, %38 ]
ret i32 %41
}

LLVM IR (-O2):
define i32 @textws(i32 %0, i8* %1, i32 %2) {
%4 = tail call i32 @text(i32 %0, i8* %1, i32 %2)
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %1, i64 %5
%7 = icmp eq i32 %2, 0
br i1 %7, label %16, label %10
8: ; preds = %10
%9 = icmp eq i8* %15, %6
br i1 %9, label %16, label %10
10: ; preds = %3, %8
%11 = phi i8* [ %15, %8 ], [ %1, %3 ]
%12 = load i8, i8* %11
%13 = tail call i32 @xmlc_white_space(i8 signext %12)
%14 = icmp eq i32 %13, 0
%15 = getelementptr inbounds i8, i8* %11, i64 1
br i1 %14, label %18, label %8
16: ; preds = %8, %3
%17 = tail call i32 @rn_choice(i32 %0, i32 %4)
br label %18
18: ; preds = %10, %16
%19 = phi i32 [ %17, %16 ], [ %4, %10 ]
ret i32 %19
}