#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*/ fprintf(int /*<<< orphan*/ *, char *, char *,
                           int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ get_blank_from_bit(unsigned char const);
char *get_next_line_from_file(int /*<<< orphan*/ *);
int hide_byte(const unsigned char byte, FILE *cover_fp, FILE *output_fp) {
  int b;
  char *line = NULL;
  for (b = 0; b < 8; b++) {
    line = get_next_line_from_file(cover_fp);
    if (line == NULL) {
      return 0;
    }
    fprintf(output_fp, "%s%c\n", line,
            get_blank_from_bit((byte >> (7 - b)) & 0x1));
    free(line);
  }
  return 1;
}


x86 assembly (clang, -O0):
<hide_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    11e9 <hide_byte+0xa9>
mov    -0x10(%rbp),%rdi
call   1060 <get_next_line_from_file@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1193 <hide_byte+0x53>
movl   $0x0,-0x4(%rbp)
jmp    11f0 <hide_byte+0xb0>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
movzbl -0x5(%rbp),%eax
mov    $0x7,%ecx
sub    -0x1c(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
movzbl %al,%edi
call   1040 <get_blank_from_bit@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    %eax,%ecx
lea    0xe33(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1165 <hide_byte+0x25>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hide_byte>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,%r12d
mov    %rsi,%rdi
call   1060 <get_next_line_from_file@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     134c <hide_byte+0x20c>
mov    %rax,%rbp
mov    %r12d,%eax
shr    $0x7,%al
movzbl %al,%edi
call   1040 <get_blank_from_bit@plt>
lea    0xe83(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
mov    %eax,%ecx
call   1050 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <get_next_line_from_file@plt>
test   %rax,%rax
je     134c <hide_byte+0x20c>
mov    %rax,%rbp
mov    %r12d,%eax
shr    $0x6,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <get_blank_from_bit@plt>
lea    0xe43(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
mov    %eax,%ecx
call   1050 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <get_next_line_from_file@plt>
test   %rax,%rax
je     134c <hide_byte+0x20c>
mov    %rax,%rbp
mov    %r12d,%eax
shr    $0x5,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <get_blank_from_bit@plt>
lea    0xe03(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
mov    %eax,%ecx
call   1050 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <get_next_line_from_file@plt>
test   %rax,%rax
je     134c <hide_byte+0x20c>
mov    %rax,%rbp
mov    %r12d,%eax
shr    $0x4,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <get_blank_from_bit@plt>
lea    0xdc3(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
mov    %eax,%ecx
call   1050 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <get_next_line_from_file@plt>
test   %rax,%rax
je     134c <hide_byte+0x20c>
mov    %rax,%rbp
mov    %r12d,%eax
shr    $0x3,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <get_blank_from_bit@plt>
lea    0xd83(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
mov    %eax,%ecx
call   1050 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <get_next_line_from_file@plt>
test   %rax,%rax
je     134c <hide_byte+0x20c>
mov    %rax,%rbp
mov    %r12d,%eax
shr    $0x2,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <get_blank_from_bit@plt>
lea    0xd43(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
mov    %eax,%ecx
call   1050 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <get_next_line_from_file@plt>
test   %rax,%rax
je     134c <hide_byte+0x20c>
mov    %rax,%rbp
mov    %r12d,%eax
shr    %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <get_blank_from_bit@plt>
lea    0xd08(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
mov    %eax,%ecx
call   1050 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <get_next_line_from_file@plt>
test   %rax,%rax
je     134c <hide_byte+0x20c>
mov    %rax,%rbx
and    $0x1,%r12b
movzbl %r12b,%edi
call   1040 <get_blank_from_bit@plt>
lea    0xccf(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s%c\0A\00"
define i32 @hide_byte(i8 zeroext %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8*
store i8 %0, i8* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i8* null, i8** %9
store i32 0, i32* %8
br label %10
10: ; preds = %33, %3
%11 = load i32, i32* %8
%12 = icmp slt i32 %11, 8
br i1 %12, label %13, label %36
13: ; preds = %10
%14 = load i32*, i32** %6
%15 = call i8* @get_next_line_from_file(i32* %14)
store i8* %15, i8** %9
%16 = load i8*, i8** %9
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 0, i32* %4
br label %37
19: ; preds = %13
%20 = load i32*, i32** %7
%21 = load i8*, i8** %9
%22 = load i8, i8* %5
%23 = zext i8 %22 to i32
%24 = load i32, i32* %8
%25 = sub nsw i32 7, %24
%26 = ashr i32 %23, %25
%27 = and i32 %26, 1
%28 = trunc i32 %27 to i8
%29 = call i32 @get_blank_from_bit(i8 zeroext %28)
%30 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %21, i32 %29)
%31 = load i8*, i8** %9
%32 = call i32 @free(i8* %31)
br label %33
33: ; preds = %19
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %10
36: ; preds = %10
store i32 1, i32* %4
br label %37
37: ; preds = %36, %18
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s%c\0A\00"
define i32 @hide_byte(i8 zeroext %0, i32* %1, i32* nocapture %2) {
%4 = tail call i8* @get_next_line_from_file(i32* %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %66, label %6
6: ; preds = %3
%7 = lshr i8 %0, 7
%8 = tail call i32 @get_blank_from_bit(i8 zeroext %7)
%9 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %8)
%10 = tail call i32 @free(i8* %4)
%11 = tail call i8* @get_next_line_from_file(i32* %1)
%12 = icmp eq i8* %11, null
br i1 %12, label %66, label %13
13: ; preds = %6
%14 = lshr i8 %0, 6
%15 = and i8 %14, 1
%16 = tail call i32 @get_blank_from_bit(i8 zeroext %15)
%17 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %11, i32 %16)
%18 = tail call i32 @free(i8* %11)
%19 = tail call i8* @get_next_line_from_file(i32* %1)
%20 = icmp eq i8* %19, null
br i1 %20, label %66, label %21
21: ; preds = %13
%22 = lshr i8 %0, 5
%23 = and i8 %22, 1
%24 = tail call i32 @get_blank_from_bit(i8 zeroext %23)
%25 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %19, i32 %24)
%26 = tail call i32 @free(i8* %19)
%27 = tail call i8* @get_next_line_from_file(i32* %1)
%28 = icmp eq i8* %27, null
br i1 %28, label %66, label %29
29: ; preds = %21
%30 = lshr i8 %0, 4
%31 = and i8 %30, 1
%32 = tail call i32 @get_blank_from_bit(i8 zeroext %31)
%33 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %27, i32 %32)
%34 = tail call i32 @free(i8* %27)
%35 = tail call i8* @get_next_line_from_file(i32* %1)
%36 = icmp eq i8* %35, null
br i1 %36, label %66, label %37
37: ; preds = %29
%38 = lshr i8 %0, 3
%39 = and i8 %38, 1
%40 = tail call i32 @get_blank_from_bit(i8 zeroext %39)
%41 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %35, i32 %40)
%42 = tail call i32 @free(i8* %35)
%43 = tail call i8* @get_next_line_from_file(i32* %1)
%44 = icmp eq i8* %43, null
br i1 %44, label %66, label %45
45: ; preds = %37
%46 = lshr i8 %0, 2
%47 = and i8 %46, 1
%48 = tail call i32 @get_blank_from_bit(i8 zeroext %47)
%49 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %43, i32 %48)
%50 = tail call i32 @free(i8* %43)
%51 = tail call i8* @get_next_line_from_file(i32* %1)
%52 = icmp eq i8* %51, null
br i1 %52, label %66, label %53
53: ; preds = %45
%54 = lshr i8 %0, 1
%55 = and i8 %54, 1
%56 = tail call i32 @get_blank_from_bit(i8 zeroext %55)
%57 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %51, i32 %56)
%58 = tail call i32 @free(i8* %51)
%59 = tail call i8* @get_next_line_from_file(i32* %1)
%60 = icmp eq i8* %59, null
br i1 %60, label %66, label %61
61: ; preds = %53
%62 = and i8 %0, 1
%63 = tail call i32 @get_blank_from_bit(i8 zeroext %62)
%64 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %59, i32 %63)
%65 = tail call i32 @free(i8* %59)
br label %66
66: ; preds = %61, %53, %45, %37, %29, %21, %13, %6, %3
%67 = phi i32 [ 0, %3 ], [ 0, %6 ], [ 0, %13 ], [ 0, %21 ], [ 0, %29 ], [ 0, %37 ], [ 0, %45 ], [ 0, %53 ], [ 1, %61 ]
ret i32 %67
}