#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;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(unsigned char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
unsigned char setBit(unsigned char, int);
void getnputsecondbyte(FILE *Writeoutput) {
  int i;
  FILE *temp;
  temp = fopen("temp.txt", "r");
  unsigned char ch = NULL;
  fseek(temp, 8, SEEK_SET);
  for (i = 7; i >= 0; i--) {
    if (fgetc(temp) == '1') {
      ch = setBit(ch, i);
    }
  }
  fputc(ch, Writeoutput);
  fclose(temp);
}


x86 assembly (clang, -O0):
<getnputsecondbyte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe8d(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
mov    $0x8,%esi
call   1060 <fseek@plt>
movl   $0x7,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11e8 <getnputsecondbyte+0x88>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
movsbl %al,%eax
cmp    $0x31,%eax
jne    11d5 <getnputsecondbyte+0x75>
mov    -0x19(%rbp),%al
mov    -0xc(%rbp),%esi
movzbl %al,%edi
call   1080 <setBit@plt>
mov    %al,-0x19(%rbp)
jmp    11da <getnputsecondbyte+0x7a>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11a5 <getnputsecondbyte+0x45>
mov    -0x19(%rbp),%al
mov    -0x8(%rbp),%rsi
movzbl %al,%edi
call   1050 <fputc@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getnputsecondbyte>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xe92(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    0x2e5c(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1060 <fseek@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    11af <getnputsecondbyte+0x4f>
xor    %edi,%edi
mov    $0x7,%esi
call   1080 <setBit@plt>
mov    %eax,%ebp
jmp    11b1 <getnputsecondbyte+0x51>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    11cd <getnputsecondbyte+0x6d>
movzbl %bpl,%edi
mov    $0x6,%esi
call   1080 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    11e9 <getnputsecondbyte+0x89>
movzbl %bpl,%edi
mov    $0x5,%esi
call   1080 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    1205 <getnputsecondbyte+0xa5>
movzbl %bpl,%edi
mov    $0x4,%esi
call   1080 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    1221 <getnputsecondbyte+0xc1>
movzbl %bpl,%edi
mov    $0x3,%esi
call   1080 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    123d <getnputsecondbyte+0xdd>
movzbl %bpl,%edi
mov    $0x2,%esi
call   1080 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    1259 <getnputsecondbyte+0xf9>
movzbl %bpl,%edi
mov    $0x1,%esi
call   1080 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    1272 <getnputsecondbyte+0x112>
movzbl %bpl,%edi
xor    %esi,%esi
call   1080 <setBit@plt>
mov    %eax,%ebp
movzbl %bpl,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"temp.txt\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_SET = global i32 0
define void @getnputsecondbyte(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8
store i32* %0, i32** %2
%6 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %4
store i8 0, i8* %5
%7 = load i32*, i32** %4
%8 = load i32, i32* @SEEK_SET
%9 = call i32 @fseek(i32* %7, i32 8, i32 %8)
store i32 7, i32* %3
br label %10
10: ; preds = %23, %1
%11 = load i32, i32* %3
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = load i32*, i32** %4
%15 = call signext i8 @fgetc(i32* %14)
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 49
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = load i8, i8* %5
%20 = load i32, i32* %3
%21 = call zeroext i8 @setBit(i8 zeroext %19, i32 %20)
store i8 %21, i8* %5
br label %22
22: ; preds = %18, %13
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, -1
store i32 %25, i32* %3
br label %10
26: ; preds = %10
%27 = load i8, i8* %5
%28 = load i32*, i32** %2
%29 = call i32 @fputc(i8 zeroext %27, i32* %28)
%30 = load i32*, i32** %4
%31 = call i32 @fclose(i32* %30)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"temp.txt\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_SET = global i32 0
define void @getnputsecondbyte(i32* nocapture %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = load i32, i32* @SEEK_SET
%4 = tail call i32 @fseek(i32* %2, i32 8, i32 %3)
%5 = tail call signext i8 @fgetc(i32* %2)
%6 = icmp eq i8 %5, 49
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call zeroext i8 @setBit(i8 zeroext 0, i32 7)
br label %9
9: ; preds = %1, %7
%10 = phi i8 [ %8, %7 ], [ 0, %1 ]
%11 = tail call signext i8 @fgetc(i32* %2)
%12 = icmp eq i8 %11, 49
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call zeroext i8 @setBit(i8 zeroext %10, i32 6)
br label %15
15: ; preds = %13, %9
%16 = phi i8 [ %14, %13 ], [ %10, %9 ]
%17 = tail call signext i8 @fgetc(i32* %2)
%18 = icmp eq i8 %17, 49
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = tail call zeroext i8 @setBit(i8 zeroext %16, i32 5)
br label %21
21: ; preds = %19, %15
%22 = phi i8 [ %20, %19 ], [ %16, %15 ]
%23 = tail call signext i8 @fgetc(i32* %2)
%24 = icmp eq i8 %23, 49
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = tail call zeroext i8 @setBit(i8 zeroext %22, i32 4)
br label %27
27: ; preds = %25, %21
%28 = phi i8 [ %26, %25 ], [ %22, %21 ]
%29 = tail call signext i8 @fgetc(i32* %2)
%30 = icmp eq i8 %29, 49
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = tail call zeroext i8 @setBit(i8 zeroext %28, i32 3)
br label %33
33: ; preds = %31, %27
%34 = phi i8 [ %32, %31 ], [ %28, %27 ]
%35 = tail call signext i8 @fgetc(i32* %2)
%36 = icmp eq i8 %35, 49
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = tail call zeroext i8 @setBit(i8 zeroext %34, i32 2)
br label %39
39: ; preds = %37, %33
%40 = phi i8 [ %38, %37 ], [ %34, %33 ]
%41 = tail call signext i8 @fgetc(i32* %2)
%42 = icmp eq i8 %41, 49
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = tail call zeroext i8 @setBit(i8 zeroext %40, i32 1)
br label %45
45: ; preds = %43, %39
%46 = phi i8 [ %44, %43 ], [ %40, %39 ]
%47 = tail call signext i8 @fgetc(i32* %2)
%48 = icmp eq i8 %47, 49
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = tail call zeroext i8 @setBit(i8 zeroext %46, i32 0)
br label %51
51: ; preds = %49, %45
%52 = phi i8 [ %50, %49 ], [ %46, %45 ]
%53 = tail call i32 @fputc(i8 zeroext %52, i32* %0)
%54 = tail call i32 @fclose(i32* %2)
ret void
}