#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 PrintChar(char *buf, char c, int length, int ladjust) {
  int i;
  if (length < 1)
    length = 1;
  if (ladjust) {
    *buf = c;
    for (i = 1; i < length; i++)
      buf[i] = ' ';
  } else {
    for (i = 0; i < length - 1; i++)
      buf[i] = ' ';
    buf[length - 1] = c;
  }
  return length;
}


x86 assembly (clang, -O0):
<PrintChar>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x1,-0x10(%rbp)
jge    1125 <PrintChar+0x25>
movl   $0x1,-0x10(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     116a <PrintChar+0x6a>
mov    -0x9(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1165 <PrintChar+0x65>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113f <PrintChar+0x3f>
jmp    11af <PrintChar+0xaf>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    119c <PrintChar+0x9c>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1171 <PrintChar+0x71>
mov    -0x9(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintChar>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r14
test   %edx,%edx
mov    $0x1,%ebx
cmovg  %edx,%ebx
test   %ecx,%ecx
je     114c <PrintChar+0x3c>
mov    %bpl,(%r14)
cmp    $0x2,%edx
jl     1176 <PrintChar+0x66>
add    $0x1,%r14
lea    -0x2(%rbx),%edx
add    $0x1,%rdx
mov    %r14,%rdi
mov    $0x20,%esi
call   1030 <memset@plt>
jmp    1176 <PrintChar+0x66>
lea    -0x1(%rbx),%r15d
cmp    $0x2,%edx
jl     116f <PrintChar+0x5f>
cmp    $0x2,%r15d
mov    $0x1,%edx
cmovge %r15d,%edx
mov    %r14,%rdi
mov    $0x20,%esi
call   1030 <memset@plt>
mov    %r15d,%eax
mov    %bpl,(%r14,%rax,1)
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @PrintChar(i8* %0, i8 signext %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8 %1, i8* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %4
store i32 1, i32* %7
br label %13
13: ; preds = %12, %4
%14 = load i32, i32* %8
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %32
16: ; preds = %13
%17 = load i8, i8* %6
%18 = load i8*, i8** %5
store i8 %17, i8* %18
store i32 1, i32* %9
br label %19
19: ; preds = %28, %16
%20 = load i32, i32* %9
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %31
23: ; preds = %19
%24 = load i8*, i8** %5
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
store i8 32, i8* %27
br label %28
28: ; preds = %23
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
store i32 %30, i32* %9
br label %19
31: ; preds = %19
br label %53
32: ; preds = %13
store i32 0, i32* %9
br label %33
33: ; preds = %43, %32
%34 = load i32, i32* %9
%35 = load i32, i32* %7
%36 = sub nsw i32 %35, 1
%37 = icmp slt i32 %34, %36
br i1 %37, label %38, label %46
38: ; preds = %33
%39 = load i8*, i8** %5
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
store i8 32, i8* %42
br label %43
43: ; preds = %38
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %33
46: ; preds = %33
%47 = load i8, i8* %6
%48 = load i8*, i8** %5
%49 = load i32, i32* %7
%50 = sub nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %48, i64 %51
store i8 %47, i8* %52
br label %53
53: ; preds = %46, %31
%54 = load i32, i32* %7
ret i32 %54
}

LLVM IR (-O2):
define i32 @PrintChar(i8* nocapture writeonly %0, i8 signext %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %2, 1
%6 = select i1 %5, i32 %2, i32 1
%7 = icmp eq i32 %3, 0
br i1 %7, label %8, label %13
8: ; preds = %4
%9 = add nsw i32 %6, -1
br i1 %5, label %10, label %19
10: ; preds = %8
%11 = call i32 @llvm.smax.i32(i32 %9, i32 1)
%12 = zext i32 %11 to i64
br label %19
13: ; preds = %4
store i8 %1, i8* %0
br i1 %5, label %14, label %22
14: ; preds = %13
%15 = getelementptr i8, i8* %0, i64 1
%16 = add nsw i32 %6, -2
%17 = zext i32 %16 to i64
%18 = add nuw nsw i64 %17, 1
br label %22
19: ; preds = %10, %8
%20 = zext i32 %9 to i64
%21 = getelementptr inbounds i8, i8* %0, i64 %20
store i8 %1, i8* %21
br label %22
22: ; preds = %14, %13, %19
ret i32 %6
}