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

/* Variables and functions */
int htobe16(int);
int htobe32(int);
int htobe64(int);
int le16toh(int);
int le32toh(int);
int le64toh(int);
int /*<<< orphan*/ printf(char *, int, char *, int, int, int);
int main(int argc, char **argv) {
  uint16_t var16bit;
  uint32_t var32bit;
  uint64_t var64bit;
  uint64_t tmp;
  uint16_t var16bitResult;
  uint32_t var32bitResult;
  uint64_t var64bitResult;
  var16bit = 0x3210;
  var32bit = 0x76543210L;
  var64bit = 0x76543210L;
  tmp = 0xFEDCBA98L;
  var64bit = var64bit | (tmp << 32);
  var16bitResult = le16toh(var16bit);
  var16bitResult = htobe16(var16bit);
  var32bitResult = le32toh(var32bit);
  var32bitResult = htobe32(var32bit);
  var64bitResult = le64toh(var64bit);
  var64bitResult = htobe64(var64bit);
  printf("Argc = %i\nArgv[0] = %s\nResult 16bit = %"
         "u"
         "\nResult 32bit = %"
         "lu"
         "\nResult 64bit = %"
         "llu"
         "\n",
         argc, argv[0], var16bitResult, var32bitResult, var64bitResult);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3210,-0x14(%rbp)
movl   $0x76543210,-0x18(%rbp)
movl   $0x76543210,-0x1c(%rbp)
movl   $0xfedcba98,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%edx
mov    $0x20,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <le16toh@plt>
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
call   1090 <htobe16@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <le32toh@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <htobe32@plt>
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <le64toh@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
call   1080 <htobe64@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
lea    0xdec(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%r14d
mov    $0x3210,%edi
call   1070 <le16toh@plt>
mov    $0x3210,%edi
call   1090 <htobe16@plt>
mov    %eax,%ebp
mov    $0x76543210,%edi
call   1040 <le32toh@plt>
mov    $0x76543210,%edi
call   1060 <htobe32@plt>
mov    %eax,%ebx
call   1030 <le64toh@plt>
call   1080 <htobe64@plt>
mov    (%r15),%rdx
lea    0xe43(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%ecx
mov    %ebx,%r8d
mov    %eax,%r9d
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [81 x i8] c"Argc = %i\0AArgv[0] = %s\0AResult 16bit = %u\0AResult 32bit = %lu\0AResult 64bit = %llu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 12816, i32* %6
store i32 1985229328, i32* %7
store i32 1985229328, i32* %8
store i32 -19088744, i32* %9
%13 = load i32, i32* %8
%14 = load i32, i32* %9
%15 = shl i32 %14, 32
%16 = or i32 %13, %15
store i32 %16, i32* %8
%17 = load i32, i32* %6
%18 = call i32 @le16toh(i32 %17)
store i32 %18, i32* %10
%19 = load i32, i32* %6
%20 = call i32 @htobe16(i32 %19)
store i32 %20, i32* %10
%21 = load i32, i32* %7
%22 = call i32 @le32toh(i32 %21)
store i32 %22, i32* %11
%23 = load i32, i32* %7
%24 = call i32 @htobe32(i32 %23)
store i32 %24, i32* %11
%25 = load i32, i32* %8
%26 = call i32 @le64toh(i32 %25)
store i32 %26, i32* %12
%27 = load i32, i32* %8
%28 = call i32 @htobe64(i32 %27)
store i32 %28, i32* %12
%29 = load i32, i32* %4
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = load i32, i32* %10
%34 = load i32, i32* %11
%35 = load i32, i32* %12
%36 = call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str, i64 0, i64 0), i32 %29, i8* %32, i32 %33, i32 %34, i32 %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [81 x i8] c"Argc = %i\0AArgv[0] = %s\0AResult 16bit = %u\0AResult 32bit = %lu\0AResult 64bit = %llu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @le16toh(i32 12816)
%4 = tail call i32 @htobe16(i32 12816)
%5 = tail call i32 @le32toh(i32 1985229328)
%6 = tail call i32 @htobe32(i32 1985229328)
%7 = tail call i32 @le64toh(i32 poison)
%8 = tail call i32 @htobe64(i32 poison)
%9 = load i8*, i8** %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %9, i32 %4, i32 %6, i32 %8)
ret i32 0
}