#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 */

/* Variables and functions */
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int write(int /*<<< orphan*/, char *, int);
int main(void) {
  int n, int1, int2;
  char line[4096];
  while ((n = read(STDIN_FILENO, line, 4096)) > 0) {
    line[n] = 0;
    if (sscanf(line, "%d%d", &int1, &int2) == 2) {
      sprintf(line, "%d\n", int1 + int2);
      n = strlen(line);
      if (write(STDOUT_FILENO, line, n) != n) {
        fprintf(stderr, "write error");
        exit(1);
      }
    } else {
      if (write(STDOUT_FILENO, "invalid args\n", 13) != 13) {
        fprintf(stderr, "write error");
        exit(1);
      }
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    -0x1010(%rbp),%rsi
mov    $0x1000,%edx
call   1050 <read@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1291 <main+0x121>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x1010(%rbp,%rax,1)
lea    -0x1010(%rbp),%rdi
lea    0xe3e(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jne    1245 <main+0xd5>
lea    -0x1010(%rbp),%rdi
mov    -0xc(%rbp),%edx
add    -0x10(%rbp),%edx
lea    0xe19(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x1010(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x8(%rbp)
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
lea    -0x1010(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1030 <write@plt>
cmp    -0x8(%rbp),%eax
je     1240 <main+0xd0>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    128c <main+0x11c>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
lea    0xdc0(%rip),%rsi
mov    $0xd,%edx
call   1030 <write@plt>
cmp    $0xd,%eax
je     1287 <main+0x117>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
lea    0xd91(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    128c <main+0x11c>
jmp    1182 <main+0x12>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    0x2e48(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0x10(%rsp),%rsi
mov    $0x1000,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    1270 <main+0x100>
lea    0xe57(%rip),%rbx
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%r14
jmp    11f3 <main+0x83>
nopw   0x0(%rax,%rax,1)
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
mov    $0xd,%edx
call   1030 <write@plt>
cmp    $0xd,%eax
jne    1251 <main+0xe1>
mov    0x0(%rbp),%edi
mov    %r15,%rsi
mov    $0x1000,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    1270 <main+0x100>
mov    %eax,%eax
movb   $0x0,0x10(%rsp,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jne    11c0 <main+0x50>
mov    0x8(%rsp),%edx
add    0xc(%rsp),%edx
mov    %r15,%rdi
lea    0xde3(%rip),%rsi
call   1080 <sprintf@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r13,%r12
mov    %eax,%r13d
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
mov    %r15,%rsi
mov    %r13d,%edx
call   1030 <write@plt>
cmp    %r13d,%eax
mov    %r12,%r13
je     11df <main+0x6f>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
lea    0xda8(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@STDOUT_FILENO = global i32 0
@stderr = global i32 0
@.str.2 = [12 x i8] c"write error\00"
@.str.3 = [14 x i8] c"invalid args\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4096 x i8]
store i32 0, i32* %1
br label %6
6: ; preds = %46, %0
%7 = load i32, i32* @STDIN_FILENO
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%9 = call i32 @read(i32 %7, i8* %8, i32 4096)
store i32 %9, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %47
11: ; preds = %6
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 %13
store i8 0, i8* %14
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %37
18: ; preds = %11
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = add nsw i32 %20, %21
%23 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
store i32 %25, i32* %2
%26 = load i32, i32* @STDOUT_FILENO
%27 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%28 = load i32, i32* %2
%29 = call i32 @write(i32 %26, i8* %27, i32 %28)
%30 = load i32, i32* %2
%31 = icmp ne i32 %29, %30
br i1 %31, label %32, label %36
32: ; preds = %18
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %18
br label %46
37: ; preds = %11
%38 = load i32, i32* @STDOUT_FILENO
%39 = call i32 @write(i32 %38, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 13)
%40 = icmp ne i32 %39, 13
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %37
br label %46
46: ; preds = %45, %36
br label %6
47: ; preds = %6
%48 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@STDOUT_FILENO = global i32 0
@stderr = global i32 0
@.str.2 = [12 x i8] c"write error\00"
@.str.3 = [14 x i8] c"invalid args\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4096 x i8]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* @STDIN_FILENO
%8 = call i32 @read(i32 %7, i8* %6, i32 4096)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %41
10: ; preds = %0, %37
%11 = phi i32 [ %39, %37 ], [ %8, %0 ]
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %12
store i8 0, i8* %13
%14 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %29
16: ; preds = %10
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = add nsw i32 %18, %17
%20 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = call i32 @strlen(i8* %6)
%22 = load i32, i32* @STDOUT_FILENO
%23 = call i32 @write(i32 %22, i8* %6, i32 %21)
%24 = icmp eq i32 %23, %21
br i1 %24, label %37, label %25
25: ; preds = %16
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %10
%30 = load i32, i32* @STDOUT_FILENO
%31 = call i32 @write(i32 %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 13)
%32 = icmp eq i32 %31, 13
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %29, %16
%38 = load i32, i32* @STDIN_FILENO
%39 = call i32 @read(i32 %38, i8* %6, i32 4096)
%40 = icmp sgt i32 %39, 0
br i1 %40, label %10, label %41
41: ; preds = %37, %0
%42 = call i32 @exit(i32 0)
unreachable
}