#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 */
struct bitfield {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ bfclearall(struct bitfield *);
int bfcmp(struct bitfield *, struct bitfield *, int /*<<< orphan*/ *);
int /*<<< orphan*/ bfdel(struct bitfield *);
struct bitfield *bfnew(int);
struct bitfield *bfnew_ones(int);
struct bitfield *bfnew_quick(int);
int /*<<< orphan*/ bfsetall(struct bitfield *);
int /*<<< orphan*/ printf(char *, ...);
struct bitfield *str2bf(char *);
int strlen(char *);
int main() {
  int i, cmp;
  int len = 80;
  char *msg = "Testing bfnew_ones(), bfsetall() and bfclearall()";
  char *failed = "[FAIL]";
  char *passed = "[PASS]";
  int dots = len - strlen(msg) - 6;
  printf("%s", msg);
  for (i = 0; i < dots; i++)
    printf(".");
  char *input_char = "111111111111111111111111111111111111111111111111111111111"
                     "11111111111111111111111";
  struct bitfield *output1 = str2bf(input_char);
  struct bitfield *output2 = bfnew_ones(len);
  cmp = bfcmp(output1, output2, NULL);
  bfdel(output2);
  if (cmp != 0) {
    printf("%s\n", failed);
    return 1;
  }
  struct bitfield *output3 = bfnew_quick(len);
  bfsetall(output3);
  cmp = bfcmp(output1, output3, NULL);
  bfdel(output1);
  if (cmp != 0) {
    printf("%s\n", failed);
    return 1;
  }
  struct bitfield *output4 = bfnew(len);
  bfclearall(output3);
  cmp = bfcmp(output3, output4, NULL);
  bfdel(output3);
  bfdel(output4);
  if (cmp != 0) {
    printf("%s\n", failed);
    return 1;
  }
  printf("%s\n", passed);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x50,-0x10(%rbp)
lea    0xe43(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe6a(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe66(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
sub    %ecx,%eax
sub    $0x6,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1234 <main+0x94>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    120c <main+0x6c>
lea    0xe0a(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   10a0 <str2bf@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%edi
call   1070 <bfnew_ones@plt>
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <bfcmp@plt>
mov    %eax,-0xc(%rbp)
mov    -0x48(%rbp),%rdi
call   10b0 <bfdel@plt>
cmpl   $0x0,-0xc(%rbp)
je     129d <main+0xfd>
mov    -0x20(%rbp),%rsi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1373 <main+0x1d3>
mov    -0x10(%rbp),%edi
call   1030 <bfnew_quick@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
call   10c0 <bfsetall@plt>
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <bfcmp@plt>
mov    %eax,-0xc(%rbp)
mov    -0x40(%rbp),%rdi
call   10b0 <bfdel@plt>
cmpl   $0x0,-0xc(%rbp)
je     12f7 <main+0x157>
mov    -0x20(%rbp),%rsi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1373 <main+0x1d3>
mov    -0x10(%rbp),%edi
call   1060 <bfnew@plt>
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rdi
call   1090 <bfclearall@plt>
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <bfcmp@plt>
mov    %eax,-0xc(%rbp)
mov    -0x50(%rbp),%rdi
call   10b0 <bfdel@plt>
mov    -0x58(%rbp),%rdi
call   10b0 <bfdel@plt>
cmpl   $0x0,-0xc(%rbp)
je     135a <main+0x1ba>
mov    -0x20(%rbp),%rsi
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1373 <main+0x1d3>
mov    -0x28(%rbp),%rsi
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xe31(%rip),%r14
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    $0x4a,%ebp
sub    %eax,%ebp
lea    0xe59(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
test   %ebp,%ebp
jle    120e <main+0x4e>
add    $0xffffffb6,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x2e,%edi
call   1030 <putchar@plt>
inc    %ebx
jne    1200 <main+0x40>
lea    0xe2e(%rip),%rdi
call   10c0 <str2bf@plt>
mov    %rax,%r12
mov    $0x50,%edi
call   1090 <bfnew_ones@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   10a0 <bfcmp@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   10d0 <bfdel@plt>
mov    $0x1,%r14d
lea    0xde4(%rip),%rbx
test   %ebp,%ebp
jne    12d1 <main+0x111>
mov    $0x50,%edi
call   1040 <bfnew_quick@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   10e0 <bfsetall@plt>
mov    %r12,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   10a0 <bfcmp@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   10d0 <bfdel@plt>
test   %ebp,%ebp
jne    12d1 <main+0x111>
mov    $0x50,%edi
call   1080 <bfnew@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   10b0 <bfclearall@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   10a0 <bfcmp@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   10d0 <bfdel@plt>
mov    %rbx,%rdi
call   10d0 <bfdel@plt>
xor    %r14d,%r14d
test   %ebp,%ebp
setne  %r14b
lea    0xd73(%rip),%rax
lea    0xd65(%rip),%rbx
cmove  %rax,%rbx
mov    %rbx,%rdi
call   1050 <puts@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.bitfield = type { i32 }
@.str = [50 x i8] c"Testing bfnew_ones(), bfsetall() and bfclearall()\00"
@.str.1 = [7 x i8] c"[FAIL]\00"
@.str.2 = [7 x i8] c"[PASS]\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [81 x i8] c"11111111111111111111111111111111111111111111111111111111111111111111111111111111\00"
@.str.6 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca %struct.bitfield*
%11 = alloca %struct.bitfield*
%12 = alloca %struct.bitfield*
%13 = alloca %struct.bitfield*
store i32 0, i32* %1
store i32 80, i32* %4
store i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %7
%14 = load i32, i32* %4
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
%17 = sub nsw i32 %14, %16
%18 = sub nsw i32 %17, 6
store i32 %18, i32* %8
%19 = load i8*, i8** %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %19)
store i32 0, i32* %2
br label %21
21: ; preds = %27, %0
%22 = load i32, i32* %2
%23 = load i32, i32* %8
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %25
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %21
30: ; preds = %21
store i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.5, i64 0, i64 0), i8** %9
%31 = load i8*, i8** %9
%32 = call %struct.bitfield* @str2bf(i8* %31)
store %struct.bitfield* %32, %struct.bitfield** %10
%33 = load i32, i32* %4
%34 = call %struct.bitfield* @bfnew_ones(i32 %33)
store %struct.bitfield* %34, %struct.bitfield** %11
%35 = load %struct.bitfield*, %struct.bitfield** %10
%36 = load %struct.bitfield*, %struct.bitfield** %11
%37 = call i32 @bfcmp(%struct.bitfield* %35, %struct.bitfield* %36, i32* null)
store i32 %37, i32* %3
%38 = load %struct.bitfield*, %struct.bitfield** %11
%39 = call i32 @bfdel(%struct.bitfield* %38)
%40 = load i32, i32* %3
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %30
%43 = load i8*, i8** %6
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %43)
store i32 1, i32* %1
br label %80
45: ; preds = %30
%46 = load i32, i32* %4
%47 = call %struct.bitfield* @bfnew_quick(i32 %46)
store %struct.bitfield* %47, %struct.bitfield** %12
%48 = load %struct.bitfield*, %struct.bitfield** %12
%49 = call i32 @bfsetall(%struct.bitfield* %48)
%50 = load %struct.bitfield*, %struct.bitfield** %10
%51 = load %struct.bitfield*, %struct.bitfield** %12
%52 = call i32 @bfcmp(%struct.bitfield* %50, %struct.bitfield* %51, i32* null)
store i32 %52, i32* %3
%53 = load %struct.bitfield*, %struct.bitfield** %10
%54 = call i32 @bfdel(%struct.bitfield* %53)
%55 = load i32, i32* %3
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %45
%58 = load i8*, i8** %6
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %58)
store i32 1, i32* %1
br label %80
60: ; preds = %45
%61 = load i32, i32* %4
%62 = call %struct.bitfield* @bfnew(i32 %61)
store %struct.bitfield* %62, %struct.bitfield** %13
%63 = load %struct.bitfield*, %struct.bitfield** %12
%64 = call i32 @bfclearall(%struct.bitfield* %63)
%65 = load %struct.bitfield*, %struct.bitfield** %12
%66 = load %struct.bitfield*, %struct.bitfield** %13
%67 = call i32 @bfcmp(%struct.bitfield* %65, %struct.bitfield* %66, i32* null)
store i32 %67, i32* %3
%68 = load %struct.bitfield*, %struct.bitfield** %12
%69 = call i32 @bfdel(%struct.bitfield* %68)
%70 = load %struct.bitfield*, %struct.bitfield** %13
%71 = call i32 @bfdel(%struct.bitfield* %70)
%72 = load i32, i32* %3
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %60
%75 = load i8*, i8** %6
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %75)
store i32 1, i32* %1
br label %80
77: ; preds = %60
%78 = load i8*, i8** %7
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %78)
store i32 0, i32* %1
br label %80
80: ; preds = %77, %74, %57, %42
%81 = load i32, i32* %1
ret i32 %81
}

LLVM IR (-O2):
%struct.bitfield = type { i32 }
@.str = [50 x i8] c"Testing bfnew_ones(), bfsetall() and bfclearall()\00"
@.str.1 = [7 x i8] c"[FAIL]\00"
@.str.2 = [7 x i8] c"[PASS]\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.5 = [81 x i8] c"11111111111111111111111111111111111111111111111111111111111111111111111111111111\00"
define i32 @main() {
%1 = tail call i32 @strlen(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%2 = sub i32 74, %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %10
5: ; preds = %0, %5
%6 = phi i32 [ %8, %5 ], [ 0, %0 ]
%7 = tail call i32 @putchar(i32 46)
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, %2
br i1 %9, label %10, label %5
10: ; preds = %5, %0
%11 = tail call %struct.bitfield* @str2bf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.5, i64 0, i64 0))
%12 = tail call %struct.bitfield* @bfnew_ones(i32 80)
%13 = tail call i32 @bfcmp(%struct.bitfield* %11, %struct.bitfield* %12, i32* null)
%14 = tail call i32 @bfdel(%struct.bitfield* %12)
%15 = icmp eq i32 %13, 0
br i1 %15, label %16, label %32
16: ; preds = %10
%17 = tail call %struct.bitfield* @bfnew_quick(i32 80)
%18 = tail call i32 @bfsetall(%struct.bitfield* %17)
%19 = tail call i32 @bfcmp(%struct.bitfield* %11, %struct.bitfield* %17, i32* null)
%20 = tail call i32 @bfdel(%struct.bitfield* %11)
%21 = icmp eq i32 %19, 0
br i1 %21, label %22, label %32
22: ; preds = %16
%23 = tail call %struct.bitfield* @bfnew(i32 80)
%24 = tail call i32 @bfclearall(%struct.bitfield* %17)
%25 = tail call i32 @bfcmp(%struct.bitfield* %17, %struct.bitfield* %23, i32* null)
%26 = tail call i32 @bfdel(%struct.bitfield* %17)
%27 = tail call i32 @bfdel(%struct.bitfield* %23)
%28 = icmp eq i32 %25, 0
%29 = select i1 %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0)
%30 = xor i1 %28, true
%31 = zext i1 %30 to i32
br label %32
32: ; preds = %22, %16, %10
%33 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %10 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %16 ], [ %29, %22 ]
%34 = phi i32 [ 1, %10 ], [ 1, %16 ], [ %31, %22 ]
%35 = tail call i32 @puts(i8* dereferenceable(1) %33)
ret i32 %34
}