#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*/ scif_putchar(char);
void scif_puts(unsigned char *foo) {
  int i = 0;
  while (foo[i] != 0) {
    scif_putchar(foo[i]);
    if (foo[i] == '\n')
      scif_putchar('\r');
    i++;
  }
}


x86 assembly (clang, -O0):
<scif_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1176 <scif_puts+0x66>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <scif_putchar@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1168 <scif_puts+0x58>
mov    $0xd,%edi
call   1030 <scif_putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <scif_puts+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scif_puts>:
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1145 <scif_puts+0x35>
mov    %rdi,%rbx
add    $0x1,%rbx
jmp    112b <scif_puts+0x1b>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1145 <scif_puts+0x35>
movsbl %al,%edi
call   1030 <scif_putchar@plt>
cmpb   $0xa,-0x1(%rbx)
jne    1120 <scif_puts+0x10>
mov    $0xd,%edi
call   1030 <scif_putchar@plt>
jmp    1120 <scif_puts+0x10>
pop    %rbx
ret

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

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