#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*/ buf1;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int calc_string(char *);
int /*<<< orphan*/ cutereturn(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int main(void) {
  FILE *p = fopen("D:\\temp\\a.txt", "r");
  FILE *p1 = fopen("D:\\temp\\b.txt", "w");
  char buf[1024];
  char buf1[1024];
  while (!feof(p)) {
    memset(buf, 0, sizeof(buf));
    fgets(buf, sizeof(buf), p);
    cutereturn(buf);
    int value = calc_string(buf);
    memset(buf1, 0, sizeof(buf1));
    sprintf(buf1, "%s%d\n", buf, value);
    fputs(buf1, p1);
  }
  fclose(p);
  fclose(p1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe57(%rip),%rdi
lea    0xe5e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe50(%rip),%rdi
lea    0xe57(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ee <main+0x5e>
jmp    127c <main+0xec>
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1070 <fgets@plt>
lea    -0x420(%rbp),%rdi
call   1030 <cutereturn@plt>
lea    -0x420(%rbp),%rdi
call   1090 <calc_string@plt>
mov    %eax,-0x824(%rbp)
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x820(%rbp),%rdi
lea    -0x420(%rbp),%rdx
mov    -0x824(%rbp),%ecx
lea    0xdbe(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <fputs@plt>
jmp    11d0 <main+0x40>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
lea    0xe58(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r15
lea    0xe52(%rip),%rdi
lea    0xe59(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1257 <main+0xc7>
lea    0x400(%rsp),%rbx
mov    %rsp,%r12
lea    0xe35(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1030 <cutereturn@plt>
mov    %rbx,%rdi
call   1090 <calc_string@plt>
mov    %eax,%ebp
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   10b0 <sprintf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <fputs@plt>
mov    %r15,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     11f0 <main+0x60>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"D:\\temp\\a.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"D:\\temp\\b.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [6 x i8] c"%s%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
%8 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 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* %8, i32** %3
br label %9
9: ; preds = %14, %0
%10 = load i32*, i32** %2
%11 = call i32 @feof(i32* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %33
14: ; preds = %9
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%16 = call i32 @memset(i8* %15, i32 0, i32 1024)
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%18 = load i32*, i32** %2
%19 = call i32 @fgets(i8* %17, i32 1024, i32* %18)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%21 = call i32 @cutereturn(i8* %20)
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%23 = call i32 @calc_string(i8* %22)
store i32 %23, i32* %6
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%25 = call i32 @memset(i8* %24, i32 0, i32 1024)
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%28 = load i32, i32* %6
%29 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %27, i32 %28)
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%31 = load i32*, i32** %3
%32 = call i32 @fputs(i8* %30, i32* %31)
br label %9
33: ; preds = %9
%34 = load i32*, i32** %2
%35 = call i32 @fclose(i32* %34)
%36 = load i32*, i32** %3
%37 = call i32 @fclose(i32* %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"D:\\temp\\a.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"D:\\temp\\b.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [6 x i8] c"%s%d\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%7 = call i32 @feof(i32* %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %0, %9
%10 = call i32 @memset(i8* %5, i32 0, i32 1024)
%11 = call i32 @fgets(i8* %5, i32 1024, i32* %3)
%12 = call i32 @cutereturn(i8* %5)
%13 = call i32 @calc_string(i8* %5)
%14 = call i32 @memset(i8* %6, i32 0, i32 1024)
%15 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %5, i32 %13)
%16 = call i32 @fputs(i8* %6, i32* %4)
%17 = call i32 @feof(i32* %3)
%18 = icmp eq i32 %17, 0
br i1 %18, label %9, label %19
19: ; preds = %9, %0
%20 = call i32 @fclose(i32* %3)
%21 = call i32 @fclose(i32* %4)
ret i32 0
}