#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 wchar_t;

/* Variables and functions */
scalar_t__ WEOF;
int /*<<< orphan*/ err(int, int /*<<< orphan*/ *);
scalar_t__ iswprint(int);
scalar_t__ iswspace(int);
scalar_t__ putwchar(int);
int /*<<< orphan*/ wprintf(char *, int);
void wr_fputs(wchar_t *s) {
  for (; *s != L'\0'; ++s) {
    if (*s == L'\n') {
      if (putwchar(L'\r') == WEOF)
        err(1, NULL);
      ;
      if (putwchar(L'\n') == WEOF)
        err(1, NULL);
      ;
    } else if (iswprint(*s) || iswspace(*s)) {
      if (putwchar(*s) == WEOF)
        err(1, NULL);
      ;
    } else {
      wprintf(L"<0x%X>", *s);
    }
  }
  return;
}


x86 assembly (clang, -O0):
<wr_fputs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
je     1250 <wr_fputs+0x100>
mov    -0x8(%rbp),%rax
cmpl   $0xa,(%rax)
jne    11cb <wr_fputs+0x7b>
mov    $0xd,%edi
call   1060 <putwchar@plt>
mov    0x2e59(%rip),%rcx
cmp    (%rcx),%rax
jne    119e <wr_fputs+0x4e>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <err@plt>
mov    $0xa,%edi
call   1060 <putwchar@plt>
mov    0x2e31(%rip),%rcx
cmp    (%rcx),%rax
jne    11c6 <wr_fputs+0x76>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <err@plt>
jmp    123a <wr_fputs+0xea>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1070 <iswprint@plt>
cmp    $0x0,%rax
jne    11f5 <wr_fputs+0xa5>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1050 <iswspace@plt>
cmp    $0x0,%rax
je     1223 <wr_fputs+0xd3>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1060 <putwchar@plt>
mov    0x2dd9(%rip),%rcx
cmp    (%rcx),%rax
jne    121e <wr_fputs+0xce>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <err@plt>
jmp    1235 <wr_fputs+0xe5>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xdd0(%rip),%rdi
call   1040 <wprintf@plt>
jmp    123a <wr_fputs+0xea>
jmp    123f <wr_fputs+0xef>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    115c <wr_fputs+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wr_fputs>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2e81(%rip),%r15
lea    0xe9a(%rip),%r14
jmp    1184 <wr_fputs+0x34>
mov    (%rbx),%esi
mov    %r14,%rdi
call   1040 <wprintf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x4,%rbx
mov    (%rbx),%edi
cmp    $0xa,%edi
je     11b0 <wr_fputs+0x60>
test   %edi,%edi
je     11ec <wr_fputs+0x9c>
call   1070 <iswprint@plt>
test   %rax,%rax
jne    11a5 <wr_fputs+0x55>
mov    (%rbx),%edi
call   1050 <iswspace@plt>
test   %rax,%rax
je     1168 <wr_fputs+0x18>
mov    (%rbx),%edi
jmp    11d0 <wr_fputs+0x80>
nopl   0x0(%rax)
mov    $0xd,%edi
call   1060 <putwchar@plt>
cmp    (%r15),%rax
jne    11cb <wr_fputs+0x7b>
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <err@plt>
mov    $0xa,%edi
call   1060 <putwchar@plt>
cmp    (%r15),%rax
jne    1180 <wr_fputs+0x30>
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <err@plt>
add    $0x4,%rbx
jmp    1184 <wr_fputs+0x34>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@WEOF = global i64 0
@.str = [7 x i32] [i32 60, i32 48, i32 120, i32 37, i32 88, i32 62, i32 0]
define void @wr_fputs(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
br label %3
3: ; preds = %49, %1
%4 = load i32*, i32** %2
%5 = load i32, i32* %4
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %52
7: ; preds = %3
%8 = load i32*, i32** %2
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 10
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = call i64 @putwchar(i32 13)
%13 = load i64, i64* @WEOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @err(i32 1, i32* null)
br label %17
17: ; preds = %15, %11
%18 = call i64 @putwchar(i32 10)
%19 = load i64, i64* @WEOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @err(i32 1, i32* null)
br label %23
23: ; preds = %21, %17
br label %48
24: ; preds = %7
%25 = load i32*, i32** %2
%26 = load i32, i32* %25
%27 = call i64 @iswprint(i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %24
%30 = load i32*, i32** %2
%31 = load i32, i32* %30
%32 = call i64 @iswspace(i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %43
34: ; preds = %29, %24
%35 = load i32*, i32** %2
%36 = load i32, i32* %35
%37 = call i64 @putwchar(i32 %36)
%38 = load i64, i64* @WEOF
%39 = icmp eq i64 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = call i32 @err(i32 1, i32* null)
br label %42
42: ; preds = %40, %34
br label %47
43: ; preds = %29
%44 = load i32*, i32** %2
%45 = load i32, i32* %44
%46 = call i32 @wprintf(i8* bitcast ([7 x i32]* @.str to i8*), i32 %45)
br label %47
47: ; preds = %43, %42
br label %48
48: ; preds = %47, %23
br label %49
49: ; preds = %48
%50 = load i32*, i32** %2
%51 = getelementptr inbounds i32, i32* %50, i32 1
store i32* %51, i32** %2
br label %3
52: ; preds = %3
ret void
}

LLVM IR (-O2):
@WEOF = global i64 0
@.str = [7 x i32] [i32 60, i32 48, i32 120, i32 37, i32 88, i32 62, i32 0]
define void @wr_fputs(i32* nocapture %0) {
br label %2
2: ; preds = %34, %1
%3 = phi i32* [ %0, %1 ], [ %35, %34 ]
%4 = load i32, i32* %3
switch i32 %4, label %17 [
i32 0, label %36
i32 10, label %5
]
5: ; preds = %2
%6 = tail call i64 @putwchar(i32 13)
%7 = load i64, i64* @WEOF
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @err(i32 1, i32* null)
br label %11
11: ; preds = %9, %5
%12 = tail call i64 @putwchar(i32 10)
%13 = load i64, i64* @WEOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %34
15: ; preds = %11
%16 = tail call i32 @err(i32 1, i32* null)
br label %34
17: ; preds = %2
%18 = tail call i64 @iswprint(i32 %4)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %3
%22 = tail call i64 @iswspace(i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %20, %17
%25 = load i32, i32* %3
%26 = tail call i64 @putwchar(i32 %25)
%27 = load i64, i64* @WEOF
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = tail call i32 @err(i32 1, i32* null)
br label %34
31: ; preds = %20
%32 = load i32, i32* %3
%33 = tail call i32 @wprintf(i8* bitcast ([7 x i32]* @.str to i8*), i32 %32)
br label %34
34: ; preds = %15, %11, %24, %29, %31
%35 = getelementptr inbounds i32, i32* %3, i64 1
br label %2
36: ; preds = %2
ret void
}