#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*/ mirror(char *, int *, int);
int /*<<< orphan*/ reorder(int, char *, int *, int);
int resolveLines(char *, char *, int);
int /*<<< orphan*/ resolveWhitespace(int, int *, int *, int);
void BidiLines(int baselevel, char *pszLine, int *pclsLine, int *plevelLine,
               int cchPara, int fMirror, char *pbrk) {
  int cchLine = 0;
  do {
    cchLine = resolveLines(pszLine, pbrk, cchPara);
    resolveWhitespace(baselevel, pclsLine, plevelLine, cchLine);
    if (fMirror) {
      mirror(pszLine, plevelLine, cchLine);
    }
    reorder(baselevel, pszLine, plevelLine, cchLine);
    pszLine += cchLine;
    plevelLine += cchLine;
    pbrk += pbrk ? cchLine : 0;
    pclsLine += cchLine;
    cchPara -= cchLine;
  } while (cchPara);
}


x86 assembly (clang, -O0):
<BidiLines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1060 <resolveLines@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
call   1050 <resolveWhitespace@plt>
cmpl   $0x0,-0x28(%rbp)
je     11aa <BidiLines+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <mirror@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
call   1040 <reorder@plt>
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,0x10(%rbp)
je     11f9 <BidiLines+0xb9>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    1203 <BidiLines+0xc3>
xor    %eax,%eax
mov    %eax,-0x30(%rbp)
jmp    1203 <BidiLines+0xc3>
mov    -0x30(%rbp),%ecx
mov    0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,0x10(%rbp)
mov    -0x2c(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x2c(%rbp),%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    116a <BidiLines+0x2a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BidiLines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0x10(%rsp)
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %edi,%r15d
mov    0x50(%rsp),%r14
mov    %edi,0xc(%rsp)
jmp    11a8 <BidiLines+0x68>
nopw   0x0(%rax,%rax,1)
mov    0xc(%rsp),%r15d
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r13d,%ecx
call   1040 <reorder@plt>
movslq %r13d,%rax
add    %rax,%rbp
lea    (%rbx,%rax,4),%rbx
test   %r14,%r14
lea    (%r12,%rax,4),%r12
cmove  %r14,%rax
add    %rax,%r14
mov    0x14(%rsp),%r8d
sub    %r13d,%r8d
je     11e5 <BidiLines+0xa5>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r8d,0x14(%rsp)
mov    %r8d,%edx
call   1060 <resolveLines@plt>
mov    %eax,%r13d
mov    %r15d,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1050 <resolveWhitespace@plt>
cmpl   $0x0,0x10(%rsp)
je     1170 <BidiLines+0x30>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r13d,%edx
call   1030 <mirror@plt>
jmp    1170 <BidiLines+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @BidiLines(i32 %0, i8* %1, i32* %2, i32* %3, i32 %4, i32 %5, i8* %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
store i32 %0, i32* %8
store i8* %1, i8** %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i8* %6, i8** %14
store i32 0, i32* %15
br label %16
16: ; preds = %64, %7
%17 = load i8*, i8** %9
%18 = load i8*, i8** %14
%19 = load i32, i32* %12
%20 = call i32 @resolveLines(i8* %17, i8* %18, i32 %19)
store i32 %20, i32* %15
%21 = load i32, i32* %8
%22 = load i32*, i32** %10
%23 = load i32*, i32** %11
%24 = load i32, i32* %15
%25 = call i32 @resolveWhitespace(i32 %21, i32* %22, i32* %23, i32 %24)
%26 = load i32, i32* %13
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %16
%29 = load i8*, i8** %9
%30 = load i32*, i32** %11
%31 = load i32, i32* %15
%32 = call i32 @mirror(i8* %29, i32* %30, i32 %31)
br label %33
33: ; preds = %28, %16
%34 = load i32, i32* %8
%35 = load i8*, i8** %9
%36 = load i32*, i32** %11
%37 = load i32, i32* %15
%38 = call i32 @reorder(i32 %34, i8* %35, i32* %36, i32 %37)
%39 = load i32, i32* %15
%40 = load i8*, i8** %9
%41 = sext i32 %39 to i64
%42 = getelementptr inbounds i8, i8* %40, i64 %41
store i8* %42, i8** %9
%43 = load i32, i32* %15
%44 = load i32*, i32** %11
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i32, i32* %44, i64 %45
store i32* %46, i32** %11
%47 = load i8*, i8** %14
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %51
49: ; preds = %33
%50 = load i32, i32* %15
br label %52
51: ; preds = %33
br label %52
52: ; preds = %51, %49
%53 = phi i32 [ %50, %49 ], [ 0, %51 ]
%54 = load i8*, i8** %14
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds i8, i8* %54, i64 %55
store i8* %56, i8** %14
%57 = load i32, i32* %15
%58 = load i32*, i32** %10
%59 = sext i32 %57 to i64
%60 = getelementptr inbounds i32, i32* %58, i64 %59
store i32* %60, i32** %10
%61 = load i32, i32* %15
%62 = load i32, i32* %12
%63 = sub nsw i32 %62, %61
store i32 %63, i32* %12
br label %64
64: ; preds = %52
%65 = load i32, i32* %12
%66 = icmp ne i32 %65, 0
br i1 %66, label %16, label %67
67: ; preds = %64
ret void
}

LLVM IR (-O2):
define void @BidiLines(i32 %0, i8* %1, i32* %2, i32* %3, i32 %4, i32 %5, i8* %6) {
%8 = icmp eq i32 %5, 0
br label %9
9: ; preds = %19, %7
%10 = phi i32* [ %2, %7 ], [ %27, %19 ]
%11 = phi i32* [ %3, %7 ], [ %23, %19 ]
%12 = phi i32 [ %4, %7 ], [ %28, %19 ]
%13 = phi i8* [ %1, %7 ], [ %22, %19 ]
%14 = phi i8* [ %6, %7 ], [ %26, %19 ]
%15 = tail call i32 @resolveLines(i8* %13, i8* %14, i32 %12)
%16 = tail call i32 @resolveWhitespace(i32 %0, i32* %10, i32* %11, i32 %15)
br i1 %8, label %19, label %17
17: ; preds = %9
%18 = tail call i32 @mirror(i8* %13, i32* %11, i32 %15)
br label %19
19: ; preds = %17, %9
%20 = tail call i32 @reorder(i32 %0, i8* %13, i32* %11, i32 %15)
%21 = sext i32 %15 to i64
%22 = getelementptr inbounds i8, i8* %13, i64 %21
%23 = getelementptr inbounds i32, i32* %11, i64 %21
%24 = icmp eq i8* %14, null
%25 = select i1 %24, i64 0, i64 %21
%26 = getelementptr inbounds i8, i8* %14, i64 %25
%27 = getelementptr inbounds i32, i32* %10, i64 %21
%28 = sub nsw i32 %12, %15
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %9
30: ; preds = %19
ret void
}