#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, int *, int *);
int main() {
  int a, b;
  int r;
  printf("Ler arquivo (c) 2015.\n");
  FILE *entrada = fopen("dados.txt", "r");
  char linha[100];
  int i = 0;
  while (fgets(linha, 100, entrada) != NULL) {
    i++;
    r = sscanf(linha, "%i %i", &a, &b);
    if (r == 2) {
      printf("%i + %i = %i\n", a, b, a + b);
    } else {
      printf("Erro na linha: %i.\n", i);
    }
  }
  fclose(entrada);
  printf("*FIM*\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x84(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x64,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1219 <main+0xc9>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe5c(%rip),%rsi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1060 <sscanf@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x2,-0x10(%rbp)
jne    1200 <main+0xb0>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
add    -0xc(%rbp),%ecx
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1214 <main+0xc4>
mov    -0x84(%rbp),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1191 <main+0x41>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7f(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1229 <main+0xc9>
mov    $0x1,%ebp
lea    0xe55(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%r13
jmp    11f8 <main+0x98>
nopl   0x0(%rax,%rax,1)
lea    0xe49(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
je     1229 <main+0xc9>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jne    11d0 <main+0x70>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    (%rdx,%rsi,1),%ecx
lea    0xdf2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e0 <main+0x80>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xe12(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Ler arquivo (c) 2015.\0A\00"
@.str.1 = [10 x i8] c"dados.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [6 x i8] c"%i %i\00"
@.str.4 = [14 x i8] c"%i + %i = %i\0A\00"
@.str.5 = [20 x i8] c"Erro na linha: %i.\0A\00"
@.str.6 = [7 x i8] c"*FIM*\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca [100 x i8]
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%9 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %9, i32** %5
store i32 0, i32* %7
br label %10
10: ; preds = %32, %0
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%12 = load i32*, i32** %5
%13 = call i32* @fgets(i8* %11, i32 100, i32* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %33
15: ; preds = %10
%16 = load i32, i32* %7
%17 = add nsw i32 %16, 1
store i32 %17, i32* %7
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %2, i32* %3)
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %29
22: ; preds = %15
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = add nsw i32 %25, %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %23, i32 %24, i32 %27)
br label %32
29: ; preds = %15
%30 = load i32, i32* %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29, %22
br label %10
33: ; preds = %10
%34 = load i32*, i32** %5
%35 = call i32 @fclose(i32* %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"dados.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [6 x i8] c"%i %i\00"
@.str.4 = [14 x i8] c"%i + %i = %i\0A\00"
@.str.5 = [20 x i8] c"Erro na linha: %i.\0A\00"
@str = [22 x i8] c"Ler arquivo (c) 2015.\00"
@str.7 = [6 x i8] c"*FIM*\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = call i32* @fgets(i8* %8, i32 100, i32* %7)
%10 = icmp eq i32* %9, null
br i1 %10, label %26, label %11
11: ; preds = %0, %23
%12 = phi i32 [ %13, %23 ], [ 0, %0 ]
%13 = add nuw nsw i32 %12, 1
%14 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %2)
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = add nsw i32 %18, %17
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %17, i32 %18, i32 %19)
br label %23
21: ; preds = %11
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %13)
br label %23
23: ; preds = %21, %16
%24 = call i32* @fgets(i8* %8, i32 100, i32* %7)
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %11
26: ; preds = %23, %0
%27 = call i32 @fclose(i32* %7)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}