#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 */
struct CONSOLE {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ cons_putchar(struct CONSOLE *, unsigned char, int);
void cons_putstr1(struct CONSOLE *cons, char *s, int l) {
  unsigned char *sz = (unsigned char *)s;
  int i;
  for (i = 0; i < l; i++) {
    cons_putchar(cons, sz[i], 1);
  }
  return;
}


x86 assembly (clang, -O0):
<cons_putstr1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1166 <cons_putstr1+0x56>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    $0x1,%edx
movzbl (%rax,%rcx,1),%esi
call   1030 <cons_putchar@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1132 <cons_putstr1+0x22>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cons_putstr1>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    114b <cons_putstr1+0x3b>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%esi
mov    %r15,%rdi
mov    $0x1,%edx
call   1030 <cons_putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <cons_putstr1+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.CONSOLE = type { i32 }
define void @cons_putstr1(%struct.CONSOLE* %0, i8* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %14
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %12, %7 ]
%9 = getelementptr inbounds i8, i8* %1, i64 %8
%10 = load i8, i8* %9
%11 = tail call i32 @cons_putchar(%struct.CONSOLE* %0, i8 zeroext %10, i32 1)
%12 = add nuw nsw i64 %8, 1
%13 = icmp eq i64 %12, %6
br i1 %13, label %14, label %7
14: ; preds = %7, %3
ret void
}