#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*/ printf(char *, ...);
void print_current_word(char *ptr, int n) {
  int i = 0;
  while (*ptr != '\0' && i < n) {
    printf("%c", *ptr++);
    i++;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_current_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     1147 <print_current_word+0x37>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1157 <print_current_word+0x47>
jmp    1185 <print_current_word+0x75>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <print_current_word+0x16>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_current_word>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     114c <print_current_word+0x3c>
mov    %esi,%r14d
test   %esi,%esi
jle    114c <print_current_word+0x3c>
mov    %rdi,%rbx
mov    $0x1,%ebp
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx,%rbp,1),%eax
test   %al,%al
je     114c <print_current_word+0x3c>
lea    0x1(%rbp),%rcx
cmp    %r14d,%ebp
mov    %rcx,%rbp
jl     1130 <print_current_word+0x20>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_current_word(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %17, %2
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br label %15
15: ; preds = %11, %6
%16 = phi i1 [ false, %6 ], [ %14, %11 ]
br i1 %16, label %17, label %25
17: ; preds = %15
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
%20 = load i8, i8* %18
%21 = sext i8 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %6
25: ; preds = %15
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
define void @print_current_word(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp ne i8 %3, 0
%5 = icmp sgt i32 %1, 0
%6 = and i1 %4, %5
br i1 %6, label %7, label %19
7: ; preds = %2, %7
%8 = phi i8 [ %15, %7 ], [ %3, %2 ]
%9 = phi i32 [ %14, %7 ], [ 0, %2 ]
%10 = phi i8* [ %12, %7 ], [ %0, %2 ]
%11 = sext i8 %8 to i32
%12 = getelementptr inbounds i8, i8* %10, i64 1
%13 = tail call i32 @putchar(i32 %11)
%14 = add nuw nsw i32 %9, 1
%15 = load i8, i8* %12
%16 = icmp ne i8 %15, 0
%17 = icmp slt i32 %14, %1
%18 = select i1 %16, i1 %17, i1 false
br i1 %18, label %7, label %19
19: ; preds = %7, %2
%20 = tail call i32 @putchar(i32 10)
ret void
}