#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
char *strerror(int /*<<< orphan*/);
int strlen(char *);
int write(int /*<<< orphan*/, char *, int);
int main(void) {
  int n, num1, num2;
  char buf[1024];
  while ((n = read(stdin, buf, 1024)) > 0) {
    buf[n] = 0;
    if (sscanf(buf, "%d%d", &num1, &num2) == 2) {
      sprintf(buf, "%d\n", num1 + num2);
      n = strlen(buf);
      if (write(stdout, buf, n) != n) {
        fprintf(stderr, "Err. write() - %s\n", strerror(errno));
        exit(EXIT_FAILURE);
      }
    } else {
      if (write(stdout, "invalid args\n", 13) != 13) {
        fprintf(stderr, "Err. write() - %s\n", strerror(errno));
        exit(EXIT_FAILURE);
      }
    }
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1050 <read@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    12e3 <main+0x163>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rdi
lea    0xe2e(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jne    1276 <main+0xf6>
lea    -0x410(%rbp),%rdi
mov    -0xc(%rbp),%edx
add    -0x10(%rbp),%edx
lea    0xe09(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x8(%rbp)
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1030 <write@plt>
cmp    -0x8(%rbp),%eax
je     1271 <main+0xf1>
mov    0x2da0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x414(%rbp)
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x414(%rbp),%edi
mov    %rax,%rdx
lea    0xdab(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    12de <main+0x15e>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
lea    0xd96(%rip),%rsi
mov    $0xd,%edx
call   1030 <write@plt>
cmp    $0xd,%eax
je     12d9 <main+0x159>
mov    0x2d38(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x418(%rbp)
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x418(%rbp),%edi
mov    %rax,%rdx
lea    0xd43(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2cf6(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    12de <main+0x15e>
jmp    1192 <main+0x12>
mov    0x2cce(%rip),%rax
mov    (%rax),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    0x2e50(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0x10(%rsp),%rsi
mov    $0x400,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    129b <main+0x11b>
lea    0xe47(%rip),%rbx
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%r14
jmp    1207 <main+0x87>
nopw   0x0(%rax,%rax,1)
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
mov    $0xd,%edx
call   1030 <write@plt>
cmp    $0xd,%eax
jne    1265 <main+0xe5>
mov    0x0(%rbp),%edi
mov    %r15,%rsi
mov    $0x400,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    129b <main+0x11b>
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    11d0 <main+0x50>
mov    0x8(%rsp),%edx
add    0xc(%rsp),%edx
mov    %r15,%rdi
lea    0xdcf(%rip),%rsi
call   1080 <sprintf@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r13,%r12
mov    %eax,%r13d
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
mov    %r15,%rsi
mov    %r13d,%edx
call   1030 <write@plt>
cmp    %r13d,%eax
mov    %r12,%r13
je     11ef <main+0x6f>
mov    0x2d6c(%rip),%rax
mov    (%rax),%ebx
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd86(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2d16(%rip),%rax
mov    (%rax),%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@stdout = global i32 0
@stderr = global i32 0
@.str.2 = [19 x i8] c"Err. write() - %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.3 = [14 x i8] c"invalid args\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1024 x i8]
store i32 0, i32* %1
br label %6
6: ; preds = %52, %0
%7 = load i32, i32* @stdin
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = call i32 @read(i32 %7, i8* %8, i32 1024)
store i32 %9, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %53
11: ; preds = %6
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %13
store i8 0, i8* %14
%15 = getelementptr inbounds [1024 x i8], [1024 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 %40
18: ; preds = %11
%19 = getelementptr inbounds [1024 x i8], [1024 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 [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
store i32 %25, i32* %2
%26 = load i32, i32* @stdout
%27 = getelementptr inbounds [1024 x i8], [1024 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 %39
32: ; preds = %18
%33 = load i32, i32* @stderr
%34 = load i32, i32* @errno
%35 = call i8* @strerror(i32 %34)
%36 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %18
br label %52
40: ; preds = %11
%41 = load i32, i32* @stdout
%42 = call i32 @write(i32 %41, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 13)
%43 = icmp ne i32 %42, 13
br i1 %43, label %44, label %51
44: ; preds = %40
%45 = load i32, i32* @stderr
%46 = load i32, i32* @errno
%47 = call i8* @strerror(i32 %46)
%48 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = load i32, i32* @EXIT_FAILURE
%50 = call i32 @exit(i32 %49)
unreachable
51: ; preds = %40
br label %52
52: ; preds = %51, %39
br label %6
53: ; preds = %6
%54 = load i32, i32* @EXIT_SUCCESS
ret i32 %54
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@stdout = global i32 0
@stderr = global i32 0
@.str.2 = [19 x i8] c"Err. write() - %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.3 = [14 x i8] c"invalid args\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @read(i32 %7, i8* %6, i32 1024)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %47
10: ; preds = %0, %43
%11 = phi i32 [ %45, %43 ], [ %8, %0 ]
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [1024 x i8], [1024 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 %32
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
%23 = call i32 @write(i32 %22, i8* %6, i32 %21)
%24 = icmp eq i32 %23, %21
br i1 %24, label %43, label %25
25: ; preds = %16
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %10
%33 = load i32, i32* @stdout
%34 = call i32 @write(i32 %33, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 13)
%35 = icmp eq i32 %34, 13
br i1 %35, label %43, label %36
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %32, %16
%44 = load i32, i32* @stdin
%45 = call i32 @read(i32 %44, i8* %6, i32 1024)
%46 = icmp sgt i32 %45, 0
br i1 %46, label %10, label %47
47: ; preds = %43, %0
%48 = load i32, i32* @EXIT_SUCCESS
ret i32 %48
}