#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 stat {
  int st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
unsigned char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fstat(int, struct stat *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int print_bits(char *file_name, int length) {
  int file_length = length;
  if (file_name == NULL) {
    return -1;
  }
  FILE *fp = fopen(file_name, "rb");
  if (fp == NULL) {
    return -1;
  }
  if (file_length == -1) {
    int fd = open(file_name, O_RDONLY);
    struct stat filestat;
    int status = fstat(fd, &filestat);
    do {
      if ((status) != 0) {
        fprintf(stderr, "info: %s:%d:\n ",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/"
                "master/UTILS/src/DEPRECATED/bitops.c",
                201);
        return (status);
      }
    } while (0);
    file_length = filestat.st_size;
  }
  unsigned char byte;
  for (int i = 0; i < file_length; i++) {
    byte = fgetc(fp);
    for (int j = 0; j < 8; j++) {
      do {
        if (0)
          fprintf(stderr, "%d\n", (((&byte)[(j) / 8] & (1 << ((j) % 8))) > 0));
      } while (0);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<print_bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117c <print_bits+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    127f <print_bits+0x12f>
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a7 <print_bits+0x57>
movl   $0xffffffff,-0x4(%rbp)
jmp    127f <print_bits+0x12f>
cmpl   $0xffffffff,-0x18(%rbp)
jne    1218 <print_bits+0xc8>
mov    -0x10(%rbp),%rdi
mov    0x2e2c(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1070 <fstat@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     120d <print_bits+0xbd>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
lea    0xe1c(%rip),%rdx
mov    $0xc9,%ecx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    127f <print_bits+0x12f>
jmp    1212 <print_bits+0xc2>
mov    -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1278 <print_bits+0x128>
mov    -0x20(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x2d(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x8,-0x38(%rbp)
jge    1265 <print_bits+0x115>
jmp    124d <print_bits+0xfd>
jmp    1252 <print_bits+0x102>
jmp    1257 <print_bits+0x107>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    123e <print_bits+0xee>
jmp    126a <print_bits+0x11a>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    121f <print_bits+0xcf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bits>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
test   %rdi,%rdi
je     11e4 <print_bits+0x94>
mov    %esi,%ebp
mov    %rdi,%r15
lea    0xe8e(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11e4 <print_bits+0x94>
mov    %rax,%rbx
cmp    $0xffffffff,%ebp
je     119f <print_bits+0x4f>
xor    %r14d,%r14d
test   %ebp,%ebp
jle    11e4 <print_bits+0x94>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <fgetc@plt>
add    $0xffffffff,%ebp
jne    1190 <print_bits+0x40>
jmp    11e4 <print_bits+0x94>
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1050 <open@plt>
mov    %rsp,%rsi
mov    %eax,%edi
call   1070 <fstat@plt>
test   %eax,%eax
je     11f2 <print_bits+0xa2>
mov    %eax,%r14d
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe32(%rip),%rsi
lea    0xe3a(%rip),%rdx
mov    $0xc9,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsp),%ebp
jmp    1184 <print_bits+0x34>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [3 x i8] c"rb\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.1 = [15 x i8] c"info: %s:%d:\0A \00"
@.str.2 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/master/UTILS/src/DEPRECATED/bitops.c\00"
define i32 @print_bits(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca %struct.stat
%10 = alloca i32
%11 = alloca i8
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%14 = load i32, i32* %5
store i32 %14, i32* %6
%15 = load i8*, i8** %4
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 -1, i32* %3
br label %66
18: ; preds = %2
%19 = load i8*, i8** %4
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %7
%21 = load i32*, i32** %7
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 -1, i32* %3
br label %66
24: ; preds = %18
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %44
27: ; preds = %24
%28 = load i8*, i8** %4
%29 = load i32, i32* @O_RDONLY
%30 = call i32 @open(i8* %28, i32 %29)
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = call i32 @fstat(i32 %31, %struct.stat* %9)
store i32 %32, i32* %10
br label %33
33: ; preds = %27
%34 = load i32, i32* %10
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.2, i64 0, i64 0), i32 201)
%39 = load i32, i32* %10
store i32 %39, i32* %3
br label %66
40: ; preds = %33
br label %41
41: ; preds = %40
%42 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%43 = load i32, i32* %42
store i32 %43, i32* %6
br label %44
44: ; preds = %41, %24
store i32 0, i32* %12
br label %45
45: ; preds = %62, %44
%46 = load i32, i32* %12
%47 = load i32, i32* %6
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %65
49: ; preds = %45
%50 = load i32*, i32** %7
%51 = call zeroext i8 @fgetc(i32* %50)
store i8 %51, i8* %11
store i32 0, i32* %13
br label %52
52: ; preds = %58, %49
%53 = load i32, i32* %13
%54 = icmp slt i32 %53, 8
br i1 %54, label %55, label %61
55: ; preds = %52
br label %56
56: ; preds = %55
br label %57
57: ; preds = %56
br label %58
58: ; preds = %57
%59 = load i32, i32* %13
%60 = add nsw i32 %59, 1
store i32 %60, i32* %13
br label %52
61: ; preds = %52
br label %62
62: ; preds = %61
%63 = load i32, i32* %12
%64 = add nsw i32 %63, 1
store i32 %64, i32* %12
br label %45
65: ; preds = %45
store i32 0, i32* %3
br label %66
66: ; preds = %65, %36, %23, %17
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [3 x i8] c"rb\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.1 = [15 x i8] c"info: %s:%d:\0A \00"
@.str.2 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/NerdWalletOSS/Q/refs/heads/master/UTILS/src/DEPRECATED/bitops.c\00"
define i32 @print_bits(i8* %0, i32 %1) {
%3 = alloca %struct.stat
%4 = icmp eq i8* %0, null
br i1 %4, label %30, label %5
5: ; preds = %2
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %30, label %8
8: ; preds = %5
%9 = icmp eq i32 %1, -1
br i1 %9, label %10, label %22
10: ; preds = %8
%11 = load i32, i32* @O_RDONLY
%12 = tail call i32 @open(i8* %0, i32 %11)
%13 = bitcast %struct.stat* %3 to i8*
%14 = call i32 @fstat(i32 %12, %struct.stat* %3)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%18 = load i32, i32* %17
br label %22
19: ; preds = %10
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.2, i64 0, i64 0), i32 201)
br label %30
22: ; preds = %16, %8
%23 = phi i32 [ %1, %8 ], [ %18, %16 ]
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %22, %25
%26 = phi i32 [ %28, %25 ], [ 0, %22 ]
%27 = tail call zeroext i8 @fgetc(i32* %6)
%28 = add nuw nsw i32 %26, 1
%29 = icmp eq i32 %28, %23
br i1 %29, label %30, label %25
30: ; preds = %25, %22, %19, %5, %2
%31 = phi i32 [ -1, %2 ], [ %14, %19 ], [ -1, %5 ], [ 0, %22 ], [ 0, %25 ]
ret i32 %31
}