#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  FILE *dados;
  int a, b, s;
  s = 0;
  char nome[101];
  if (argc == 1) {
    printf("Informe o nome do arquivo: ");
    fgets(nome, 100, stdin);
    nome[strlen(nome) - 1] = '\0';
  } else {
    strcpy(nome, argv[1]);
  }
  printf("Abrindo arquivo: [%s]\n", nome);
  dados = fopen(nome, "r");
  if (dados == NULL) {
    fprintf(stderr, "Arquivo não encontrado.\n");
    return EXIT_FAILURE;
  }
  while (fscanf(dados, "%d %d", &a, &b) == 2) {
    if (a > b) {
      printf("%d\n", a);
      s = s + b;
    } else {
      printf("%d\n", b);
      s = s + a;
    }
  }
  printf("S=%d\n", s);
  fclose(dados);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11f0 <main+0x70>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2e22(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1080 <fgets@plt>
lea    -0x90(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x90(%rbp,%rax,1)
jmp    1204 <main+0x84>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x90(%rbp),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe0c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1261 <main+0xe1>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f7 <main+0x177>
jmp    1266 <main+0xe6>
mov    -0x18(%rbp),%rdi
lea    0xdde(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1070 <fscanf@plt>
cmp    $0x2,%eax
jne    12d1 <main+0x151>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    12b2 <main+0x132>
mov    -0x1c(%rbp),%esi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    12cc <main+0x14c>
mov    -0x20(%rbp),%esi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1266 <main+0xe6>
mov    -0x24(%rbp),%esi
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2cd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%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
cmp    $0x1,%edi
jne    11cd <main+0x4d>
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1080 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
jmp    11db <main+0x5b>
mov    0x8(%rsi),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xe3a(%rip),%rdi
xor    %ebx,%ebx
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe39(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     129c <main+0x11c>
mov    %rax,%r14
lea    0xe3a(%rip),%rsi
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%r12
mov    %rax,%rdi
mov    %r13,%rdx
mov    %r12,%rcx
call   1070 <fscanf@plt>
cmp    $0x2,%eax
jne    127b <main+0xfb>
lea    0xe16(%rip),%rbp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%esi
cmp    %esi,%eax
cmovg  %eax,%esi
mov    %r13,%r15
cmovg  %r12,%r15
lea    0xdfc(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    (%r15),%ebx
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
call   1070 <fscanf@plt>
cmp    $0x2,%eax
je     1240 <main+0xc0>
lea    0xdd3(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    0x2d2e(%rip),%rax
jmp    12b8 <main+0x138>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
lea    0xd89(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2d18(%rip),%rax
mov    (%rax),%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Informe o nome do arquivo: \00"
@stdin = global i32 0
@.str.1 = [23 x i8] c"Abrindo arquivo: [%s]\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [26 x i8] c"Arquivo n\C3\A3o encontrado.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [6 x i8] c"S=%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [101 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %23
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds [101 x i8], [101 x i8]* %10, i64 0, i64 0
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %15, i32 100, i32 %16)
%18 = getelementptr inbounds [101 x i8], [101 x i8]* %10, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [101 x i8], [101 x i8]* %10, i64 0, i64 %21
store i8 0, i8* %22
br label %29
23: ; preds = %2
%24 = getelementptr inbounds [101 x i8], [101 x i8]* %10, i64 0, i64 0
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @strcpy(i8* %24, i8* %27)
br label %29
29: ; preds = %23, %13
%30 = getelementptr inbounds [101 x i8], [101 x i8]* %10, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [101 x i8], [101 x i8]* %10, i64 0, i64 0
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %33, i32** %6
%34 = load i32*, i32** %6
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %40
36: ; preds = %29
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
store i32 %39, i32* %3
br label %68
40: ; preds = %29
br label %41
41: ; preds = %61, %40
%42 = load i32*, i32** %6
%43 = call i32 @fscanf(i32* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %7, i32* %8)
%44 = icmp eq i32 %43, 2
br i1 %44, label %45, label %62
45: ; preds = %41
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = icmp sgt i32 %46, %47
br i1 %48, label %49, label %55
49: ; preds = %45
%50 = load i32, i32* %7
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %9
%53 = load i32, i32* %8
%54 = add nsw i32 %52, %53
store i32 %54, i32* %9
br label %61
55: ; preds = %45
%56 = load i32, i32* %8
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %9
%59 = load i32, i32* %7
%60 = add nsw i32 %58, %59
store i32 %60, i32* %9
br label %61
61: ; preds = %55, %49
br label %41
62: ; preds = %41
%63 = load i32, i32* %9
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %63)
%65 = load i32*, i32** %6
%66 = call i32 @fclose(i32* %65)
%67 = load i32, i32* @EXIT_SUCCESS
store i32 %67, i32* %3
br label %68
68: ; preds = %62, %36
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@.str = [28 x i8] c"Informe o nome do arquivo: \00"
@stdin = global i32 0
@.str.1 = [23 x i8] c"Abrindo arquivo: [%s]\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [26 x i8] c"Arquivo n\C3\A3o encontrado.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [6 x i8] c"S=%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [101 x i8]
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 1
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %8, i32 100, i32 %12)
%14 = call i32 @strlen(i8* %8)
%15 = add nsw i32 %14, -1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 %16
store i8 0, i8* %17
br label %22
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcpy(i8* %8, i8* %20)
br label %22
22: ; preds = %18, %10
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%24 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %29, label %26
26: ; preds = %22
%27 = call i32 @fscanf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32* %4)
%28 = icmp eq i32 %27, 2
br i1 %28, label %32, label %45
29: ; preds = %22
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %49
32: ; preds = %26, %32
%33 = phi i32 [ %42, %32 ], [ 0, %26 ]
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = icmp sgt i32 %34, %35
%37 = select i1 %36, i32 %34, i32 %35
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %4
%40 = load i32, i32* %3
%41 = select i1 %36, i32 %39, i32 %40
%42 = add nsw i32 %41, %33
%43 = call i32 @fscanf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32* %4)
%44 = icmp eq i32 %43, 2
br i1 %44, label %32, label %45
45: ; preds = %32, %26
%46 = phi i32 [ 0, %26 ], [ %42, %32 ]
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %46)
%48 = call i32 @fclose(i32* %24)
br label %49
49: ; preds = %45, %29
%50 = phi i32* [ @EXIT_FAILURE, %29 ], [ @EXIT_SUCCESS, %45 ]
%51 = load i32, i32* %50
ret i32 %51
}