#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);
int setbits(int, int, int, int);
main() {
  printf("%o\n", setbits(0777, 1, 1, 0333));
  printf("%o\n", setbits(0123456, 4, 3, 0712));
  printf("%o\n", setbits(0xDEADBEAF, 4, 3, 0xFF));
  printf("%o\n", setbits(377569, 6, 2, 432));
  printf("%o\n", setbits(12345667, 22, 2, 98765));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1ff,%edi
mov    $0x1,%edx
mov    $0xdb,%ecx
mov    %edx,%esi
call   1040 <setbits@plt>
mov    %eax,%esi
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
mov    $0xa72e,%edi
mov    $0x4,%esi
mov    $0x3,%edx
mov    $0x1ca,%ecx
call   1040 <setbits@plt>
mov    %eax,%esi
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    $0xdeadbeaf,%edi
mov    $0x4,%esi
mov    $0x3,%edx
mov    $0xff,%ecx
call   1040 <setbits@plt>
mov    %eax,%esi
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
mov    $0x5c2e1,%edi
mov    $0x6,%esi
mov    $0x2,%edx
mov    $0x1b0,%ecx
call   1040 <setbits@plt>
mov    %eax,%esi
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
mov    $0xbc6143,%edi
mov    $0x16,%esi
mov    $0x2,%edx
mov    $0x181cd,%ecx
call   1040 <setbits@plt>
mov    %eax,%esi
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1ff,%edi
mov    $0x1,%esi
mov    $0x1,%edx
mov    $0xdb,%ecx
call   1040 <setbits@plt>
lea    0xebf(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0xa72e,%edi
mov    $0x4,%esi
mov    $0x3,%edx
mov    $0x1ca,%ecx
call   1040 <setbits@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0xdeadbeaf,%edi
mov    $0x4,%esi
mov    $0x3,%edx
mov    $0xff,%ecx
call   1040 <setbits@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x5c2e1,%edi
mov    $0x6,%esi
mov    $0x2,%edx
mov    $0x1b0,%ecx
call   1040 <setbits@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0xbc6143,%edi
mov    $0x16,%esi
mov    $0x2,%edx
mov    $0x181cd,%ecx
call   1040 <setbits@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%o\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @setbits(i32 511, i32 1, i32 1, i32 219)
%3 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = call i32 @setbits(i32 42798, i32 4, i32 3, i32 458)
%5 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @setbits(i32 -559038801, i32 4, i32 3, i32 255)
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @setbits(i32 377569, i32 6, i32 2, i32 432)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @setbits(i32 12345667, i32 22, i32 2, i32 98765)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%o\0A\00"
define i32 @main() {
%1 = tail call i32 @setbits(i32 511, i32 1, i32 1, i32 219)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @setbits(i32 42798, i32 4, i32 3, i32 458)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @setbits(i32 -559038801, i32 4, i32 3, i32 255)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @setbits(i32 377569, i32 6, i32 2, i32 432)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @setbits(i32 12345667, i32 22, i32 2, i32 98765)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
ret i32 0
}