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

/* Variables and functions */
int EXIT_FAILURE;
unsigned int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *file1 = NULL;
  FILE *file2 = NULL;
  char *line = NULL;
  size_t len = 0;
  unsigned int sum1, sum2;
  unsigned int n;
  ssize_t numc;
  if (argc != 3) {
    fprintf(stderr, "usage: %s <file1> <file2>\n", argv[0]);
    exit(1);
  }
  file1 = fopen(argv[1], "r");
  if (NULL == file1) {
    perror("open file1");
    exit(EXIT_FAILURE);
  }
  file2 = fopen(argv[2], "r");
  if (NULL == file2) {
    perror("open file2");
    exit(EXIT_FAILURE);
  }
  sum1 = 0;
  while (1) {
    numc = getline(&line, &len, file1);
    if (-1 == numc)
      break;
    if (line[numc - 1] == '\n') {
      line[numc - 1] = '\0';
    }
    n = atoi(line);
    sum1 += n;
  }
  sum2 = 0;
  while (1) {
    numc = getline(&line, &len, file2);
    if (-1 == numc)
      break;
    if (line[numc - 1] == '\n') {
      line[numc - 1] = '\0';
    }
    n = atoi(line);
    sum2 += n;
  }
  if (NULL != line) {
    free(line);
  }
  n = (sum2 > sum1) ? sum2 - sum1 : sum1 - sum2;
  printf("%i\n", n);
  fclose(file1);
  fclose(file2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11f6 <main+0x66>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe19(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe16(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1234 <main+0xa4>
lea    0xdfc(%rip),%rdi
call   1080 <perror@plt>
mov    0x2dab(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdd8(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    1272 <main+0xe2>
lea    0xdc9(%rip),%rdi
call   1080 <perror@plt>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10a0 <getline@plt>
mov    %eax,-0x40(%rbp)
mov    $0xffffffff,%eax
cmp    -0x40(%rbp),%eax
jne    12a0 <main+0x110>
jmp    12e5 <main+0x155>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    12cb <main+0x13b>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1279 <main+0xe9>
movl   $0x0,-0x38(%rbp)
mov    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10a0 <getline@plt>
mov    %eax,-0x40(%rbp)
mov    $0xffffffff,%eax
cmp    -0x40(%rbp),%eax
jne    1313 <main+0x183>
jmp    1358 <main+0x1c8>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    133e <main+0x1ae>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    12ec <main+0x15c>
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
je     136d <main+0x1dd>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jbe    1387 <main+0x1f7>
mov    -0x38(%rbp),%eax
sub    -0x34(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    1390 <main+0x200>
mov    -0x34(%rbp),%eax
sub    -0x38(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
lea    0xc93(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
cmp    $0x3,%edi
jne    12fd <main+0x16d>
mov    0x8(%rbx),%rdi
lea    0xe54(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     131f <main+0x18f>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe38(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1328 <main+0x198>
mov    %rax,%r15
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %r14,%rdx
call   10a0 <getline@plt>
xor    %ebx,%ebx
mov    $0x0,%ebp
cmp    $0xffffffff,%eax
je     1254 <main+0xc4>
xor    %ebp,%ebp
lea    0x8(%rsp),%r12
lea    0x10(%rsp),%r13
jmp    123a <main+0xaa>
call   1090 <atoi@plt>
add    %eax,%ebp
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   10a0 <getline@plt>
cmp    $0xffffffff,%eax
je     1254 <main+0xc4>
mov    0x8(%rsp),%rdi
cltq
cmpb   $0xa,-0x1(%rax,%rdi,1)
jne    1220 <main+0x90>
movb   $0x0,-0x1(%rdi,%rax,1)
mov    0x8(%rsp),%rdi
jmp    1220 <main+0x90>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %r15,%rdx
call   10a0 <getline@plt>
cmp    $0xffffffff,%eax
je     12b4 <main+0x124>
xor    %ebx,%ebx
lea    0x8(%rsp),%r12
lea    0x10(%rsp),%r13
jmp    129a <main+0x10a>
nopl   0x0(%rax)
call   1090 <atoi@plt>
add    %eax,%ebx
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   10a0 <getline@plt>
cmp    $0xffffffff,%eax
je     12b4 <main+0x124>
mov    0x8(%rsp),%rdi
cltq
cmpb   $0xa,-0x1(%rax,%rdi,1)
jne    1280 <main+0xf0>
movb   $0x0,-0x1(%rdi,%rax,1)
mov    0x8(%rsp),%rdi
jmp    1280 <main+0xf0>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     12c3 <main+0x133>
call   1030 <free@plt>
mov    %ebp,%eax
sub    %ebx,%eax
neg    %eax
sub    %ebx,%ebp
cmovb  %eax,%ebp
lea    0xd5e(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xcf0(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xcf7(%rip),%rdi
jmp    132f <main+0x19f>
lea    0xcf9(%rip),%rdi
call   1080 <perror@plt>
mov    0x2c9d(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"usage: %s <file1> <file2>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"open file1\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [11 x i8] c"open file2\00"
@.str.4 = [4 x i8] c"%i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
store i8* null, i8** %8
store i64 0, i64* %9
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %6
%28 = load i32*, i32** %6
%29 = icmp eq i32* null, %28
br i1 %29, label %30, label %34
30: ; preds = %23
%31 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %23
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %38, i32** %7
%39 = load i32*, i32** %7
%40 = icmp eq i32* null, %39
br i1 %40, label %41, label %45
41: ; preds = %34
%42 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %34
store i32 0, i32* %10
br label %46
46: ; preds = %45, %67
%47 = load i32*, i32** %6
%48 = call i32 @getline(i8** %8, i64* %9, i32* %47)
store i32 %48, i32* %13
%49 = load i32, i32* %13
%50 = icmp eq i32 -1, %49
br i1 %50, label %51, label %52
51: ; preds = %46
br label %73
52: ; preds = %46
%53 = load i8*, i8** %8
%54 = load i32, i32* %13
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %53, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 10
br i1 %60, label %61, label %67
61: ; preds = %52
%62 = load i8*, i8** %8
%63 = load i32, i32* %13
%64 = sub nsw i32 %63, 1
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %62, i64 %65
store i8 0, i8* %66
br label %67
67: ; preds = %61, %52
%68 = load i8*, i8** %8
%69 = call i32 @atoi(i8* %68)
store i32 %69, i32* %12
%70 = load i32, i32* %12
%71 = load i32, i32* %10
%72 = add i32 %71, %70
store i32 %72, i32* %10
br label %46
73: ; preds = %51
store i32 0, i32* %11
br label %74
74: ; preds = %73, %95
%75 = load i32*, i32** %7
%76 = call i32 @getline(i8** %8, i64* %9, i32* %75)
store i32 %76, i32* %13
%77 = load i32, i32* %13
%78 = icmp eq i32 -1, %77
br i1 %78, label %79, label %80
79: ; preds = %74
br label %101
80: ; preds = %74
%81 = load i8*, i8** %8
%82 = load i32, i32* %13
%83 = sub nsw i32 %82, 1
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %81, i64 %84
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp eq i32 %87, 10
br i1 %88, label %89, label %95
89: ; preds = %80
%90 = load i8*, i8** %8
%91 = load i32, i32* %13
%92 = sub nsw i32 %91, 1
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %90, i64 %93
store i8 0, i8* %94
br label %95
95: ; preds = %89, %80
%96 = load i8*, i8** %8
%97 = call i32 @atoi(i8* %96)
store i32 %97, i32* %12
%98 = load i32, i32* %12
%99 = load i32, i32* %11
%100 = add i32 %99, %98
store i32 %100, i32* %11
br label %74
101: ; preds = %79
%102 = load i8*, i8** %8
%103 = icmp ne i8* null, %102
br i1 %103, label %104, label %107
104: ; preds = %101
%105 = load i8*, i8** %8
%106 = call i32 @free(i8* %105)
br label %107
107: ; preds = %104, %101
%108 = load i32, i32* %11
%109 = load i32, i32* %10
%110 = icmp ugt i32 %108, %109
br i1 %110, label %111, label %115
111: ; preds = %107
%112 = load i32, i32* %11
%113 = load i32, i32* %10
%114 = sub i32 %112, %113
br label %119
115: ; preds = %107
%116 = load i32, i32* %10
%117 = load i32, i32* %11
%118 = sub i32 %116, %117
br label %119
119: ; preds = %115, %111
%120 = phi i32 [ %114, %111 ], [ %118, %115 ]
store i32 %120, i32* %12
%121 = load i32, i32* %12
%122 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %121)
%123 = load i32*, i32** %6
%124 = call i32 @fclose(i32* %123)
%125 = load i32*, i32** %7
%126 = call i32 @fclose(i32* %125)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"usage: %s <file1> <file2>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"open file1\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [11 x i8] c"open file2\00"
@.str.4 = [4 x i8] c"%i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = icmp eq i32 %0, 3
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %13
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %30, label %27
27: ; preds = %22
%28 = call i32 @getline(i8** %3, i64* %4, i32* %16)
%29 = icmp eq i32 %28, -1
br i1 %29, label %34, label %38
30: ; preds = %22
%31 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = tail call i32 @exit(i32 %32)
unreachable
34: ; preds = %49, %27
%35 = phi i32 [ 0, %27 ], [ %52, %49 ]
%36 = call i32 @getline(i8** %3, i64* %4, i32* %25)
%37 = icmp eq i32 %36, -1
br i1 %37, label %72, label %55
38: ; preds = %27, %49
%39 = phi i32 [ %53, %49 ], [ %28, %27 ]
%40 = phi i32 [ %52, %49 ], [ 0, %27 ]
%41 = load i8*, i8** %3
%42 = add nsw i32 %39, -1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 10
br i1 %46, label %47, label %49
47: ; preds = %38
store i8 0, i8* %44
%48 = load i8*, i8** %3
br label %49
49: ; preds = %47, %38
%50 = phi i8* [ %48, %47 ], [ %41, %38 ]
%51 = call i32 @atoi(i8* %50)
%52 = add i32 %51, %40
%53 = call i32 @getline(i8** %3, i64* %4, i32* %16)
%54 = icmp eq i32 %53, -1
br i1 %54, label %34, label %38
55: ; preds = %34, %66
%56 = phi i32 [ %70, %66 ], [ %36, %34 ]
%57 = phi i32 [ %69, %66 ], [ 0, %34 ]
%58 = load i8*, i8** %3
%59 = add nsw i32 %56, -1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = load i8, i8* %61
%63 = icmp eq i8 %62, 10
br i1 %63, label %64, label %66
64: ; preds = %55
store i8 0, i8* %61
%65 = load i8*, i8** %3
br label %66
66: ; preds = %64, %55
%67 = phi i8* [ %65, %64 ], [ %58, %55 ]
%68 = call i32 @atoi(i8* %67)
%69 = add i32 %68, %57
%70 = call i32 @getline(i8** %3, i64* %4, i32* %25)
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %55
72: ; preds = %66, %34
%73 = phi i32 [ 0, %34 ], [ %69, %66 ]
%74 = load i8*, i8** %3
%75 = icmp eq i8* %74, null
br i1 %75, label %78, label %76
76: ; preds = %72
%77 = call i32 @free(i8* %74)
br label %78
78: ; preds = %76, %72
%79 = icmp ugt i32 %73, %35
%80 = sub i32 %73, %35
%81 = sub i32 %35, %73
%82 = select i1 %79, i32 %80, i32 %81
%83 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %82)
%84 = call i32 @fclose(i32* %16)
%85 = call i32 @fclose(i32* %25)
ret i32 0
}