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


x86 assembly (clang, -O0):
<getnputfirstbyte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
movl   $0x7,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11c1 <getnputfirstbyte+0x71>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
movsbl %al,%eax
cmp    $0x31,%eax
jne    11ae <getnputfirstbyte+0x5e>
mov    -0x19(%rbp),%al
mov    -0xc(%rbp),%esi
movzbl %al,%edi
call   1070 <setBit@plt>
mov    %al,-0x19(%rbp)
jmp    11b3 <getnputfirstbyte+0x63>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    117e <getnputfirstbyte+0x2e>
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):
<getnputfirstbyte>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xea2(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    1189 <getnputfirstbyte+0x39>
xor    %edi,%edi
mov    $0x7,%esi
call   1070 <setBit@plt>
mov    %eax,%ebp
jmp    118b <getnputfirstbyte+0x3b>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    11a7 <getnputfirstbyte+0x57>
movzbl %bpl,%edi
mov    $0x6,%esi
call   1070 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    11c3 <getnputfirstbyte+0x73>
movzbl %bpl,%edi
mov    $0x5,%esi
call   1070 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    11df <getnputfirstbyte+0x8f>
movzbl %bpl,%edi
mov    $0x4,%esi
call   1070 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    11fb <getnputfirstbyte+0xab>
movzbl %bpl,%edi
mov    $0x3,%esi
call   1070 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    1217 <getnputfirstbyte+0xc7>
movzbl %bpl,%edi
mov    $0x2,%esi
call   1070 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    1233 <getnputfirstbyte+0xe3>
movzbl %bpl,%edi
mov    $0x1,%esi
call   1070 <setBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x31,%al
jne    124c <getnputfirstbyte+0xfc>
movzbl %bpl,%edi
xor    %esi,%esi
call   1070 <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"
define void @getnputfirstbyte(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
store i32 7, i32* %3
br label %7
7: ; preds = %20, %1
%8 = load i32, i32* %3
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = load i32*, i32** %4
%12 = call signext i8 @fgetc(i32* %11)
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 49
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i8, i8* %5
%17 = load i32, i32* %3
%18 = call zeroext i8 @setBit(i8 zeroext %16, i32 %17)
store i8 %18, i8* %5
br label %19
19: ; preds = %15, %10
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, -1
store i32 %22, i32* %3
br label %7
23: ; preds = %7
%24 = load i8, i8* %5
%25 = load i32*, i32** %2
%26 = call i32 @fputc(i8 zeroext %24, i32* %25)
%27 = load i32*, i32** %4
%28 = call i32 @fclose(i32* %27)
ret void
}

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