#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 */
unsigned int get_power_of_two(unsigned int);
int /*<<< orphan*/ is_power_of_two(unsigned int);
char *power_of_two_binary(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int main() {
  unsigned int operator1;
  unsigned int operator2;
  printf("op1=");
  scanf("%u", &operator1);
  printf("op2=");
  scanf("%u", &operator2);
  if (!is_power_of_two(operator2)) {
    printf("op2=%u is not power of 2\n", operator2);
    return -1;
  }
  printf("multiplying\n");
  printf("op1 * op2 = %u\n", operator1 << get_power_of_two(operator2));
  printf("dividing\n");
  printf("op1 / op2 = %u\n", operator1 >> get_power_of_two(operator2));
  printf("modulo\n");
  printf("op1 %% op2 = %u\n", operator1 & (operator2 - 1));
  printf("binary value of number 2^%u in binary is %s\n", operator2,
         power_of_two_binary(operator2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe91(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1060 <is_power_of_two@plt>
cmp    $0x0,%eax
jne    11c9 <main+0x79>
mov    -0xc(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127b <main+0x12b>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <get_power_of_two@plt>
mov    -0x18(%rbp),%esi
mov    %eax,%ecx
shl    %cl,%esi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <get_power_of_two@plt>
mov    -0x14(%rbp),%esi
mov    %eax,%ecx
shr    %cl,%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
and    %eax,%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <power_of_two_binary@plt>
mov    -0x10(%rbp),%esi
mov    %rax,%rdx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe96(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8b(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
mov    (%rsp),%edi
call   1070 <is_power_of_two@plt>
test   %eax,%eax
je     124b <main+0xeb>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%ebx
mov    (%rsp),%edi
call   1040 <get_power_of_two@plt>
mov    %eax,%ecx
shl    %cl,%ebx
lea    0xe54(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%ebx
mov    (%rsp),%edi
call   1040 <get_power_of_two@plt>
mov    %eax,%ecx
shr    %cl,%ebx
lea    0xe38(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%esi
add    $0xffffffff,%esi
and    0x4(%rsp),%esi
lea    0xe22(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%ebx
mov    %ebx,%edi
call   1060 <power_of_two_binary@plt>
lea    0xe1b(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1261 <main+0x101>
mov    (%rsp),%esi
lea    0xdb8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"op1=\00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [5 x i8] c"op2=\00"
@.str.3 = [26 x i8] c"op2=%u is not power of 2\0A\00"
@.str.4 = [13 x i8] c"multiplying\0A\00"
@.str.5 = [16 x i8] c"op1 * op2 = %u\0A\00"
@.str.6 = [10 x i8] c"dividing\0A\00"
@.str.7 = [16 x i8] c"op1 / op2 = %u\0A\00"
@.str.8 = [8 x i8] c"modulo\0A\00"
@.str.9 = [17 x i8] c"op1 %% op2 = %u\0A\00"
@.str.10 = [45 x i8] c"binary value of number 2^%u in binary is %s\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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = call i32 @is_power_of_two(i32 %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %0
%12 = load i32, i32* %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %12)
store i32 -1, i32* %1
br label %37
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 @get_power_of_two(i32 %17)
%19 = shl i32 %16, %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 @get_power_of_two(i32 %23)
%25 = lshr i32 %22, %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = sub i32 %29, 1
%31 = and i32 %28, %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %3
%34 = load i32, i32* %3
%35 = call i8* @power_of_two_binary(i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 %33, i8* %35)
store i32 0, i32* %1
br label %37
37: ; preds = %14, %11
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str = [5 x i8] c"op1=\00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [5 x i8] c"op2=\00"
@.str.3 = [26 x i8] c"op2=%u is not power of 2\0A\00"
@.str.5 = [16 x i8] c"op1 * op2 = %u\0A\00"
@.str.7 = [16 x i8] c"op1 / op2 = %u\0A\00"
@.str.9 = [17 x i8] c"op1 %% op2 = %u\0A\00"
@.str.10 = [45 x i8] c"binary value of number 2^%u in binary is %s\0A\00"
@str = [12 x i8] c"multiplying\00"
@str.11 = [9 x i8] c"dividing\00"
@str.12 = [7 x i8] c"modulo\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = call i32 @is_power_of_two(i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = load i32, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %13)
br label %37
15: ; preds = %0
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = call i32 @get_power_of_two(i32 %18)
%20 = shl i32 %17, %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %20)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.11, i64 0, i64 0))
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = call i32 @get_power_of_two(i32 %24)
%26 = lshr i32 %23, %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %26)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.12, i64 0, i64 0))
%29 = load i32, i32* %1
%30 = load i32, i32* %2
%31 = add i32 %30, -1
%32 = and i32 %31, %29
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %2
%35 = call i8* @power_of_two_binary(i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 %34, i8* %35)
br label %37
37: ; preds = %15, %12
%38 = phi i32 [ 0, %15 ], [ -1, %12 ]
ret i32 %38
}