#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 printf(char *, char *);
int oc_print_from_dll(char *buf) {
  char *cp;
  for (cp = buf; *cp != '\0'; ++cp) {
    if (*cp == '\n') {
      *cp = '\r';
    } else if (*cp == '\r') {
      *cp = '\n';
    }
  }
  return printf("%s", buf);
}


x86 assembly (clang, -O0):
<oc_print_from_dll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1182 <oc_print_from_dll+0x72>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1150 <oc_print_from_dll+0x40>
mov    -0x10(%rbp),%rax
movb   $0xd,(%rax)
jmp    116c <oc_print_from_dll+0x5c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    1167 <oc_print_from_dll+0x57>
mov    -0x10(%rbp),%rax
movb   $0xa,(%rax)
jmp    116c <oc_print_from_dll+0x5c>
jmp    1171 <oc_print_from_dll+0x61>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <oc_print_from_dll+0x14>
mov    -0x8(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oc_print_from_dll>:
mov    %rdi,%rsi
mov    %rdi,%rax
jmp    1128 <oc_print_from_dll+0x18>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%cl
mov    %cl,(%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0xa,%cl
je     1140 <oc_print_from_dll+0x30>
cmp    $0xd,%cl
je     1120 <oc_print_from_dll+0x10>
test   %cl,%cl
jne    1124 <oc_print_from_dll+0x14>
jmp    1144 <oc_print_from_dll+0x34>
nopl   0x0(%rax,%rax,1)
mov    $0xd,%cl
jmp    1122 <oc_print_from_dll+0x12>
lea    0xeb5(%rip),%rdi
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @oc_print_from_dll(i8* %0) {
br label %2
2: ; preds = %8, %1
%3 = phi i8* [ %0, %1 ], [ %9, %8 ]
%4 = load i8, i8* %3
switch i8 %4, label %8 [
i8 0, label %10
i8 10, label %6
i8 13, label %5
]
5: ; preds = %2
br label %6
6: ; preds = %2, %5
%7 = phi i8 [ 10, %5 ], [ 13, %2 ]
store i8 %7, i8* %3
br label %8
8: ; preds = %6, %2
%9 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
10: ; preds = %2
%11 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
ret i32 %11
}