#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 /*<<< orphan*/ test_flip_bit(int, int, int);
int /*<<< orphan*/ test_get_bit(int, int, int);
int /*<<< orphan*/ test_set_bit(int, int, int, int);
int main(int argc, const char *argv[]) {
  printf("\nTesting get_bit()\n\n");
  test_get_bit(0b1001110, 0, 0);
  test_get_bit(0b1001110, 1, 1);
  test_get_bit(0b1001110, 5, 0);
  test_get_bit(0b11011, 3, 1);
  test_get_bit(0b11011, 2, 0);
  test_get_bit(0b11011, 9, 0);
  printf("\nTesting set_bit()\n\n");
  test_set_bit(0b1001110, 2, 0, 0b1001010);
  test_set_bit(0b1101101, 0, 0, 0b1101100);
  test_set_bit(0b1001110, 2, 1, 0b1001110);
  test_set_bit(0b1101101, 0, 1, 0b1101101);
  test_set_bit(0b1001110, 9, 0, 0b1001110);
  test_set_bit(0b1101101, 4, 0, 0b1101101);
  test_set_bit(0b1001110, 9, 1, 0b1001001110);
  test_set_bit(0b1101101, 7, 1, 0b11101101);
  printf("\nTesting flip_bit()\n\n");
  test_flip_bit(0b1001110, 0, 0b1001111);
  test_flip_bit(0b1001110, 1, 0b1001100);
  test_flip_bit(0b1001110, 2, 0b1001010);
  test_flip_bit(0b1001110, 5, 0b1101110);
  test_flip_bit(0b1001110, 9, 0b1001001110);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
mov    $0x4e,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1060 <test_get_bit@plt>
mov    $0x4e,%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <test_get_bit@plt>
mov    $0x4e,%edi
mov    $0x5,%esi
xor    %edx,%edx
call   1060 <test_get_bit@plt>
mov    $0x1b,%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1060 <test_get_bit@plt>
mov    $0x1b,%edi
mov    $0x2,%esi
xor    %edx,%edx
call   1060 <test_get_bit@plt>
mov    $0x1b,%edi
mov    $0x9,%esi
xor    %edx,%edx
call   1060 <test_get_bit@plt>
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
mov    $0x4e,%edi
mov    $0x2,%esi
xor    %edx,%edx
mov    $0x4a,%ecx
call   1050 <test_set_bit@plt>
mov    $0x6d,%edi
xor    %edx,%edx
mov    $0x6c,%ecx
mov    %edx,%esi
call   1050 <test_set_bit@plt>
mov    $0x4e,%ecx
mov    $0x2,%esi
mov    $0x1,%edx
mov    %ecx,%edi
call   1050 <test_set_bit@plt>
mov    $0x6d,%ecx
xor    %esi,%esi
mov    $0x1,%edx
mov    %ecx,%edi
call   1050 <test_set_bit@plt>
mov    $0x4e,%ecx
mov    $0x9,%esi
xor    %edx,%edx
mov    %ecx,%edi
call   1050 <test_set_bit@plt>
mov    $0x6d,%ecx
mov    $0x4,%esi
xor    %edx,%edx
mov    %ecx,%edi
call   1050 <test_set_bit@plt>
mov    $0x4e,%edi
mov    $0x9,%esi
mov    $0x1,%edx
mov    $0x24e,%ecx
call   1050 <test_set_bit@plt>
mov    $0x6d,%edi
mov    $0x7,%esi
mov    $0x1,%edx
mov    $0xed,%ecx
call   1050 <test_set_bit@plt>
lea    0xda5(%rip),%rdi
call   1040 <printf@plt>
mov    $0x4e,%edi
xor    %esi,%esi
mov    $0x4f,%edx
call   1030 <test_flip_bit@plt>
mov    $0x4e,%edi
mov    $0x1,%esi
mov    $0x4c,%edx
call   1030 <test_flip_bit@plt>
mov    $0x4e,%edi
mov    $0x2,%esi
mov    $0x4a,%edx
call   1030 <test_flip_bit@plt>
mov    $0x4e,%edi
mov    $0x5,%esi
mov    $0x6e,%edx
call   1030 <test_flip_bit@plt>
mov    $0x4e,%edi
mov    $0x9,%esi
mov    $0x24e,%edx
call   1030 <test_flip_bit@plt>
lea    0xd4c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xea8(%rip),%rdi
call   1050 <puts@plt>
mov    $0x4e,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <test_get_bit@plt>
mov    $0x4e,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1070 <test_get_bit@plt>
mov    $0x4e,%edi
mov    $0x5,%esi
xor    %edx,%edx
call   1070 <test_get_bit@plt>
mov    $0x1b,%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1070 <test_get_bit@plt>
mov    $0x1b,%edi
mov    $0x2,%esi
xor    %edx,%edx
call   1070 <test_get_bit@plt>
mov    $0x1b,%edi
mov    $0x9,%esi
xor    %edx,%edx
call   1070 <test_get_bit@plt>
lea    0xe47(%rip),%rdi
call   1050 <puts@plt>
mov    $0x4e,%edi
mov    $0x2,%esi
xor    %edx,%edx
mov    $0x4a,%ecx
call   1060 <test_set_bit@plt>
mov    $0x6d,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x6c,%ecx
call   1060 <test_set_bit@plt>
mov    $0x4e,%edi
mov    $0x2,%esi
mov    $0x1,%edx
mov    $0x4e,%ecx
call   1060 <test_set_bit@plt>
mov    $0x6d,%edi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x6d,%ecx
call   1060 <test_set_bit@plt>
mov    $0x4e,%edi
mov    $0x9,%esi
xor    %edx,%edx
mov    $0x4e,%ecx
call   1060 <test_set_bit@plt>
mov    $0x6d,%edi
mov    $0x4,%esi
xor    %edx,%edx
mov    $0x6d,%ecx
call   1060 <test_set_bit@plt>
mov    $0x4e,%edi
mov    $0x9,%esi
mov    $0x1,%edx
mov    $0x24e,%ecx
call   1060 <test_set_bit@plt>
mov    $0x6d,%edi
mov    $0x7,%esi
mov    $0x1,%edx
mov    $0xed,%ecx
call   1060 <test_set_bit@plt>
lea    0xd99(%rip),%rdi
call   1050 <puts@plt>
mov    $0x4e,%edi
xor    %esi,%esi
mov    $0x4f,%edx
call   1040 <test_flip_bit@plt>
mov    $0x4e,%edi
mov    $0x1,%esi
mov    $0x4c,%edx
call   1040 <test_flip_bit@plt>
mov    $0x4e,%edi
mov    $0x2,%esi
mov    $0x4a,%edx
call   1040 <test_flip_bit@plt>
mov    $0x4e,%edi
mov    $0x5,%esi
mov    $0x6e,%edx
call   1040 <test_flip_bit@plt>
mov    $0x4e,%edi
mov    $0x9,%esi
mov    $0x24e,%edx
call   1040 <test_flip_bit@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0ATesting get_bit()\0A\0A\00"
@.str.1 = [21 x i8] c"\0ATesting set_bit()\0A\0A\00"
@.str.2 = [22 x i8] c"\0ATesting flip_bit()\0A\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @test_get_bit(i32 78, i32 0, i32 0)
%8 = call i32 @test_get_bit(i32 78, i32 1, i32 1)
%9 = call i32 @test_get_bit(i32 78, i32 5, i32 0)
%10 = call i32 @test_get_bit(i32 27, i32 3, i32 1)
%11 = call i32 @test_get_bit(i32 27, i32 2, i32 0)
%12 = call i32 @test_get_bit(i32 27, i32 9, i32 0)
%13 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @test_set_bit(i32 78, i32 2, i32 0, i32 74)
%15 = call i32 @test_set_bit(i32 109, i32 0, i32 0, i32 108)
%16 = call i32 @test_set_bit(i32 78, i32 2, i32 1, i32 78)
%17 = call i32 @test_set_bit(i32 109, i32 0, i32 1, i32 109)
%18 = call i32 @test_set_bit(i32 78, i32 9, i32 0, i32 78)
%19 = call i32 @test_set_bit(i32 109, i32 4, i32 0, i32 109)
%20 = call i32 @test_set_bit(i32 78, i32 9, i32 1, i32 590)
%21 = call i32 @test_set_bit(i32 109, i32 7, i32 1, i32 237)
%22 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @test_flip_bit(i32 78, i32 0, i32 79)
%24 = call i32 @test_flip_bit(i32 78, i32 1, i32 76)
%25 = call i32 @test_flip_bit(i32 78, i32 2, i32 74)
%26 = call i32 @test_flip_bit(i32 78, i32 5, i32 110)
%27 = call i32 @test_flip_bit(i32 78, i32 9, i32 590)
%28 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [20 x i8] c"\0ATesting get_bit()\0A\00"
@str.4 = [20 x i8] c"\0ATesting set_bit()\0A\00"
@str.5 = [21 x i8] c"\0ATesting flip_bit()\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @test_get_bit(i32 78, i32 0, i32 0)
%5 = tail call i32 @test_get_bit(i32 78, i32 1, i32 1)
%6 = tail call i32 @test_get_bit(i32 78, i32 5, i32 0)
%7 = tail call i32 @test_get_bit(i32 27, i32 3, i32 1)
%8 = tail call i32 @test_get_bit(i32 27, i32 2, i32 0)
%9 = tail call i32 @test_get_bit(i32 27, i32 9, i32 0)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0))
%11 = tail call i32 @test_set_bit(i32 78, i32 2, i32 0, i32 74)
%12 = tail call i32 @test_set_bit(i32 109, i32 0, i32 0, i32 108)
%13 = tail call i32 @test_set_bit(i32 78, i32 2, i32 1, i32 78)
%14 = tail call i32 @test_set_bit(i32 109, i32 0, i32 1, i32 109)
%15 = tail call i32 @test_set_bit(i32 78, i32 9, i32 0, i32 78)
%16 = tail call i32 @test_set_bit(i32 109, i32 4, i32 0, i32 109)
%17 = tail call i32 @test_set_bit(i32 78, i32 9, i32 1, i32 590)
%18 = tail call i32 @test_set_bit(i32 109, i32 7, i32 1, i32 237)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
%20 = tail call i32 @test_flip_bit(i32 78, i32 0, i32 79)
%21 = tail call i32 @test_flip_bit(i32 78, i32 1, i32 76)
%22 = tail call i32 @test_flip_bit(i32 78, i32 2, i32 74)
%23 = tail call i32 @test_flip_bit(i32 78, i32 5, i32 110)
%24 = tail call i32 @test_flip_bit(i32 78, i32 9, i32 590)
%25 = tail call i32 @putchar(i32 10)
ret i32 0
}