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

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int printf(char *, ...);
int wcslen(char *);
main() {
  wchar_t *wstring =
      L"Now is the time for all good men to come to the aid of their country";
  int i;
  int ret;
  printf("wcslen(wstring) = %d\n", wcslen(wstring));
  for (i = 0; i < wcslen(wstring); i++) {
    ret = printf("%lc", wstring[i]);
    if (ret != 1) {
      printf("printf returned: %d\n", ret);
      perror("Linux says");
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <wcslen@plt>
mov    %eax,%esi
lea    0xfb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <wcslen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11dd <main+0xad>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xf91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
je     11ca <main+0x9a>
mov    -0x18(%rbp),%esi
lea    0xf77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf7e(%rip),%rdi
call   1050 <perror@plt>
jmp    11cf <main+0x9f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <main+0x3a>
lea    0xf5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xfd4(%rip),%rdi
mov    $0x44,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xead(%rip),%r12
lea    0xfd0(%rip),%r13
lea    0xfcd(%rip),%r14
lea    0xfdb(%rip),%r15
xor    %ebx,%ebx
jmp    117a <main+0x4a>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x44,%rbx
je     11a4 <main+0x74>
movsbl (%rbx,%r12,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%eax
je     1170 <main+0x40>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1050 <perror@plt>
jmp    1170 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [69 x i32] [i32 78, i32 111, i32 119, i32 32, i32 105, i32 115, i32 32, i32 116, i32 104, i32 101, i32 32, i32 116, i32 105, i32 109, i32 101, i32 32, i32 102, i32 111, i32 114, i32 32, i32 97, i32 108, i32 108, i32 32, i32 103, i32 111, i32 111, i32 100, i32 32, i32 109, i32 101, i32 110, i32 32, i32 116, i32 111, i32 32, i32 99, i32 111, i32 109, i32 101, i32 32, i32 116, i32 111, i32 32, i32 116, i32 104, i32 101, i32 32, i32 97, i32 105, i32 100, i32 32, i32 111, i32 102, i32 32, i32 116, i32 104, i32 101, i32 105, i32 114, i32 32, i32 99, i32 111, i32 117, i32 110, i32 116, i32 114, i32 121, i32 0]
@.str.1 = [22 x i8] c"wcslen(wstring) = %d\0A\00"
@.str.2 = [4 x i8] c"%lc\00"
@.str.3 = [21 x i8] c"printf returned: %d\0A\00"
@.str.4 = [11 x i8] c"Linux says\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i8* bitcast ([69 x i32]* @.str to i8*), i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @wcslen(i8* %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %6)
store i32 0, i32* %3
br label %8
8: ; preds = %28, %0
%9 = load i32, i32* %3
%10 = load i8*, i8** %2
%11 = call i32 @wcslen(i8* %10)
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %31
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %19)
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 1
br i1 %22, label %23, label %27
23: ; preds = %13
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %23, %13
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %8
31: ; preds = %8
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [69 x i32] [i32 78, i32 111, i32 119, i32 32, i32 105, i32 115, i32 32, i32 116, i32 104, i32 101, i32 32, i32 116, i32 105, i32 109, i32 101, i32 32, i32 102, i32 111, i32 114, i32 32, i32 97, i32 108, i32 108, i32 32, i32 103, i32 111, i32 111, i32 100, i32 32, i32 109, i32 101, i32 110, i32 32, i32 116, i32 111, i32 32, i32 99, i32 111, i32 109, i32 101, i32 32, i32 116, i32 111, i32 32, i32 116, i32 104, i32 101, i32 32, i32 97, i32 105, i32 100, i32 32, i32 111, i32 102, i32 32, i32 116, i32 104, i32 101, i32 105, i32 114, i32 32, i32 99, i32 111, i32 117, i32 110, i32 116, i32 114, i32 121, i32 0]
@.str.1 = [22 x i8] c"wcslen(wstring) = %d\0A\00"
@.str.2 = [4 x i8] c"%lc\00"
@.str.3 = [21 x i8] c"printf returned: %d\0A\00"
@.str.4 = [11 x i8] c"Linux says\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 68)
br label %2
2: ; preds = %0, %12
%3 = phi i64 [ 0, %0 ], [ %13, %12 ]
%4 = getelementptr inbounds i8, i8* bitcast ([69 x i32]* @.str to i8*), i64 %3
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = icmp eq i32 %7, 1
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%11 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %12
12: ; preds = %2, %9
%13 = add nuw nsw i64 %3, 1
%14 = icmp eq i64 %13, 68
br i1 %14, label %15, label %2
15: ; preds = %12
%16 = tail call i32 @putchar(i32 10)
ret i32 0
}