#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*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, int, int, int);
int main() {
  FILE *fp_in, *fp_out;
  char *input_file = "in.txt";
  char *output_file = "out.txt";
  int num1, num2, sum;
  fp_in = fopen(input_file, "r");
  fp_out = fopen(output_file, "w");
  fscanf(fp_in, "%d", &num1);
  fscanf(fp_in, "%d", &num2);
  sum = num1 + num2;
  printf("%d %d %d\n", num1, num2, sum);
  fprintf(fp_out, "%d\n", sum);
  fclose(fp_in);
  fclose(fp_out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe96(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe6b(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe57(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xe2b(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xea2(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe93(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
lea    0xe89(%rip),%r15
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <fscanf@plt>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <fscanf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    (%rdx,%rsi,1),%ebp
lea    0xe5d(%rip),%rdi
mov    %ebp,%ecx
call   1040 <printf@plt>
lea    0xe55(%rip),%rsi
mov    %r14,%rdi
mov    %ebp,%edx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"in.txt\00"
@.str.1 = [8 x i8] c"out.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [10 x i8] c"%d %d %d\0A\00"
@.str.6 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %5
%9 = load i8*, i8** %4
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %10, i32** %2
%11 = load i8*, i8** %5
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %12, i32** %3
%13 = load i32*, i32** %2
%14 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%15 = load i32*, i32** %2
%16 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %7)
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = add nsw i32 %17, %18
store i32 %19, i32* %8
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %20, i32 %21, i32 %22)
%24 = load i32*, i32** %3
%25 = load i32, i32* %8
%26 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %25)
%27 = load i32*, i32** %2
%28 = call i32 @fclose(i32* %27)
%29 = load i32*, i32** %3
%30 = call i32 @fclose(i32* %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"in.txt\00"
@.str.1 = [8 x i8] c"out.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [10 x i8] c"%d %d %d\0A\00"
@.str.6 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%8 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = add nsw i32 %10, %9
%12 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %9, i32 %10, i32 %11)
%13 = call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %11)
%14 = call i32 @fclose(i32* %5)
%15 = call i32 @fclose(i32* %6)
ret i32 0
}