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

/* Variables and functions */
int BIG_ENDIAN;
int BYTE_ORDER;
int LITTLE_ENDIAN;
int PDP_ENDIAN;
int be32toh(int);
int htobe32(int);
int htonl(int);
int ntohl(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  uint32_t i = ntohl(0x01234567);
  printf("%.2x\n", i);
  i = ntohl(0x67452301);
  printf("%.2x\n", i);
  i = htonl(0x67452301);
  printf("%.2x\n", i);
  i = htonl(0x01234567);
  printf("%.2x\n", i);
  printf("%.2x\n", 0x01234567 + 0x67452301);
  printf("%d\n", 0x01234567 + 0x67452301);
  printf("%d\n", BYTE_ORDER == LITTLE_ENDIAN);
  printf("%d\n", BYTE_ORDER);
  printf("%d\n", LITTLE_ENDIAN);
  printf("%d\n", BIG_ENDIAN);
  printf("%d\n", PDP_ENDIAN);
  printf("%x\n", htobe32(1000));
  printf("%x\n", be32toh(1000));
  printf("%x\n", be32toh(0xe8030000));
  printf("%x\n", htobe32(0xe8030000));
  return 0;
}


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)
mov    $0x1234567,%edi
call   1070 <ntohl@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    $0x67452301,%edi
call   1070 <ntohl@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    $0x67452301,%edi
call   1040 <htonl@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1234567,%edi
call   1040 <htonl@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
lea    0xe23(%rip),%rdi
mov    $0x68686868,%esi
call   1030 <printf@plt>
lea    0xe18(%rip),%rdi
mov    $0x68686868,%esi
call   1030 <printf@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%eax
mov    0x2dd8(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xded(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dab(%rip),%rax
mov    (%rax),%esi
lea    0xdd8(%rip),%rdi
call   1030 <printf@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%esi
lea    0xdc3(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%esi
lea    0xdae(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%esi
lea    0xd99(%rip),%rdi
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <htobe32@plt>
mov    %eax,%esi
lea    0xd85(%rip),%rdi
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1050 <be32toh@plt>
mov    %eax,%esi
lea    0xd6d(%rip),%rdi
call   1030 <printf@plt>
mov    $0xe8030000,%edi
call   1050 <be32toh@plt>
mov    %eax,%esi
lea    0xd55(%rip),%rdi
call   1030 <printf@plt>
mov    $0xe8030000,%edi
call   1060 <htobe32@plt>
mov    %eax,%esi
lea    0xd3d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x1234567,%edi
call   1070 <ntohl@plt>
lea    0xe9a(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x67452301,%edi
call   1070 <ntohl@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x67452301,%edi
call   1040 <htonl@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x1234567,%edi
call   1040 <htonl@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x68686868,%esi
call   1030 <printf@plt>
lea    0xe46(%rip),%rbx
mov    %rbx,%rdi
mov    $0x68686868,%esi
call   1030 <printf@plt>
mov    0x2dfc(%rip),%r14
mov    (%r14),%eax
mov    0x2e02(%rip),%r15
xor    %esi,%esi
cmp    (%r15),%eax
sete   %sil
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%r15),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1060 <htobe32@plt>
lea    0xdd2(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1050 <be32toh@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0xe8030000,%edi
call   1050 <be32toh@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0xe8030000,%edi
call   1060 <htobe32@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%.2x\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@BYTE_ORDER = global i32 0
@LITTLE_ENDIAN = global i32 0
@BIG_ENDIAN = global i32 0
@PDP_ENDIAN = global i32 0
@.str.2 = [4 x i8] c"%x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @ntohl(i32 19088743)
store i32 %7, i32* %6
%8 = load i32, i32* %6
%9 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @ntohl(i32 1732584193)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 @htonl(i32 1732584193)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = call i32 @htonl(i32 19088743)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 1751672936)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1751672936)
%21 = load i32, i32* @BYTE_ORDER
%22 = load i32, i32* @LITTLE_ENDIAN
%23 = icmp eq i32 %21, %22
%24 = zext i1 %23 to i32
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @BYTE_ORDER
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i32, i32* @LITTLE_ENDIAN
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* @BIG_ENDIAN
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i32, i32* @PDP_ENDIAN
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = call i32 @htobe32(i32 1000)
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = call i32 @be32toh(i32 1000)
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = call i32 @be32toh(i32 -402456576)
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = call i32 @htobe32(i32 -402456576)
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%.2x\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@BYTE_ORDER = global i32 0
@LITTLE_ENDIAN = global i32 0
@BIG_ENDIAN = global i32 0
@PDP_ENDIAN = global i32 0
@.str.2 = [4 x i8] c"%x\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @ntohl(i32 19088743)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @ntohl(i32 1732584193)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @htonl(i32 1732584193)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @htonl(i32 19088743)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 1751672936)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1751672936)
%13 = load i32, i32* @BYTE_ORDER
%14 = load i32, i32* @LITTLE_ENDIAN
%15 = icmp eq i32 %13, %14
%16 = zext i1 %15 to i32
%17 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @BYTE_ORDER
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* @LITTLE_ENDIAN
%21 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @BIG_ENDIAN
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @PDP_ENDIAN
%25 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = tail call i32 @htobe32(i32 1000)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = tail call i32 @be32toh(i32 1000)
%29 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = tail call i32 @be32toh(i32 -402456576)
%31 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = tail call i32 @htobe32(i32 -402456576)
%33 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %32)
ret i32 0
}