#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*/ putchar(char);
int puts(const char *string) {
  while (*string) {
    if ((1) & (*string == '\n')) {
      putchar('\r');
    }
    putchar(*string++);
  }
  if ((1) & (*string == '\n')) {
    putchar('\r');
  }
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     116d <puts+0x5d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1151 <puts+0x41>
mov    $0xd,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
call   1030 <putchar@plt>
jmp    111c <puts+0xc>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1195 <puts+0x85>
mov    $0xd,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<puts>:
push   %rbx
mov    %rdi,%rbx
jmp    1139 <puts+0x29>
cs nopw 0x0(%rax,%rax,1)
mov    $0xd,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
cmp    $0xa,%al
je     1120 <puts+0x10>
test   %al,%al
jne    112d <puts+0x1d>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @puts(i8* nocapture %0) {
br label %2
2: ; preds = %8, %1
%3 = phi i8* [ %0, %1 ], [ %10, %8 ]
%4 = load i8, i8* %3
switch i8 %4, label %8 [
i8 0, label %12
i8 10, label %5
]
5: ; preds = %2
%6 = tail call i32 @putchar(i8 signext 13)
%7 = load i8, i8* %3
br label %8
8: ; preds = %2, %5
%9 = phi i8 [ %4, %2 ], [ %7, %5 ]
%10 = getelementptr inbounds i8, i8* %3, i64 1
%11 = tail call i32 @putchar(i8 signext %9)
br label %2
12: ; preds = %2
%13 = tail call i32 @putchar(i8 signext 10)
ret i32 0
}