#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 my_ntohl(int);
int ntohl(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  uint32_t u;
  uint32_t t;
  u = 0x00000011;
  u = ntohl(u);
  printf("ntohl(u)    == %u\n", u);
  u = 0x00000011;
  u = my_ntohl(u);
  printf("my_ntohl(u) == %u\n", u);
  t = 0x00000011;
  if (!(((char *)&t)[0]))
    printf("little endian\n");
  else
    printf("big endian\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x11,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <ntohl@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x11,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <my_ntohl@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x11,-0xc(%rbp)
cmpb   $0x0,-0xc(%rbp)
jne    11a9 <main+0x79>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b7 <main+0x87>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x11,%edi
call   1060 <ntohl@plt>
lea    0xeae(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x11,%edi
call   1050 <my_ntohl@plt>
lea    0xea7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"ntohl(u) == %u\0A\00"
@.str.1 = [19 x i8] c"my_ntohl(u) == %u\0A\00"
@.str.2 = [15 x i8] c"little endian\0A\00"
@.str.3 = [12 x i8] c"big endian\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 17, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @ntohl(i32 %4)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 17, i32* %2
%8 = load i32, i32* %2
%9 = call i32 @my_ntohl(i32 %8)
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %10)
store i32 17, i32* %3
%12 = bitcast i32* %3 to i8*
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %20
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"ntohl(u) == %u\0A\00"
@.str.1 = [19 x i8] c"my_ntohl(u) == %u\0A\00"
@str = [11 x i8] c"big endian\00"
define i32 @main() {
%1 = tail call i32 @ntohl(i32 17)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @my_ntohl(i32 17)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
ret i32 0
}