#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ InStringFromChar(char, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void WriteInputData(char *input, int cch, FILE *outfile, int baselevel) {
  char out[50];
  char *direction;
  if (baselevel)
    direction = "rtl";
  else
    direction = "ltr";
  fprintf(outfile,
          "<p style = \"letter-spacing: 0.25em; text-indent: 0.25em; "
          "direction: %s;\">",
          direction);
  for (int i = 0; i < cch; i++) {
    InStringFromChar(input[i], out);
    fprintf(outfile, "%s", out);
  }
  fprintf(outfile, "</p>\n");
}


x86 assembly (clang, -O0):
<WriteInputData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1150 <WriteInputData+0x30>
lea    0xeb9(%rip),%rax
mov    %rax,-0x58(%rbp)
jmp    115b <WriteInputData+0x3b>
lea    0xead(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x58(%rbp),%rdx
lea    0xe9e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bf <WriteInputData+0x9f>
mov    -0x8(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
lea    -0x50(%rbp),%rsi
movsbl %al,%edi
call   1040 <InStringFromChar@plt>
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1178 <WriteInputData+0x58>
mov    -0x18(%rbp),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteInputData>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rdx,%r14
mov    %esi,%ebx
mov    %rdi,%r15
test   %ecx,%ecx
lea    0xea6(%rip),%rax
lea    0xe9b(%rip),%rdx
cmove  %rax,%rdx
lea    0xe98(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %ebx,%ebx
jle    11b1 <WriteInputData+0x71>
mov    %ebx,%r12d
xor    %ebx,%ebx
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
mov    %r13,%rsi
call   1050 <InStringFromChar@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1030 <fputs@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1190 <WriteInputData+0x50>
lea    0xe9a(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1060 <fwrite@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"rtl\00"
@.str.1 = [4 x i8] c"ltr\00"
@.str.2 = [74 x i8] c"<p style = \22letter-spacing: 0.25em; text-indent: 0.25em; direction: %s;\22>\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [6 x i8] c"</p>\0A\00"
define void @WriteInputData(i8* %0, i32 %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [50 x i8]
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%12 = load i32, i32* %8
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %10
br label %16
15: ; preds = %4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %10
br label %16
16: ; preds = %15, %14
%17 = load i32*, i32** %7
%18 = load i8*, i8** %10
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i8* %18)
store i32 0, i32* %11
br label %20
20: ; preds = %35, %16
%21 = load i32, i32* %11
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %38
24: ; preds = %20
%25 = load i8*, i8** %5
%26 = load i32, i32* %11
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%31 = call i32 @InStringFromChar(i8 signext %29, i8* %30)
%32 = load i32*, i32** %7
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %24
%36 = load i32, i32* %11
%37 = add nsw i32 %36, 1
store i32 %37, i32* %11
br label %20
38: ; preds = %20
%39 = load i32*, i32** %7
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"rtl\00"
@.str.1 = [4 x i8] c"ltr\00"
@.str.2 = [74 x i8] c"<p style = \22letter-spacing: 0.25em; text-indent: 0.25em; direction: %s;\22>\00"
@.str.4 = [6 x i8] c"</p>\0A\00"
define void @WriteInputData(i8* nocapture %0, i32 %1, i32* nocapture %2, i32 %3) {
%5 = alloca [50 x i8]
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%7 = icmp eq i32 %3, 0
%8 = select i1 %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0)
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = zext i32 %1 to i64
br label %15
13: ; preds = %15, %4
%14 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 5, i64 1, i32* %2)
ret void
15: ; preds = %11, %15
%16 = phi i64 [ 0, %11 ], [ %21, %15 ]
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @InStringFromChar(i8 signext %18, i8* %6)
%20 = call i32 @fputs(i8* %6, i32* %2)
%21 = add nuw nsw i64 %16, 1
%22 = icmp eq i64 %21, %12
br i1 %22, label %13, label %15
}