#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 */
scalar_t__ bitwise_check(int, int);
int /*<<< orphan*/ printf(char *, ...);
void bitwise_set(int number, int bitshift) {
  int newnumber = number;
  printf("bitwise set %i |= 1 << %i : %i\n", number, bitshift,
         newnumber |= 1 << bitshift);
  int i;
  printf("checking bits set: ");
  for (i = 7; i >= 0; i--)
    if (bitwise_check(newnumber, i))
      printf("1");
    else
      printf("0");
  printf("\n");
}


x86 assembly (clang, -O0):
<bitwise_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
or     -0xc(%rbp),%ecx
mov    %ecx,-0xc(%rbp)
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x7,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     11c2 <bitwise_set+0xa2>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <bitwise_check@plt>
cmp    $0x0,%rax
je     11a1 <bitwise_set+0x81>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11af <bitwise_set+0x8f>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b4 <bitwise_set+0x94>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    116f <bitwise_set+0x4f>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitwise_set>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%edx
mov    %edi,%esi
mov    %edi,%ebx
bts    %edx,%ebx
lea    0xebd(%rip),%rdi
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
mov    $0x7,%esi
call   1050 <bitwise_check@plt>
cmp    $0x1,%rax
mov    $0x31,%ebp
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    $0x6,%esi
call   1050 <bitwise_check@plt>
cmp    $0x1,%rax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    $0x5,%esi
call   1050 <bitwise_check@plt>
cmp    $0x1,%rax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    $0x4,%esi
call   1050 <bitwise_check@plt>
cmp    $0x1,%rax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    $0x3,%esi
call   1050 <bitwise_check@plt>
cmp    $0x1,%rax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    $0x2,%esi
call   1050 <bitwise_check@plt>
cmp    $0x1,%rax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   1050 <bitwise_check@plt>
cmp    $0x1,%rax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <bitwise_check@plt>
cmp    $0x1,%rax
sbb    $0x0,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"bitwise set %i |= 1 << %i : %i\0A\00"
@.str.1 = [20 x i8] c"checking bits set: \00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @bitwise_set(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
store i32 %7, i32* %5
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = load i32, i32* %4
%11 = shl i32 1, %10
%12 = load i32, i32* %5
%13 = or i32 %12, %11
store i32 %13, i32* %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i32 7, i32* %6
br label %16
16: ; preds = %29, %2
%17 = load i32, i32* %6
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %32
19: ; preds = %16
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call i64 @bitwise_check(i32 %20, i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %28
26: ; preds = %19
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %24
br label %29
29: ; preds = %28
%30 = load i32, i32* %6
%31 = add nsw i32 %30, -1
store i32 %31, i32* %6
br label %16
32: ; preds = %16
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"bitwise set %i |= 1 << %i : %i\0A\00"
@.str.1 = [20 x i8] c"checking bits set: \00"
define void @bitwise_set(i32 %0, i32 %1) {
%3 = shl nuw i32 1, %1
%4 = or i32 %3, %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i64 @bitwise_check(i32 %4, i32 7)
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i32 48, i32 49
%10 = tail call i32 @putchar(i32 %9)
%11 = tail call i64 @bitwise_check(i32 %4, i32 6)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i32 48, i32 49
%14 = tail call i32 @putchar(i32 %13)
%15 = tail call i64 @bitwise_check(i32 %4, i32 5)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i32 48, i32 49
%18 = tail call i32 @putchar(i32 %17)
%19 = tail call i64 @bitwise_check(i32 %4, i32 4)
%20 = icmp eq i64 %19, 0
%21 = select i1 %20, i32 48, i32 49
%22 = tail call i32 @putchar(i32 %21)
%23 = tail call i64 @bitwise_check(i32 %4, i32 3)
%24 = icmp eq i64 %23, 0
%25 = select i1 %24, i32 48, i32 49
%26 = tail call i32 @putchar(i32 %25)
%27 = tail call i64 @bitwise_check(i32 %4, i32 2)
%28 = icmp eq i64 %27, 0
%29 = select i1 %28, i32 48, i32 49
%30 = tail call i32 @putchar(i32 %29)
%31 = tail call i64 @bitwise_check(i32 %4, i32 1)
%32 = icmp eq i64 %31, 0
%33 = select i1 %32, i32 48, i32 49
%34 = tail call i32 @putchar(i32 %33)
%35 = tail call i64 @bitwise_check(i32 %4, i32 0)
%36 = icmp eq i64 %35, 0
%37 = select i1 %36, i32 48, i32 49
%38 = tail call i32 @putchar(i32 %37)
%39 = tail call i32 @putchar(i32 10)
ret void
}