#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*/ printf(char *, ...);
int setbits(int, int, int, int);
int main() {
  printf("With x as 74, p as 5, n as 4, and y as 0, setbits returns %d\n",
         setbits(74, 5, 4, 0));
  printf("1[0010]00 to 000[0000], creating 0000010\n\n");
  printf("With x as 90, p as 3, n as 2, and y as 20, setbits returns %d\n",
         setbits(90, 3, 2, 20));
  printf("101[10]10 to 00101[00], creating 0010110\n\n");
  printf("With x as 256, p as 8, n as 1, and y as 14, setbits returns %d\n",
         setbits(256, 8, 1, 14));
  printf("[1]00000000 to 00000111[0], creating 000001111\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4a,%edi
mov    $0x5,%esi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1040 <setbits@plt>
mov    %eax,%esi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x5a,%edi
mov    $0x3,%esi
mov    $0x2,%edx
mov    $0x14,%ecx
call   1040 <setbits@plt>
mov    %eax,%esi
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x100,%edi
mov    $0x8,%esi
mov    $0x1,%edx
mov    $0xe,%ecx
call   1040 <setbits@plt>
mov    %eax,%esi
lea    0xf17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf49(%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    $0x4a,%edi
mov    $0x5,%esi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1050 <setbits@plt>
lea    0xeb2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf5f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5a,%edi
mov    $0x3,%esi
mov    $0x2,%edx
mov    $0x14,%ecx
call   1050 <setbits@plt>
lea    0xebb(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf54(%rip),%rdi
call   1030 <puts@plt>
mov    $0x100,%edi
mov    $0x8,%esi
mov    $0x1,%edx
mov    $0xe,%ecx
call   1050 <setbits@plt>
lea    0xec5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf49(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [62 x i8] c"With x as 74, p as 5, n as 4, and y as 0, setbits returns %d\0A\00"
@.str.1 = [43 x i8] c"1[0010]00 to 000[0000], creating 0000010\0A\0A\00"
@.str.2 = [63 x i8] c"With x as 90, p as 3, n as 2, and y as 20, setbits returns %d\0A\00"
@.str.3 = [43 x i8] c"101[10]10 to 00101[00], creating 0010110\0A\0A\00"
@.str.4 = [64 x i8] c"With x as 256, p as 8, n as 1, and y as 14, setbits returns %d\0A\00"
@.str.5 = [48 x i8] c"[1]00000000 to 00000111[0], creating 000001111\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @setbits(i32 74, i32 5, i32 4, i32 0)
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @setbits(i32 90, i32 3, i32 2, i32 20)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @setbits(i32 256, i32 8, i32 1, i32 14)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.4, i64 0, i64 0), i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [62 x i8] c"With x as 74, p as 5, n as 4, and y as 0, setbits returns %d\0A\00"
@.str.2 = [63 x i8] c"With x as 90, p as 3, n as 2, and y as 20, setbits returns %d\0A\00"
@.str.4 = [64 x i8] c"With x as 256, p as 8, n as 1, and y as 14, setbits returns %d\0A\00"
@str = [42 x i8] c"1[0010]00 to 000[0000], creating 0000010\0A\00"
@str.6 = [42 x i8] c"101[10]10 to 00101[00], creating 0010110\0A\00"
@str.7 = [47 x i8] c"[1]00000000 to 00000111[0], creating 000001111\00"
define i32 @main() {
%1 = tail call i32 @setbits(i32 74, i32 5, i32 4, i32 0)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @setbits(i32 90, i32 3, i32 2, i32 20)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.6, i64 0, i64 0))
%7 = tail call i32 @setbits(i32 256, i32 8, i32 1, i32 14)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.4, i64 0, i64 0), i32 %7)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}