#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*/ insert_char(char, int);
int /*<<< orphan*/ putchar(char);
void print_word(int space_len, char *buf, int length, int max_len) {
  insert_char(' ', space_len);
  for (int i = 0; i < length && i < max_len; i++)
    putchar(buf[i]);
}


x86 assembly (clang, -O0):
<print_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x20,%edi
call   1040 <insert_char@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x1d(%rbp)
jge    1166 <print_word+0x46>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1176 <print_word+0x56>
jmp    1195 <print_word+0x75>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1149 <print_word+0x29>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_word>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%ebp
mov    %edx,%ebx
mov    %rsi,%r14
mov    %edi,%esi
mov    $0x20,%edi
call   1040 <insert_char@plt>
test   %ebx,%ebx
jle    1163 <print_word+0x43>
test   %ebp,%ebp
jle    1163 <print_word+0x43>
add    $0xffffffff,%ebp
add    $0xffffffff,%ebx
cmp    %ebx,%ebp
cmovb  %ebp,%ebx
add    $0x1,%ebx
xor    %ebp,%ebp
nop
movsbl (%r14,%rbp,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1150 <print_word+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @print_word(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = call i32 @insert_char(i8 signext 32, i32 %10)
store i32 0, i32* %9
br label %12
12: ; preds = %29, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* %9
%18 = load i32, i32* %8
%19 = icmp slt i32 %17, %18
br label %20
20: ; preds = %16, %12
%21 = phi i1 [ false, %12 ], [ %19, %16 ]
br i1 %21, label %22, label %32
22: ; preds = %20
%23 = load i8*, i8** %6
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = call i32 @putchar(i8 signext %27)
br label %29
29: ; preds = %22
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
br label %12
32: ; preds = %20
ret void
}

LLVM IR (-O2):
define void @print_word(i32 %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32 @insert_char(i8 signext 32, i32 %0)
%6 = icmp sgt i32 %2, 0
%7 = icmp sgt i32 %3, 0
%8 = and i1 %6, %7
br i1 %8, label %9, label %15
9: ; preds = %4
%10 = add nsw i32 %3, -1
%11 = add nsw i32 %2, -1
%12 = call i32 @llvm.umin.i32(i32 %10, i32 %11)
%13 = add nuw nsw i32 %12, 1
%14 = zext i32 %13 to i64
br label %16
15: ; preds = %16, %4
ret void
16: ; preds = %9, %16
%17 = phi i64 [ 0, %9 ], [ %21, %16 ]
%18 = getelementptr inbounds i8, i8* %1, i64 %17
%19 = load i8, i8* %18
%20 = tail call i32 @putchar(i8 signext %19)
%21 = add nuw nsw i64 %17, 1
%22 = icmp eq i64 %21, %14
br i1 %22, label %15, label %16
}