#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 */
typedef int /*<<< orphan*/ bit_array;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int test_bit(int bit_array[], unsigned bit_number) {
  int temp = 0;
  int ArraySize = 8 * sizeof(bit_array);
  if (bit_number > ArraySize - 1) {
    printf("the second parameter is too big! The set_bit function can not "
           "accept it!\n\n");
    return 0;
  }
  if (bit_array[bit_number] != 0) {
    return 1;
  } else {
    return 0;
  }
  printf("After the process, the bit array is :");
  for (temp = 0; temp < ArraySize; temp++) {
    printf("%d", bit_array[temp]);
    if (temp == ArraySize - 1) {
      printf("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x40,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jbe    1158 <test_bit+0x48>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    117c <test_bit+0x6c>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
cmpl   $0x0,(%rax,%rcx,4)
je     1175 <test_bit+0x65>
movl   $0x1,-0x4(%rbp)
jmp    117c <test_bit+0x6c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_bit>:
push   %rax
cmp    $0x40,%esi
jb     1126 <test_bit+0x16>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    %esi,%ecx
xor    %eax,%eax
cmpl   $0x0,(%rdi,%rcx,4)
setne  %al
pop    %rcx
ret

LLVM IR (-O0):
@.str = [75 x i8] c"the second parameter is too big! The set_bit function can not accept it!\0A\0A\00"
define i32 @test_bit(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 0, i32* %6
store i32 64, i32* %7
%8 = load i32, i32* %5
%9 = load i32, i32* %7
%10 = sub nsw i32 %9, 1
%11 = icmp ugt i32 %8, %10
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %23
14: ; preds = %2
%15 = load i32*, i32** %4
%16 = load i32, i32* %5
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %14
store i32 1, i32* %3
br label %23
22: ; preds = %14
store i32 0, i32* %3
br label %23
23: ; preds = %22, %21, %12
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@str = [74 x i8] c"the second parameter is too big! The set_bit function can not accept it!\0A\00"
define i32 @test_bit(i32* nocapture %0, i32 %1) {
%3 = icmp ugt i32 %1, 63
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str, i64 0, i64 0))
br label %12
6: ; preds = %2
%7 = zext i32 %1 to i64
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = load i32, i32* %8
%10 = icmp ne i32 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %6, %4
%13 = phi i32 [ 0, %4 ], [ %11, %6 ]
ret i32 %13
}