#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 assign_bit(int bit_array[], unsigned bit_number, int value) {
  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 (value == 0) {
    bit_array[bit_number] = 0;
  } else {
    bit_array[bit_number] = 1;
  }
  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):
<assign_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x40,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jbe    115b <assign_bit+0x4b>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f9 <assign_bit+0xe9>
cmpl   $0x0,-0x18(%rbp)
jne    1178 <assign_bit+0x68>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movl   $0x0,(%rax,%rcx,4)
jmp    1186 <assign_bit+0x76>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movl   $0x1,(%rax,%rcx,4)
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11f2 <assign_bit+0xe2>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11df <assign_bit+0xcf>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e4 <assign_bit+0xd4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119b <assign_bit+0x8b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assign_bit>:
push   %r15
push   %r14
push   %rbx
cmp    $0x40,%esi
jb     1148 <assign_bit+0x18>
lea    0xee8(%rip),%rdi
call   1040 <puts@plt>
jmp    1192 <assign_bit+0x62>
mov    %rdi,%r15
xor    %eax,%eax
test   %edx,%edx
setne  %al
mov    %esi,%ecx
mov    %eax,(%rdi,%rcx,4)
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeba(%rip),%r14
xor    %ebx,%ebx
xchg   %ax,%ax
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x40,%rbx
jne    1170 <assign_bit+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
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"
@.str.1 = [38 x i8] c"After the process, the bit array is :\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @assign_bit(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 0, i32* %8
store i32 64, i32* %9
%10 = load i32, i32* %6
%11 = load i32, i32* %9
%12 = sub nsw i32 %11, 1
%13 = icmp ugt i32 %10, %12
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %53
16: ; preds = %3
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i32*, i32** %5
%21 = load i32, i32* %6
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
store i32 0, i32* %23
br label %29
24: ; preds = %16
%25 = load i32*, i32** %5
%26 = load i32, i32* %6
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
store i32 1, i32* %28
br label %29
29: ; preds = %24, %19
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %8
br label %31
31: ; preds = %49, %29
%32 = load i32, i32* %8
%33 = load i32, i32* %9
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %52
35: ; preds = %31
%36 = load i32*, i32** %5
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %8
%43 = load i32, i32* %9
%44 = sub nsw i32 %43, 1
%45 = icmp eq i32 %42, %44
br i1 %45, label %46, label %48
46: ; preds = %35
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %48
48: ; preds = %46, %35
br label %49
49: ; preds = %48
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
br label %31
52: ; preds = %31
store i32 0, i32* %4
br label %53
53: ; preds = %52, %14
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
@.str.1 = [38 x i8] c"After the process, the bit array is :\00"
@.str.2 = [3 x i8] c"%d\00"
@str = [74 x i8] c"the second parameter is too big! The set_bit function can not accept it!\0A\00"
define i32 @assign_bit(i32* nocapture %0, i32 %1, i32 %2) {
%4 = icmp ugt i32 %1, 63
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str, i64 0, i64 0))
br label %22
7: ; preds = %3
%8 = icmp ne i32 %2, 0
%9 = zext i32 %1 to i64
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = zext i1 %8 to i32
store i32 %11, i32* %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %13, %7
%14 = phi i64 [ 0, %7 ], [ %19, %13 ]
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = icmp eq i64 %14, 63
%19 = add nuw nsw i64 %14, 1
br i1 %18, label %20, label %13
20: ; preds = %13
%21 = tail call i32 @putchar(i32 10)
br label %22
22: ; preds = %20, %5
ret i32 0
}