#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
void randomSample1() {
  FILE *fi = fopen("H:\\codes\\C\\C-File\\file\\test3.txt", "r");
  FILE *fo = fopen("H:\\codes\\C\\C-File\\file\\test5.txt", "w");
  if (fi == NULL || fo == NULL) {
    printf("file open error");
    exit(EXIT_SUCCESS);
  }
  while (feof(fi)) {
    printf("%c", getc(fi));
  }
  putchar('\n');
  rewind(fi);
  while (feof(fi)) {
    putc(getc(fi), fo);
  }
  fclose(fi);
  fclose(fo);
}


x86 assembly (clang, -O0):
<randomSample1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe61(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x8(%rbp)
lea    0xe6b(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11dc <randomSample1+0x4c>
cmpq   $0x0,-0x10(%rbp)
jne    11f8 <randomSample1+0x68>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    11fd <randomSample1+0x6d>
mov    -0x8(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     122e <randomSample1+0x9e>
mov    -0x8(%rbp),%rdi
call   10b0 <getc@plt>
mov    %eax,%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11fd <randomSample1+0x6d>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x8(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     126d <randomSample1+0xdd>
mov    -0x8(%rbp),%rdi
call   10b0 <getc@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1070 <putc@plt>
jmp    1241 <randomSample1+0xb1>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomSample1>:
push   %r14
push   %rbx
push   %rax
lea    0xe65(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
lea    0xe70(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1090 <fopen@plt>
test   %rbx,%rbx
je     1238 <randomSample1+0xa8>
mov    %rax,%r14
test   %rax,%rax
je     1238 <randomSample1+0xa8>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %rax,%rax
je     11ee <randomSample1+0x5e>
mov    %rbx,%rdi
call   10b0 <getc@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    11d0 <randomSample1+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <rewind@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %rax,%rax
je     1221 <randomSample1+0x91>
mov    %rbx,%rdi
call   10b0 <getc@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1070 <putc@plt>
jmp    1200 <randomSample1+0x70>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fclose@plt>
lea    0xe05(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"H:\\codes\\C\\C-File\\file\\test3.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [33 x i8] c"H:\\codes\\C\\C-File\\file\\test5.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [16 x i8] c"file open error\00"
@EXIT_SUCCESS = global i32 0
@.str.5 = [3 x i8] c"%c\00"
define void @randomSample1() {
%1 = alloca i32*
%2 = alloca i32*
%3 = call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %1
%6 = icmp eq i32* %5, null
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load i32*, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %14
10: ; preds = %7, %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%12 = load i32, i32* @EXIT_SUCCESS
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %7
br label %15
15: ; preds = %19, %14
%16 = load i32*, i32** %1
%17 = call i64 @feof(i32* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i32*, i32** %1
%21 = call i32 @getc(i32* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %21)
br label %15
23: ; preds = %15
%24 = call i32 @putchar(i8 signext 10)
%25 = load i32*, i32** %1
%26 = call i32 @rewind(i32* %25)
br label %27
27: ; preds = %31, %23
%28 = load i32*, i32** %1
%29 = call i64 @feof(i32* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i32*, i32** %1
%33 = call i32 @getc(i32* %32)
%34 = load i32*, i32** %2
%35 = call i32 @putc(i32 %33, i32* %34)
br label %27
36: ; preds = %27
%37 = load i32*, i32** %1
%38 = call i32 @fclose(i32* %37)
%39 = load i32*, i32** %2
%40 = call i32 @fclose(i32* %39)
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"H:\\codes\\C\\C-File\\file\\test3.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [33 x i8] c"H:\\codes\\C\\C-File\\file\\test5.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [16 x i8] c"file open error\00"
@EXIT_SUCCESS = global i32 0
define void @randomSample1() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%3 = icmp eq i32* %1, null
%4 = icmp eq i32* %2, null
%5 = or i1 %3, %4
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = tail call i64 @feof(i32* %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %18, label %13
9: ; preds = %0
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%11 = load i32, i32* @EXIT_SUCCESS
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %6, %13
%14 = tail call i32 @getc(i32* %1)
%15 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 %14)
%16 = tail call i64 @feof(i32* %1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %13
18: ; preds = %13, %6
%19 = tail call i32 @putchar(i8 signext 10)
%20 = tail call i32 @rewind(i32* %1)
%21 = tail call i64 @feof(i32* %1)
%22 = icmp eq i64 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %18, %23
%24 = tail call i32 @getc(i32* %1)
%25 = tail call i32 @putc(i32 %24, i32* %2)
%26 = tail call i64 @feof(i32* %1)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %23
28: ; preds = %23, %18
%29 = tail call i32 @fclose(i32* %1)
%30 = tail call i32 @fclose(i32* %2)
ret void
}