#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 /*<<< orphan*/ un8;
typedef int /*<<< orphan*/ u16;
typedef int /*<<< orphan*/ s16;
typedef int /*<<< orphan*/ n8;
typedef int /*<<< orphan*/ n64f;

/* Variables and functions */
unsigned short htons(unsigned short);
int /*<<< orphan*/ printf(char *, int, unsigned short);
int /*<<< orphan*/ write(char *, ...);
int main() {
  int i;
  char n8[] = {127, 1, 0, -1, -2, -128};
  unsigned char un8[] = {255, 1, 0};
  double n64f[] = {-9.1819281981e3, -10, -0.11, 0, 0.11, 10};
  unsigned short int u16[] = {65535, 65534, 1, 0};
  short int s16[] = {32767, 128, 1, 0, -1, -129, -32768};
  write("t/examples/n8", &un8, sizeof(un8));
  write("t/examples/-n8", &n8, sizeof(n8));
  write("t/examples/u16", &u16, sizeof(u16));
  for (i = 0; i < sizeof(u16) / 2; i++) {
    printf("%d %d\n", i, u16[i]);
    u16[i] = htons(u16[i]);
    printf("%d %d\n", i, u16[i]);
  }
  write("t/examples/n16", &u16, sizeof(u16));
  write("t/examples/s16", &s16, sizeof(s16));
  write("t/examples/n64f", &n64f, sizeof(n64f));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xed3(%rip),%eax
mov    %eax,-0xe(%rbp)
mov    0xecd(%rip),%ax
mov    %ax,-0xa(%rbp)
mov    0xed2(%rip),%ax
mov    %ax,-0x11(%rbp)
mov    0xeca(%rip),%al
mov    %al,-0xf(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1060 <memset@plt>
movsd  0xe91(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe7c(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe67(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe52(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe3d(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0xed1(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xe54(%rip),%rax
mov    %rax,-0x66(%rbp)
mov    0xe52(%rip),%eax
mov    %eax,-0x5e(%rbp)
mov    0xe4c(%rip),%ax
mov    %ax,-0x5a(%rbp)
lea    0xe46(%rip),%rdi
lea    -0x11(%rbp),%rsi
mov    $0x3,%edx
mov    $0x0,%al
call   1030 <write@plt>
lea    0xe3d(%rip),%rdi
lea    -0xe(%rbp),%rsi
mov    $0x6,%edx
mov    $0x0,%al
call   1030 <write@plt>
lea    0xe35(%rip),%rdi
lea    -0x58(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1030 <write@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
cmp    $0x4,%rax
jae    12a4 <main+0x164>
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rax
lea    0xe11(%rip),%rdi
movzwl -0x58(%rbp,%rax,2),%edx
call   1050 <printf@plt>
movslq -0x8(%rbp),%rax
movzwl -0x58(%rbp,%rax,2),%edi
call   1040 <htons@plt>
mov    %ax,%cx
movslq -0x8(%rbp),%rax
mov    %cx,-0x58(%rbp,%rax,2)
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rax
lea    0xddf(%rip),%rdi
movzwl -0x58(%rbp,%rax,2),%edx
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    123e <main+0xfe>
lea    0xdc7(%rip),%rdi
lea    -0x58(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1030 <write@plt>
lea    0xdbf(%rip),%rdi
lea    -0x66(%rbp),%rsi
mov    $0xe,%edx
mov    $0x0,%al
call   1030 <write@plt>
lea    0xdb7(%rip),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x30,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
movw   $0x80fe,0x1c(%rsp)
movl   $0xff00017f,0x18(%rsp)
ff
movb   $0x0,0x16(%rsp)
movw   $0x1ff,0x14(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe9f(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movabs $0xbfbc28f5c28f5c29,%rax
28 bc bf
mov    %rax,0x40(%rsp)
movaps 0xe94(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movabs $0x1fffeffff,%rax
mov    %rax,0x8(%rsp)
mov    0xe95(%rip),%rax
mov    %rax,0x26(%rsp)
mov    0xe83(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xe88(%rip),%rdi
lea    0x14(%rsp),%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xe7e(%rip),%rdi
lea    0x18(%rsp),%rsi
mov    $0x6,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xe75(%rip),%rdi
lea    0x8(%rsp),%r14
mov    $0x8,%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <write@plt>
movzwl 0x8(%rsp),%edx
lea    0xe64(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <printf@plt>
movzwl 0x8(%rsp),%edi
call   1040 <htons@plt>
mov    %ax,0x8(%rsp)
movzwl %ax,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <printf@plt>
movzwl 0xa(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <printf@plt>
movzwl 0xa(%rsp),%edi
call   1040 <htons@plt>
mov    %ax,0xa(%rsp)
movzwl %ax,%edx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <printf@plt>
movzwl 0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1050 <printf@plt>
movzwl 0xc(%rsp),%edi
call   1040 <htons@plt>
mov    %ax,0xc(%rsp)
movzwl %ax,%edx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1050 <printf@plt>
movzwl 0xe(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1050 <printf@plt>
movzwl 0xe(%rsp),%edi
call   1040 <htons@plt>
mov    %ax,0xe(%rsp)
movzwl %ax,%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1050 <printf@plt>
lea    0xdab(%rip),%rdi
mov    $0x8,%edx
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <write@plt>
lea    0xda4(%rip),%rdi
lea    0x20(%rsp),%rsi
mov    $0xe,%edx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xd9b(%rip),%rdi
lea    0x30(%rsp),%rsi
mov    $0x30,%edx
xor    %eax,%eax
call   1030 <write@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.n8 = [6 x i8] c"\7F\01\00\FF\FE\80"
@__const.main.un8 = [3 x i8] c"\FF\01\00"
@__const.main.u16 = [4 x i16] [i16 -1, i16 -2, i16 1, i16 0]
@__const.main.s16 = [7 x i16] [i16 32767, i16 128, i16 1, i16 0, i16 -1, i16 -129, i16 -32768]
@.str = [14 x i8] c"t/examples/n8\00"
@.str.1 = [15 x i8] c"t/examples/-n8\00"
@.str.2 = [15 x i8] c"t/examples/u16\00"
@.str.3 = [7 x i8] c"%d %d\0A\00"
@.str.4 = [15 x i8] c"t/examples/n16\00"
@.str.5 = [15 x i8] c"t/examples/s16\00"
@.str.6 = [16 x i8] c"t/examples/n64f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [6 x i8]
%4 = alloca [3 x i8]
%5 = alloca [6 x double]
%6 = alloca [4 x i16]
%7 = alloca [7 x i16]
store i32 0, i32* %1
%8 = bitcast [6 x i8]* %3 to i8*
%9 = bitcast [3 x i8]* %4 to i8*
%10 = bitcast [6 x double]* %5 to i8*
%11 = bitcast i8* %10 to [6 x double]*
%12 = getelementptr inbounds [6 x double], [6 x double]* %11, i32 0, i32 0
store double 0xC0C1EEF6CF3201DB, double* %12
%13 = getelementptr inbounds [6 x double], [6 x double]* %11, i32 0, i32 1
store double -1.000000e+01, double* %13
%14 = getelementptr inbounds [6 x double], [6 x double]* %11, i32 0, i32 2
store double -1.100000e-01, double* %14
%15 = getelementptr inbounds [6 x double], [6 x double]* %11, i32 0, i32 4
store double 1.100000e-01, double* %15
%16 = getelementptr inbounds [6 x double], [6 x double]* %11, i32 0, i32 5
store double 1.000000e+01, double* %16
%17 = bitcast [4 x i16]* %6 to i8*
%18 = bitcast [7 x i16]* %7 to i8*
%19 = call i32 (i8*, ...) @write(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), [3 x i8]* %4, i64 3)
%20 = call i32 (i8*, ...) @write(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), [6 x i8]* %3, i64 6)
%21 = call i32 (i8*, ...) @write(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), [4 x i16]* %6, i64 8)
store i32 0, i32* %2
br label %22
22: ; preds = %47, %0
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = icmp ult i64 %24, 4
br i1 %25, label %26, label %50
26: ; preds = %22
%27 = load i32, i32* %2
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [4 x i16], [4 x i16]* %6, i64 0, i64 %29
%31 = load i16, i16* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %27, i16 zeroext %31)
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [4 x i16], [4 x i16]* %6, i64 0, i64 %34
%36 = load i16, i16* %35
%37 = call zeroext i16 @htons(i16 zeroext %36)
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [4 x i16], [4 x i16]* %6, i64 0, i64 %39
store i16 %37, i16* %40
%41 = load i32, i32* %2
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [4 x i16], [4 x i16]* %6, i64 0, i64 %43
%45 = load i16, i16* %44
%46 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %41, i16 zeroext %45)
br label %47
47: ; preds = %26
%48 = load i32, i32* %2
%49 = add nsw i32 %48, 1
store i32 %49, i32* %2
br label %22
50: ; preds = %22
%51 = call i32 (i8*, ...) @write(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), [4 x i16]* %6, i64 8)
%52 = call i32 (i8*, ...) @write(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), [7 x i16]* %7, i64 14)
%53 = call i32 (i8*, ...) @write(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), [6 x double]* %5, i64 48)
%54 = load i32, i32* %1
ret i32 %54
}

LLVM IR (-O2):
@__const.main.n8 = [6 x i8] c"\7F\01\00\FF\FE\80"
@__const.main.un8 = [3 x i8] c"\FF\01\00"
@__const.main.s16 = [7 x i16] [i16 32767, i16 128, i16 1, i16 0, i16 -1, i16 -129, i16 -32768]
@.str = [14 x i8] c"t/examples/n8\00"
@.str.1 = [15 x i8] c"t/examples/-n8\00"
@.str.2 = [15 x i8] c"t/examples/u16\00"
@.str.3 = [7 x i8] c"%d %d\0A\00"
@.str.4 = [15 x i8] c"t/examples/n16\00"
@.str.5 = [15 x i8] c"t/examples/s16\00"
@.str.6 = [16 x i8] c"t/examples/n64f\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [3 x i8]
%3 = alloca [6 x double]
%4 = alloca i64
%5 = bitcast i64* %4 to [4 x i16]*
%6 = alloca [7 x i16]
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%9 = bitcast [6 x double]* %3 to i8*
%10 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 2
%11 = bitcast double* %10 to i8*
%12 = bitcast [6 x double]* %3 to <2 x double>*
store <2 x double> <double 0xC0C1EEF6CF3201DB, double -1.000000e+01>, <2 x double>* %12
%13 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 2
store double -1.100000e-01, double* %13
%14 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 4
%15 = bitcast double* %14 to <2 x double>*
store <2 x double> <double 1.100000e-01, double 1.000000e+01>, <2 x double>* %15
%16 = bitcast i64* %4 to i8*
store i64 8589869055, i64* %4
%17 = bitcast [7 x i16]* %6 to i8*
%18 = call i32 (i8*, ...) @write(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), [3 x i8]* %2, i64 3)
%19 = call i32 (i8*, ...) @write(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), [6 x i8]* %1, i64 6)
%20 = call i32 (i8*, ...) @write(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i64* %4, i64 8)
%21 = bitcast i64* %4 to i16*
%22 = load i16, i16* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 0, i16 zeroext %22)
%24 = load i16, i16* %21
%25 = call zeroext i16 @htons(i16 zeroext %24)
store i16 %25, i16* %21
%26 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 0, i16 zeroext %25)
%27 = getelementptr inbounds [4 x i16], [4 x i16]* %5, i64 0, i64 1
%28 = load i16, i16* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 1, i16 zeroext %28)
%30 = load i16, i16* %27
%31 = call zeroext i16 @htons(i16 zeroext %30)
store i16 %31, i16* %27
%32 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 1, i16 zeroext %31)
%33 = getelementptr inbounds [4 x i16], [4 x i16]* %5, i64 0, i64 2
%34 = load i16, i16* %33
%35 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 2, i16 zeroext %34)
%36 = load i16, i16* %33
%37 = call zeroext i16 @htons(i16 zeroext %36)
store i16 %37, i16* %33
%38 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 2, i16 zeroext %37)
%39 = getelementptr inbounds [4 x i16], [4 x i16]* %5, i64 0, i64 3
%40 = load i16, i16* %39
%41 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 3, i16 zeroext %40)
%42 = load i16, i16* %39
%43 = call zeroext i16 @htons(i16 zeroext %42)
store i16 %43, i16* %39
%44 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 3, i16 zeroext %43)
%45 = call i32 (i8*, ...) @write(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i64* %4, i64 8)
%46 = call i32 (i8*, ...) @write(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), [7 x i16]* %6, i64 14)
%47 = call i32 (i8*, ...) @write(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), [6 x double]* %3, i64 48)
ret i32 0
}