#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*/ fputc(char const, int /*<<< orphan*/ *);
void print_element_by_chars(const char *element, const int N_chars,
                            FILE *stream) {
  int i = 0;
  if (element == NULL)
    return;
  for (i = 0; i < N_chars; i++) {
    fputc(*(element + i), stream);
  }
  return;
}


x86 assembly (clang, -O0):
<print_element_by_chars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113a <print_element_by_chars+0x2a>
jmp    1177 <print_element_by_chars+0x67>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1172 <print_element_by_chars+0x62>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <print_element_by_chars+0x31>
jmp    1177 <print_element_by_chars+0x67>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_element_by_chars>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1146 <print_element_by_chars+0x36>
test   %esi,%esi
jle    1146 <print_element_by_chars+0x36>
mov    %rdx,%r14
mov    %rdi,%r15
mov    %esi,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl (%r15,%rbx,1),%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <print_element_by_chars+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @print_element_by_chars(i8* %0, i32 %1, i32* nocapture %2) {
%4 = icmp ne i8* %0, null
%5 = icmp sgt i32 %1, 0
%6 = and i1 %4, %5
br i1 %6, label %7, label %16
7: ; preds = %3
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %14, %9 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = tail call i32 @fputc(i8 signext %12, i32* %2)
%14 = add nuw nsw i64 %10, 1
%15 = icmp eq i64 %14, %8
br i1 %15, label %16, label %9
16: ; preds = %9, %3
ret void
}