#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int htobe32(int);
int htole32(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  union {
    uint32_t u32;
    uint8_t arr[4];
  } x;
  x.arr[0] = 0x11;
  x.arr[1] = 0x22;
  x.arr[2] = 0x33;
  x.arr[3] = 0x44;
  printf("x.u32 = 0x%x\n", x.u32);
  printf("htole32(x.u32) = 0x%x\n", htole32(x.u32));
  printf("htobe32(x.u32) = 0x%x\n", htobe32(x.u32));
  printf("0x%x\n", *(uint32_t *)&x);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x11,-0x20(%rbp)
movl   $0x22,-0x1c(%rbp)
movl   $0x33,-0x18(%rbp)
movl   $0x44,-0x14(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
call   1030 <htole32@plt>
mov    %eax,%esi
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
call   1050 <htobe32@plt>
mov    %eax,%esi
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
mov    $0x11,%esi
call   1040 <printf@plt>
mov    $0x11,%edi
call   1030 <htole32@plt>
lea    0xeab(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x11,%edi
call   1050 <htobe32@plt>
lea    0xeaa(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
mov    $0x11,%esi
call   1040 <printf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%union.anon = type { [4 x i32] }
@.str = [14 x i8] c"x.u32 = 0x%x\0A\00"
@.str.1 = [23 x i8] c"htole32(x.u32) = 0x%x\0A\00"
@.str.2 = [23 x i8] c"htobe32(x.u32) = 0x%x\0A\00"
@.str.3 = [6 x i8] c"0x%x\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %union.anon
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = bitcast %union.anon* %6 to [4 x i32]*
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
store i32 17, i32* %8
%9 = bitcast %union.anon* %6 to [4 x i32]*
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 1
store i32 34, i32* %10
%11 = bitcast %union.anon* %6 to [4 x i32]*
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %11, i64 0, i64 2
store i32 51, i32* %12
%13 = bitcast %union.anon* %6 to [4 x i32]*
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %13, i64 0, i64 3
store i32 68, i32* %14
%15 = bitcast %union.anon* %6 to i32*
%16 = load i32, i32* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = bitcast %union.anon* %6 to i32*
%19 = load i32, i32* %18
%20 = call i32 @htole32(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = bitcast %union.anon* %6 to i32*
%23 = load i32, i32* %22
%24 = call i32 @htobe32(i32 %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = bitcast %union.anon* %6 to i32*
%27 = load i32, i32* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @EXIT_SUCCESS
%30 = call i32 @exit(i32 %29)
unreachable
}

LLVM IR (-O2):
@.str = [14 x i8] c"x.u32 = 0x%x\0A\00"
@.str.1 = [23 x i8] c"htole32(x.u32) = 0x%x\0A\00"
@.str.2 = [23 x i8] c"htobe32(x.u32) = 0x%x\0A\00"
@.str.3 = [6 x i8] c"0x%x\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 17)
%4 = tail call i32 @htole32(i32 17)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = tail call i32 @htobe32(i32 17)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 17)
%9 = load i32, i32* @EXIT_SUCCESS
%10 = tail call i32 @exit(i32 %9)
unreachable
}