#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 fits_bits(int, int);
int /*<<< orphan*/ printf(char *, int, int, int);
int main(void) {
  int x, n;
  x = 3;
  n = 3;
  printf("0X%.8X can be represented by %d bits: %d\n", x, n, fits_bits(x, n));
  x = -6;
  n = 5;
  printf("0X%.8X can be represented by %d bits: %d\n", x, n, fits_bits(x, n));
  x = 0xFF;
  n = 8;
  printf("0X%.8X can be represented by %d bits: %d\n", x, n, fits_bits(x, n));
  x = 0xFF;
  n = 9;
  printf("0X%.8X can be represented by %d bits: %d\n", x, n, fits_bits(x, n));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <fits_bits@plt>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
movl   $0xfffffffa,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <fits_bits@plt>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    %eax,%ecx
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
movl   $0xff,-0x8(%rbp)
movl   $0x8,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <fits_bits@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
lea    0xe2b(%rip),%rdi
call   1030 <printf@plt>
movl   $0xff,-0x8(%rbp)
movl   $0x9,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <fits_bits@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    %eax,%ecx
lea    0xdf2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x3,%edi
mov    $0x3,%esi
call   1040 <fits_bits@plt>
lea    0xec9(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    $0xfffffffa,%edi
mov    $0x5,%esi
call   1040 <fits_bits@plt>
mov    %rbx,%rdi
mov    $0xfffffffa,%esi
mov    $0x5,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    $0xff,%edi
mov    $0x8,%esi
call   1040 <fits_bits@plt>
mov    %rbx,%rdi
mov    $0xff,%esi
mov    $0x8,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    $0xff,%edi
mov    $0x9,%esi
call   1040 <fits_bits@plt>
mov    %rbx,%rdi
mov    $0xff,%esi
mov    $0x9,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"0X%.8X can be represented by %d bits: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 3, i32* %2
store i32 3, i32* %3
%4 = load i32, i32* %2
%5 = load i32, i32* %3
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = call i32 @fits_bits(i32 %6, i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5, i32 %8)
store i32 -6, i32* %2
store i32 5, i32* %3
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = call i32 @fits_bits(i32 %12, i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11, i32 %14)
store i32 255, i32* %2
store i32 8, i32* %3
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @fits_bits(i32 %18, i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17, i32 %20)
store i32 255, i32* %2
store i32 9, i32* %3
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @fits_bits(i32 %24, i32 %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23, i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"0X%.8X can be represented by %d bits: %d\0A\00"
define i32 @main() {
%1 = tail call i32 @fits_bits(i32 3, i32 3)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 3, i32 3, i32 %1)
%3 = tail call i32 @fits_bits(i32 -6, i32 5)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 -6, i32 5, i32 %3)
%5 = tail call i32 @fits_bits(i32 255, i32 8)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 255, i32 8, i32 %5)
%7 = tail call i32 @fits_bits(i32 255, i32 9)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 255, i32 9, i32 %7)
ret i32 0
}