#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
void ASCIITexttoBinary() {
  FILE *inPtr;
  FILE *outPtr;
  char choose;
  char textFilePath[256];
  char outFileName[128];
  char ch;
PROCSTART:
  printf("Enter the path\n");
  scanf("%s", textFilePath);
  printf("%s", textFilePath);
  if ((inPtr = fopen(textFilePath, "r")) == NULL) {
    printf("This file can't open.\n");
    printf("Press A or a for try again // Press any key for quit\n");
    scanf("%c", &choose);
    if (choose == 'A' || choose == 'a')
      goto PROCSTART;
    else {
      return;
    }
  } else {
    printf("\nPlease enter the output file name\n");
    scanf("%s", outFileName);
    printf("%s", outFileName);
    if ((outPtr = fopen(outFileName, "w")) == NULL) {
      printf("This file can't open.\nProgram Closing...\n");
      fclose(inPtr);
      return;
    } else {
      while (fscanf(inPtr, "%c", &ch) != EOF) {
        fprintf(outPtr, "%d", (int)ch);
      }
    }
  }
  fclose(inPtr);
  fclose(outPtr);
  return;
}


x86 assembly (clang, -O0):
<ASCIITexttoBinary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x120(%rbp),%rsi
lea    0xe89(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x120(%rbp),%rsi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    1212 <ASCIITexttoBinary+0xb2>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7d(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1070 <scanf@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x41,%eax
je     1208 <ASCIITexttoBinary+0xa8>
movsbl -0x11(%rbp),%eax
cmp    $0x61,%eax
jne    120d <ASCIITexttoBinary+0xad>
jmp    116b <ASCIITexttoBinary+0xb>
jmp    12e9 <ASCIITexttoBinary+0x189>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1a0(%rbp),%rsi
lea    0xde2(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x1a0(%rbp),%rsi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1a0(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1285 <ASCIITexttoBinary+0x125>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
jmp    12e9 <ASCIITexttoBinary+0x189>
jmp    128a <ASCIITexttoBinary+0x12a>
mov    -0x8(%rbp),%rdi
lea    0xdcd(%rip),%rsi
lea    -0x1a1(%rbp),%rdx
call   1050 <fscanf@plt>
mov    0x2d40(%rip),%rcx
cmp    (%rcx),%rax
je     12cd <ASCIITexttoBinary+0x16d>
mov    -0x10(%rbp),%rdi
movsbl -0x1a1(%rbp),%edx
lea    0xdf2(%rip),%rsi
call   1060 <fprintf@plt>
jmp    128a <ASCIITexttoBinary+0x12a>
jmp    12d2 <ASCIITexttoBinary+0x172>
jmp    12d7 <ASCIITexttoBinary+0x177>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASCIITexttoBinary>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x198,%rsp
lea    0xe78(%rip),%r15
lea    0x90(%rsp),%r12
lea    0xe6c(%rip),%r13
lea    0xe67(%rip),%rbp
lea    0xf(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe56(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1090 <fopen@plt>
test   %rax,%rax
jne    1217 <ASCIITexttoBinary+0xa7>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1080 <scanf@plt>
movzbl 0xf(%rsp),%eax
and    $0xdf,%al
cmp    $0x41,%al
je     11b0 <ASCIITexttoBinary+0x40>
jmp    12e5 <ASCIITexttoBinary+0x175>
mov    %rax,%rbx
lea    0xdfb(%rip),%rdi
call   1030 <puts@plt>
lea    0xdd3(%rip),%r14
lea    0x10(%rsp),%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
call   1080 <scanf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdb7(%rip),%rsi
mov    %rbp,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     12ce <ASCIITexttoBinary+0x15e>
mov    %rax,%r14
lea    0xd9d(%rip),%rsi
lea    0xe(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <fscanf@plt>
mov    0x2d6c(%rip),%r13
cmp    0x0(%r13),%rax
je     12c4 <ASCIITexttoBinary+0x154>
lea    0xd81(%rip),%r15
lea    0xd75(%rip),%r12
lea    0xe(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
movsbl 0xe(%rsp),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <fprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1060 <fscanf@plt>
cmp    0x0(%r13),%rax
jne    12a0 <ASCIITexttoBinary+0x130>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    12dd <ASCIITexttoBinary+0x16d>
lea    0xd6a(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%r14
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0x198,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Enter the path\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [23 x i8] c"This file can't open.\0A\00"
@.str.4 = [54 x i8] c"Press A or a for try again // Press any key for quit\0A\00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [36 x i8] c"\0APlease enter the output file name\0A\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [42 x i8] c"This file can't open.\0AProgram Closing...\0A\00"
@EOF = global i64 0
@.str.9 = [3 x i8] c"%d\00"
define void @ASCIITexttoBinary() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca i8
%4 = alloca [256 x i8]
%5 = alloca [128 x i8]
%6 = alloca i8
br label %7
7: ; preds = %27, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %14, i32** %1
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %29
16: ; preds = %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %3)
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 65
br i1 %22, label %27, label %23
23: ; preds = %16
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 97
br i1 %26, label %27, label %28
27: ; preds = %23, %16
br label %7
28: ; preds = %23
br label %60
29: ; preds = %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %36, i32** %2
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %42
38: ; preds = %29
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
%40 = load i32*, i32** %1
%41 = call i32 @fclose(i32* %40)
br label %60
42: ; preds = %29
br label %43
43: ; preds = %48, %42
%44 = load i32*, i32** %1
%45 = call i64 @fscanf(i32* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %6)
%46 = load i64, i64* @EOF
%47 = icmp ne i64 %45, %46
br i1 %47, label %48, label %53
48: ; preds = %43
%49 = load i32*, i32** %2
%50 = load i8, i8* %6
%51 = sext i8 %50 to i32
%52 = call i32 @fprintf(i32* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %51)
br label %43
53: ; preds = %43
br label %54
54: ; preds = %53
br label %55
55: ; preds = %54
%56 = load i32*, i32** %1
%57 = call i32 @fclose(i32* %56)
%58 = load i32*, i32** %2
%59 = call i32 @fclose(i32* %58)
br label %60
60: ; preds = %55, %38, %28
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.5 = [3 x i8] c"%c\00"
@.str.7 = [2 x i8] c"w\00"
@EOF = global i64 0
@.str.9 = [3 x i8] c"%d\00"
@str = [15 x i8] c"Enter the path\00"
@str.10 = [35 x i8] c"\0APlease enter the output file name\00"
@str.11 = [41 x i8] c"This file can't open.\0AProgram Closing...\00"
@str.12 = [22 x i8] c"This file can't open.\00"
@str.13 = [53 x i8] c"Press A or a for try again // Press any key for quit\00"
define void @ASCIITexttoBinary() {
%1 = alloca i8
%2 = alloca [256 x i8]
%3 = alloca [128 x i8]
%4 = alloca i8
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
br label %7
7: ; preds = %13, %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%11 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %20
13: ; preds = %7
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.13, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %1)
%17 = load i8, i8* %1
%18 = and i8 %17, -33
%19 = icmp eq i8 %18, 65
br i1 %19, label %7, label %44
20: ; preds = %7
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.10, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%24 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %30, label %26
26: ; preds = %20
%27 = call i64 @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%28 = load i64, i64* @EOF
%29 = icmp eq i64 %27, %28
br i1 %29, label %39, label %32
30: ; preds = %20
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.11, i64 0, i64 0))
br label %41
32: ; preds = %26, %32
%33 = load i8, i8* %4
%34 = sext i8 %33 to i32
%35 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %34)
%36 = call i64 @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%37 = load i64, i64* @EOF
%38 = icmp eq i64 %36, %37
br i1 %38, label %39, label %32
39: ; preds = %32, %26
%40 = call i32 @fclose(i32* %11)
br label %41
41: ; preds = %30, %39
%42 = phi i32* [ %24, %39 ], [ %11, %30 ]
%43 = call i32 @fclose(i32* %42)
br label %44
44: ; preds = %13, %41
ret void
}