#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*/ bitcount(unsigned long);
int /*<<< orphan*/ invertbits(unsigned long, int, int);
int /*<<< orphan*/ printf(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ rightrotate(unsigned long, int);
int /*<<< orphan*/ setbits(unsigned long, int, int, unsigned long);
unsigned long strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  if (argc != 2)
    return 1;
  unsigned long num = strtoul(argv[1], NULL, 10);
  printf("%-30s%lu\n", "setbits 3, 4, 15", setbits(num, 3, 4, 15UL));
  printf("%-30s%lu\n", "setbits 10, 5, 1460", setbits(num, 10, 5, 1460UL));
  printf("%-30s%lu\n", "invertbits 3, 4", invertbits(num, 3, 4));
  printf("%-30s%lu\n", "invertbits 10, 5", invertbits(num, 10, 5));
  printf("%-30s%lu\n", "rightrotate 3", rightrotate(num, 3));
  printf("%-30s%lu\n", "rightrotate 10", rightrotate(num, 10));
  printf("%-30s%lu\n", "bitcount", bitcount(num));
  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)
cmpl   $0x2,-0x8(%rbp)
je     118c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    12bb <main+0x15b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x3,%esi
mov    $0x4,%edx
mov    $0xf,%ecx
call   1070 <setbits@plt>
mov    %eax,%edx
lea    0xe39(%rip),%rdi
lea    0xe3c(%rip),%rsi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0xa,%esi
mov    $0x5,%edx
mov    $0x5b4,%ecx
call   1070 <setbits@plt>
mov    %eax,%edx
lea    0xe0c(%rip),%rdi
lea    0xe20(%rip),%rsi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1060 <invertbits@plt>
mov    %eax,%edx
lea    0xde4(%rip),%rdi
lea    0xe0c(%rip),%rsi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0xa,%esi
mov    $0x5,%edx
call   1060 <invertbits@plt>
mov    %eax,%edx
lea    0xdbc(%rip),%rdi
lea    0xdf4(%rip),%rsi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x3,%esi
call   1050 <rightrotate@plt>
mov    %eax,%edx
lea    0xd99(%rip),%rdi
lea    0xde2(%rip),%rsi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0xa,%esi
call   1050 <rightrotate@plt>
mov    %eax,%edx
lea    0xd76(%rip),%rdi
lea    0xdcd(%rip),%rsi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <bitcount@plt>
mov    %eax,%edx
lea    0xd58(%rip),%rdi
lea    0xdbe(%rip),%rsi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x1,%r14d
cmp    $0x2,%edi
jne    127c <main+0x11c>
mov    0x8(%rsi),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %rax,%rbx
mov    $0xf,%ecx
mov    %rax,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1070 <setbits@plt>
lea    0xe58(%rip),%r15
lea    0xe5b(%rip),%rsi
mov    %r15,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x5b4,%ecx
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x5,%edx
call   1070 <setbits@plt>
lea    0xe44(%rip),%rsi
mov    %r15,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1060 <invertbits@plt>
lea    0xe35(%rip),%rsi
mov    %r15,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x5,%edx
call   1060 <invertbits@plt>
lea    0xe22(%rip),%rsi
mov    %r15,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1050 <rightrotate@plt>
lea    0xe15(%rip),%rsi
mov    %r15,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <rightrotate@plt>
lea    0xe05(%rip),%rsi
mov    %r15,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <bitcount@plt>
lea    0xdfb(%rip),%rsi
mov    %r15,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%-30s%lu\0A\00"
@.str.1 = [17 x i8] c"setbits 3, 4, 15\00"
@.str.2 = [20 x i8] c"setbits 10, 5, 1460\00"
@.str.3 = [16 x i8] c"invertbits 3, 4\00"
@.str.4 = [17 x i8] c"invertbits 10, 5\00"
@.str.5 = [14 x i8] c"rightrotate 3\00"
@.str.6 = [15 x i8] c"rightrotate 10\00"
@.str.7 = [9 x i8] c"bitcount\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 1, i32* %3
br label %36
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strtoul(i8* %13, i32* null, i32 10)
store i64 %14, i64* %6
%15 = load i64, i64* %6
%16 = call i32 @setbits(i64 %15, i32 3, i32 4, i64 15)
%17 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i64, i64* %6
%19 = call i32 @setbits(i64 %18, i32 10, i32 5, i64 1460)
%20 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load i64, i64* %6
%22 = call i32 @invertbits(i64 %21, i32 3, i32 4)
%23 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = load i64, i64* %6
%25 = call i32 @invertbits(i64 %24, i32 10, i32 5)
%26 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = load i64, i64* %6
%28 = call i32 @rightrotate(i64 %27, i32 3)
%29 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = load i64, i64* %6
%31 = call i32 @rightrotate(i64 %30, i32 10)
%32 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %31)
%33 = load i64, i64* %6
%34 = call i32 @bitcount(i64 %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %34)
store i32 0, i32* %3
br label %36
36: ; preds = %10, %9
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [10 x i8] c"%-30s%lu\0A\00"
@.str.1 = [17 x i8] c"setbits 3, 4, 15\00"
@.str.2 = [20 x i8] c"setbits 10, 5, 1460\00"
@.str.3 = [16 x i8] c"invertbits 3, 4\00"
@.str.4 = [17 x i8] c"invertbits 10, 5\00"
@.str.5 = [14 x i8] c"rightrotate 3\00"
@.str.6 = [15 x i8] c"rightrotate 10\00"
@.str.7 = [9 x i8] c"bitcount\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strtoul(i8* nocapture %6, i32* null, i32 10)
%8 = tail call i32 @setbits(i64 %7, i32 3, i32 4, i64 15)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = tail call i32 @setbits(i64 %7, i32 10, i32 5, i64 1460)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = tail call i32 @invertbits(i64 %7, i32 3, i32 4)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = tail call i32 @invertbits(i64 %7, i32 10, i32 5)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%16 = tail call i32 @rightrotate(i64 %7, i32 3)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %16)
%18 = tail call i32 @rightrotate(i64 %7, i32 10)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %18)
%20 = tail call i32 @bitcount(i64 %7)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %2, %4
%23 = phi i32 [ 0, %4 ], [ 1, %2 ]
ret i32 %23
}