#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*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, int *);
int /*<<< orphan*/ printf(char *, int, int);
int main01(void) {
  FILE *p = fopen("D:\\temp\\a.txt", "r");
  while (!feof(p)) {
    char buf[100] = {0};
    int a = 0;
    int b = 0;
    fscanf(p, "%d + %d =", &a, &b);
    printf("a = %d, b = %d\n", a, b);
  }
  fclose(p);
  return 0;
}


x86 assembly (clang, -O0):
<main01>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    0xe8e(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11a0 <main01+0x40>
jmp    11ed <main01+0x8d>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe47(%rip),%rsi
lea    -0x74(%rbp),%rdx
lea    -0x78(%rbp),%rcx
call   1060 <fscanf@plt>
mov    -0x74(%rbp),%esi
mov    -0x78(%rbp),%edx
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
jmp    1182 <main01+0x22>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main01>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9c(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11dd <main01+0x8d>
lea    0xe8a(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0xe83(%rip),%r13
nopw   0x0(%rax,%rax,1)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1050 <fscanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r13,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11a0 <main01+0x50>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"D:\\temp\\a.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"%d + %d =\00"
@.str.3 = [16 x i8] c"a = %d, b = %d\0A\00"
define i32 @main01() {
%1 = alloca i32*
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = 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* %5, i32** %1
br label %6
6: ; preds = %11, %0
%7 = load i32*, i32** %1
%8 = call i32 @feof(i32* %7)
%9 = icmp ne i32 %8, 0
%10 = xor i1 %9, true
br i1 %10, label %11, label %18
11: ; preds = %6
%12 = bitcast [100 x i8]* %2 to i8*
store i32 0, i32* %3
store i32 0, i32* %4
%13 = load i32*, i32** %1
%14 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32* %3, i32* %4)
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %16)
br label %6
18: ; preds = %6
%19 = load i32*, i32** %1
%20 = call i32 @fclose(i32* %19)
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 = [10 x i8] c"%d + %d =\00"
@.str.3 = [16 x i8] c"a = %d, b = %d\0A\00"
define i32 @main01() {
%1 = alloca i32
%2 = alloca i32
%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 = call i32 @feof(i32* %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %0
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
br label %9
9: ; preds = %6, %9
store i32 0, i32* %1
store i32 0, i32* %2
%10 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32 %12)
%14 = call i32 @feof(i32* %3)
%15 = icmp eq i32 %14, 0
br i1 %15, label %9, label %16
16: ; preds = %9, %0
%17 = call i32 @fclose(i32* %3)
ret i32 0
}