#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 invert(int, int, int);
int /*<<< orphan*/ printf(char *, char *, ...);
int main() {
  printf("%s\t\t\t\t%s\t%s\n", "Test", "Expected", "Actual");
  printf("%s\t\t\t\t%s\t%s\n", "----", "--------", "------");
  printf("%s\t%d\t%d\n", "invert(0x12cc5678, 23, 8)", 0x12335678,
         invert(0x12cc5678, 23, 8));
  printf("%s\t\t%d\t\t%d\n", "invert(0xa53c, 15, 16)", 0x5ac3,
         invert(0xa53c, 15, 16));
  printf("%s\t\t%d\t\t%d\n", "invert(0xff00, 15, 16)", 0xff,
         invert(0xff00, 15, 16));
  printf("%s\t\t%d\t\t%d\n", "invert(0xfe7f, 8, 2)", 0xffff,
         invert(0xfe7f, 8, 2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    0xed0(%rip),%rsi
lea    0xece(%rip),%rdx
lea    0xed0(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
lea    0xec6(%rip),%rsi
lea    0xebb(%rip),%rdx
lea    0xeb6(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x12cc5678,%edi
mov    $0x17,%esi
mov    $0x8,%edx
call   1030 <invert@plt>
mov    %eax,%ecx
lea    0xe99(%rip),%rdi
lea    0xe9c(%rip),%rsi
mov    $0x12335678,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa53c,%edi
mov    $0xf,%esi
mov    $0x10,%edx
call   1030 <invert@plt>
mov    %eax,%ecx
lea    0xe8d(%rip),%rdi
lea    0xe92(%rip),%rsi
mov    $0x5ac3,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xff00,%edi
mov    $0xf,%esi
mov    $0x10,%edx
call   1030 <invert@plt>
mov    %eax,%ecx
lea    0xe5d(%rip),%rdi
lea    0xe79(%rip),%rsi
mov    $0xff,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xfe7f,%edi
mov    $0x8,%esi
mov    $0x2,%edx
call   1030 <invert@plt>
mov    %eax,%ecx
lea    0xe2d(%rip),%rdi
lea    0xe60(%rip),%rsi
mov    $0xffff,%edx
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed8(%rip),%rbx
lea    0xede(%rip),%rsi
lea    0xedc(%rip),%rdx
lea    0xede(%rip),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed8(%rip),%rsi
lea    0xecd(%rip),%rdx
lea    0xec8(%rip),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x12cc5678,%edi
mov    $0x17,%esi
mov    $0x8,%edx
call   1030 <invert@plt>
lea    0xeaa(%rip),%rdi
lea    0xead(%rip),%rsi
mov    $0x12335678,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa53c,%edi
mov    $0xf,%esi
mov    $0x10,%edx
call   1030 <invert@plt>
lea    0xe9e(%rip),%rbx
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5ac3,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xff00,%edi
mov    $0xf,%esi
mov    $0x10,%edx
call   1030 <invert@plt>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
mov    $0xff,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xfe7f,%edi
mov    $0x8,%esi
mov    $0x2,%edx
call   1030 <invert@plt>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
mov    $0xffff,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%s\09\09\09\09%s\09%s\0A\00"
@.str.1 = [5 x i8] c"Test\00"
@.str.2 = [9 x i8] c"Expected\00"
@.str.3 = [7 x i8] c"Actual\00"
@.str.4 = [5 x i8] c"----\00"
@.str.5 = [9 x i8] c"--------\00"
@.str.6 = [7 x i8] c"------\00"
@.str.7 = [10 x i8] c"%s\09%d\09%d\0A\00"
@.str.8 = [26 x i8] c"invert(0x12cc5678, 23, 8)\00"
@.str.9 = [12 x i8] c"%s\09\09%d\09\09%d\0A\00"
@.str.10 = [23 x i8] c"invert(0xa53c, 15, 16)\00"
@.str.11 = [23 x i8] c"invert(0xff00, 15, 16)\00"
@.str.12 = [21 x i8] c"invert(0xfe7f, 8, 2)\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%3 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%4 = call i32 @invert(i32 315381368, i32 23, i32 8)
%5 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 305354360, i32 %4)
%6 = call i32 @invert(i32 42300, i32 15, i32 16)
%7 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i32 23235, i32 %6)
%8 = call i32 @invert(i32 65280, i32 15, i32 16)
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i32 255, i32 %8)
%10 = call i32 @invert(i32 65151, i32 8, i32 2)
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i32 65535, i32 %10)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"%s\09\09\09\09%s\09%s\0A\00"
@.str.1 = [5 x i8] c"Test\00"
@.str.2 = [9 x i8] c"Expected\00"
@.str.3 = [7 x i8] c"Actual\00"
@.str.4 = [5 x i8] c"----\00"
@.str.5 = [9 x i8] c"--------\00"
@.str.6 = [7 x i8] c"------\00"
@.str.7 = [10 x i8] c"%s\09%d\09%d\0A\00"
@.str.8 = [26 x i8] c"invert(0x12cc5678, 23, 8)\00"
@.str.9 = [12 x i8] c"%s\09\09%d\09\09%d\0A\00"
@.str.10 = [23 x i8] c"invert(0xa53c, 15, 16)\00"
@.str.11 = [23 x i8] c"invert(0xff00, 15, 16)\00"
@.str.12 = [21 x i8] c"invert(0xfe7f, 8, 2)\00"
define i32 @main() {
%1 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%2 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%3 = tail call i32 @invert(i32 315381368, i32 23, i32 8)
%4 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 305354360, i32 %3)
%5 = tail call i32 @invert(i32 42300, i32 15, i32 16)
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i32 23235, i32 %5)
%7 = tail call i32 @invert(i32 65280, i32 15, i32 16)
%8 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i32 255, i32 %7)
%9 = tail call i32 @invert(i32 65151, i32 8, i32 2)
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i32 65535, i32 %9)
ret i32 0
}