#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  wchar_t *wbase = L"Hello"
                   L", world";
  char *w = (char *)wbase;
  char *s = "Hello"
            ", world";
  int i;
  short foo = 0x0011;
  char little_endian = (int)*(char *)&foo;
  for (i = 0; i < 10; i++) {
    if (w[i * sizeof(wchar_t)] != (little_endian ? s[i] : 0)) {
      {
        printf("Error %d\n", (int)1);
        exit(1);
      };
    }
    if (w[i * sizeof(wchar_t) + (sizeof(wchar_t) - 1)] !=
        (little_endian ? 0 : s[i])) {
      {
        printf("Error %d\n", (int)2);
        exit(2);
      };
    }
  }
  {
    printf("Success\n");
    exit(0);
  };
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xeeb(%rip),%rax
mov    %rax,-0x20(%rbp)
movw   $0x11,-0x26(%rbp)
movsbl -0x26(%rbp),%eax
mov    %al,-0x27(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xa,-0x24(%rbp)
jge    124b <main+0x12b>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x0,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
movsbl -0x27(%rbp),%eax
cmp    $0x0,%eax
je     119f <main+0x7f>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x30(%rbp)
jmp    11a9 <main+0x89>
xor    %eax,%eax
mov    %eax,-0x30(%rbp)
jmp    11a9 <main+0x89>
mov    -0x2c(%rbp),%eax
mov    -0x30(%rbp),%ecx
cmp    %ecx,%eax
je     11d4 <main+0xb4>
lea    0xe83(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x0,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x34(%rbp)
movsbl -0x27(%rbp),%eax
cmp    $0x0,%eax
je     11fe <main+0xde>
xor    %eax,%eax
mov    %eax,-0x38(%rbp)
jmp    120d <main+0xed>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x38(%rbp),%ecx
cmp    %ecx,%eax
je     1238 <main+0x118>
lea    0xe1f(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x2,%edi
call   1040 <exit@plt>
jmp    123d <main+0x11d>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1161 <main+0x41>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i32] [i32 72, i32 101, i32 108, i32 108, i32 111, i32 44, i32 32, i32 119, i32 111, i32 114, i32 108, i32 100, i32 0]
@.str.1 = [13 x i8] c"Hello, world\00"
@.str.2 = [10 x i8] c"Error %d\0A\00"
@.str.3 = [9 x i8] c"Success\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i16
%7 = alloca i8
store i32 0, i32* %1
store i8* bitcast ([13 x i32]* @.str to i8*), i8** %2
%8 = load i8*, i8** %2
store i8* %8, i8** %3
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %4
store i16 17, i16* %6
%9 = bitcast i16* %6 to i8*
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = trunc i32 %11 to i8
store i8 %12, i8* %7
store i32 0, i32* %5
br label %13
13: ; preds = %68, %0
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 10
br i1 %15, label %16, label %71
16: ; preds = %13
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 1
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %16
%28 = load i8*, i8** %4
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
br label %35
34: ; preds = %16
br label %35
35: ; preds = %34, %27
%36 = phi i32 [ %33, %27 ], [ 0, %34 ]
%37 = icmp ne i32 %23, %36
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 1)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %35
%42 = load i8*, i8** %3
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = mul i64 %44, 1
%46 = add i64 %45, 0
%47 = getelementptr inbounds i8, i8* %42, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = load i8, i8* %7
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %41
br label %61
54: ; preds = %41
%55 = load i8*, i8** %4
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
br label %61
61: ; preds = %54, %53
%62 = phi i32 [ 0, %53 ], [ %60, %54 ]
%63 = icmp ne i32 %49, %62
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 2)
%66 = call i32 @exit(i32 2)
unreachable
67: ; preds = %61
br label %68
68: ; preds = %67
%69 = load i32, i32* %5
%70 = add nsw i32 %69, 1
store i32 %70, i32* %5
br label %13
71: ; preds = %13
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%73 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.2 = [10 x i8] c"Error %d\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 2)
%2 = tail call i32 @exit(i32 2)
unreachable
}