#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
unsigned char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
scalar_t__ isBitISet(unsigned char, int);
unsigned char setBit(unsigned char, int);
int givemethetrash(FILE *f) {
  int i;
  unsigned char ch, trash = NULL;
  fseek(f, 0, SEEK_SET);
  ch = fgetc(f);
  for (i = 5; i <= 7; i++) {
    if (isBitISet(ch, i) > 0) {
      trash = setBit(trash, i - 5);
    }
  }
  return trash;
}


x86 assembly (clang, -O0):
<givemethetrash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0xe(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0xd(%rbp)
movl   $0x5,-0xc(%rbp)
cmpl   $0x7,-0xc(%rbp)
jg     11c0 <givemethetrash+0x80>
mov    -0xd(%rbp),%al
mov    -0xc(%rbp),%esi
movzbl %al,%edi
call   1040 <isBitISet@plt>
cmp    $0x0,%rax
jle    11ad <givemethetrash+0x6d>
mov    -0xe(%rbp),%al
mov    -0xc(%rbp),%esi
sub    $0x5,%esi
movzbl %al,%edi
call   1060 <setBit@plt>
mov    %al,-0xe(%rbp)
jmp    11b2 <givemethetrash+0x72>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1177 <givemethetrash+0x37>
movzbl -0xe(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<givemethetrash>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbp
mov    0x2e93(%rip),%rax
mov    (%rax),%edx
xor    %ebx,%ebx
xor    %esi,%esi
call   1050 <fseek@plt>
mov    %rbp,%rdi
call   1030 <fgetc@plt>
movzbl %al,%ebp
mov    %ebp,%edi
mov    $0x5,%esi
call   1040 <isBitISet@plt>
test   %rax,%rax
jle    117f <givemethetrash+0x3f>
xor    %edi,%edi
xor    %esi,%esi
call   1060 <setBit@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0x6,%esi
call   1040 <isBitISet@plt>
test   %rax,%rax
jle    119f <givemethetrash+0x5f>
movzbl %bl,%edi
mov    $0x1,%esi
call   1060 <setBit@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0x7,%esi
call   1040 <isBitISet@plt>
test   %rax,%rax
jle    11bf <givemethetrash+0x7f>
movzbl %bl,%edi
mov    $0x2,%esi
call   1060 <setBit@plt>
mov    %eax,%ebx
movzbl %bl,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @givemethetrash(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
store i32* %0, i32** %2
store i8 0, i8* %5
%6 = load i32*, i32** %2
%7 = load i32, i32* @SEEK_SET
%8 = call i32 @fseek(i32* %6, i32 0, i32 %7)
%9 = load i32*, i32** %2
%10 = call zeroext i8 @fgetc(i32* %9)
store i8 %10, i8* %4
store i32 5, i32* %3
br label %11
11: ; preds = %25, %1
%12 = load i32, i32* %3
%13 = icmp sle i32 %12, 7
br i1 %13, label %14, label %28
14: ; preds = %11
%15 = load i8, i8* %4
%16 = load i32, i32* %3
%17 = call i64 @isBitISet(i8 zeroext %15, i32 %16)
%18 = icmp sgt i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i8, i8* %5
%21 = load i32, i32* %3
%22 = sub nsw i32 %21, 5
%23 = call zeroext i8 @setBit(i8 zeroext %20, i32 %22)
store i8 %23, i8* %5
br label %24
24: ; preds = %19, %14
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %11
28: ; preds = %11
%29 = load i8, i8* %5
%30 = zext i8 %29 to i32
ret i32 %30
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @givemethetrash(i32* nocapture %0) {
%2 = load i32, i32* @SEEK_SET
%3 = tail call i32 @fseek(i32* %0, i32 0, i32 %2)
%4 = tail call zeroext i8 @fgetc(i32* %0)
%5 = tail call i64 @isBitISet(i8 zeroext %4, i32 5)
%6 = icmp sgt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call zeroext i8 @setBit(i8 zeroext 0, i32 0)
br label %9
9: ; preds = %1, %7
%10 = phi i8 [ %8, %7 ], [ 0, %1 ]
%11 = tail call i64 @isBitISet(i8 zeroext %4, i32 6)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call zeroext i8 @setBit(i8 zeroext %10, i32 1)
br label %15
15: ; preds = %13, %9
%16 = phi i8 [ %14, %13 ], [ %10, %9 ]
%17 = tail call i64 @isBitISet(i8 zeroext %4, i32 7)
%18 = icmp sgt i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = tail call zeroext i8 @setBit(i8 zeroext %16, i32 2)
br label %21
21: ; preds = %19, %15
%22 = phi i8 [ %20, %19 ], [ %16, %15 ]
%23 = zext i8 %22 to i32
ret i32 %23
}