#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 */

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int bswap_16(int);
int /*<<< orphan*/ bswap_32(int);
int /*<<< orphan*/ bswap_64(int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, int, ...);
scalar_t__ strcmp(char *, char *);
int main() {
  char buf[100];
  printf("%x %x\n", bswap_16(0x1234), bswap_16(0x5678));
  snprintf(buf, 100, "%x %x", bswap_16(0x1234), bswap_16(0x5678));
  assert(strcmp(buf, "3412 7856") == 0);
  printf("%lx\n", bswap_32(0x12345678));
  snprintf(buf, 100, "%lx", bswap_32(0x12345678));
  assert(strcmp(buf, "78563412") == 0);
  printf("%qx\n", bswap_64(0x123456789ABCDEFull));
  snprintf(buf, 100, "%qx", bswap_64(0x123456789ABCDEFull));
  assert(strcmp(buf, "efcdab8967452301") == 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1234,%edi
call   1090 <bswap_16@plt>
mov    %eax,-0x94(%rbp)
mov    $0x5678,%edi
call   1090 <bswap_16@plt>
mov    -0x94(%rbp),%esi
mov    %eax,%edx
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    $0x1234,%edi
call   1090 <bswap_16@plt>
mov    %eax,-0x84(%rbp)
mov    $0x5678,%edi
call   1090 <bswap_16@plt>
mov    -0x90(%rbp),%rdi
mov    -0x84(%rbp),%ecx
mov    %eax,%r8d
mov    $0x64,%esi
lea    0xe14(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe08(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x12345678,%edi
call   1070 <bswap_32@plt>
mov    %eax,%esi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    $0x12345678,%edi
call   1070 <bswap_32@plt>
mov    -0x80(%rbp),%rdi
mov    %eax,%ecx
mov    $0x64,%esi
lea    0xdc3(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x70(%rbp),%rdi
lea    0xdb5(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x89abcdef,%edi
call   1080 <bswap_64@plt>
mov    %eax,%esi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    $0x89abcdef,%edi
call   1080 <bswap_64@plt>
mov    -0x78(%rbp),%rdi
mov    %eax,%ecx
mov    $0x64,%esi
lea    0xd6f(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x70(%rbp),%rdi
lea    0xd61(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x68,%rsp
mov    $0x1234,%edi
call   1090 <bswap_16@plt>
mov    %eax,%ebx
mov    $0x5678,%edi
call   1090 <bswap_16@plt>
lea    0xe6d(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1234,%edi
call   1090 <bswap_16@plt>
mov    %eax,%ebp
mov    $0x5678,%edi
call   1090 <bswap_16@plt>
lea    0xe4c(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xe34(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    $0x12345678,%edi
call   1070 <bswap_32@plt>
lea    0xe17(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x12345678,%edi
call   1070 <bswap_32@plt>
lea    0xe02(%rip),%rdx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xdee(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    $0x89abcdef,%edi
call   1080 <bswap_64@plt>
lea    0xdd0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x89abcdef,%edi
call   1080 <bswap_64@plt>
lea    0xdbb(%rip),%rdx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xda7(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%x %x\0A\00"
@.str.1 = [6 x i8] c"%x %x\00"
@.str.2 = [10 x i8] c"3412 7856\00"
@.str.3 = [5 x i8] c"%lx\0A\00"
@.str.4 = [4 x i8] c"%lx\00"
@.str.5 = [9 x i8] c"78563412\00"
@.str.6 = [5 x i8] c"%qx\0A\00"
@.str.7 = [4 x i8] c"%qx\00"
@.str.8 = [17 x i8] c"efcdab8967452301\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
store i32 0, i32* %1
%3 = call i32 @bswap_16(i32 4660)
%4 = call i32 @bswap_16(i32 22136)
%5 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32 @bswap_16(i32 4660)
%8 = call i32 @bswap_16(i32 22136)
%9 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %6, i32 100, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32 @bswap_32(i32 305419896)
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%18 = call i32 @bswap_32(i32 305419896)
%19 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %17, i32 100, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = call i32 @bswap_64(i32 -1985229329)
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%28 = call i32 @bswap_64(i32 -1985229329)
%29 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %27, i32 100, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%x %x\0A\00"
@.str.1 = [6 x i8] c"%x %x\00"
@.str.2 = [10 x i8] c"3412 7856\00"
@.str.3 = [5 x i8] c"%lx\0A\00"
@.str.4 = [4 x i8] c"%lx\00"
@.str.5 = [9 x i8] c"78563412\00"
@.str.6 = [5 x i8] c"%qx\0A\00"
@.str.7 = [4 x i8] c"%qx\00"
@.str.8 = [17 x i8] c"efcdab8967452301\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @bswap_16(i32 4660)
%4 = tail call i32 @bswap_16(i32 22136)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
%6 = tail call i32 @bswap_16(i32 4660)
%7 = tail call i32 @bswap_16(i32 22136)
%8 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %2, i32 100, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7)
%9 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i32 @bswap_32(i32 305419896)
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = call i32 @bswap_32(i32 305419896)
%16 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %2, i32 100, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @bswap_64(i32 -1985229329)
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %21)
%23 = call i32 @bswap_64(i32 -1985229329)
%24 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %2, i32 100, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %23)
%25 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
ret i32 0
}