#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 convert_bits(unsigned int, unsigned int);
int /*<<< orphan*/ print_binary(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, unsigned int *, unsigned int *);
int main(void) {
  printf("Enter A and B\n");
  unsigned a, b;
  while (scanf("%u%u", &a, &b) == 2) {
    printf("A = ");
    print_binary(a);
    printf("\nB = ");
    print_binary(b);
    printf("\nBits to convert A to B: %u\n", convert_bits(a, b));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    11c6 <main+0x86>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1040 <print_binary@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
call   1040 <print_binary@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <convert_bits@plt>
mov    %eax,%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1070 <scanf@plt>
cmp    $0x2,%eax
jne    1200 <main+0xb0>
lea    0xe7a(%rip),%r14
lea    0xe78(%rip),%r15
lea    0xe77(%rip),%r12
lea    0xe60(%rip),%r13
lea    0x4(%rsp),%rbx
mov    %rsp,%rbp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
call   1050 <print_binary@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%edi
call   1050 <print_binary@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1060 <convert_bits@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1070 <scanf@plt>
cmp    $0x2,%eax
je     11b0 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Enter A and B\0A\00"
@.str.1 = [5 x i8] c"%u%u\00"
@.str.2 = [5 x i8] c"A = \00"
@.str.3 = [6 x i8] c"\0AB = \00"
@.str.4 = [29 x i8] c"\0ABits to convert A to B: %u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %8, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* %2
%11 = call i32 @print_binary(i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32, i32* %3
%14 = call i32 @print_binary(i32 %13)
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 @convert_bits(i32 %15, i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %17)
br label %5
19: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%u%u\00"
@.str.2 = [5 x i8] c"A = \00"
@.str.3 = [6 x i8] c"\0AB = \00"
@.str.4 = [29 x i8] c"\0ABits to convert A to B: %u\0A\00"
@str = [14 x i8] c"Enter A and B\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %21
8: ; preds = %0, %8
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = call i32 @print_binary(i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32, i32* %2
%14 = call i32 @print_binary(i32 %13)
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = call i32 @convert_bits(i32 %15, i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%20 = icmp eq i32 %19, 2
br i1 %20, label %8, label %21
21: ; preds = %8, %0
ret i32 0
}