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

/* Variables and functions */
int /*<<< orphan*/ Readline(int, char *, int);
int /*<<< orphan*/ Writen(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int sscanf(char *, char *, long *, long *);
int /*<<< orphan*/ strlen(char *);
void str_echo(int fd) {
  long arg1, arg2;
  ssize_t n;
  char line[1024];
  for (;;) {
    if ((n = Readline(fd, line, 1024)) == 0)
      return;
    if (sscanf(line, "%ld%ld", &arg1, &arg2) == 2) {
      snprintf(line, sizeof(line), "%ld\n", arg1 + arg2);
    } else {
      snprintf(line, sizeof(line), "input error\n");
    }
    n = strlen(line);
    Writen(fd, line, n);
  }
}


x86 assembly (clang, -O0):
<str_echo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <Readline@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jne    1187 <str_echo+0x37>
add    $0x420,%rsp
pop    %rbp
ret
lea    -0x420(%rbp),%rdi
lea    0xe6b(%rip),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
jne    11d2 <str_echo+0x82>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rcx
add    -0x18(%rbp),%rcx
mov    $0x400,%esi
lea    0xe41(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    11ec <str_echo+0x9c>
lea    -0x420(%rbp),%rdi
mov    $0x400,%esi
lea    0xe27(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x420(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1070 <Writen@plt>
jmp    115e <str_echo+0xe>

x86 assembly (clang, -O2):
<str_echo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %edi,%ebp
lea    0x10(%rsp),%rsi
mov    $0x400,%edx
call   1050 <Readline@plt>
test   %eax,%eax
je     1210 <str_echo+0xc0>
lea    0xe7f(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r15
mov    %rsp,%r12
lea    0xe77(%rip),%r13
jmp    11d9 <str_echo+0x89>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <Writen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1050 <Readline@plt>
test   %eax,%eax
je     1210 <str_echo+0xc0>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
jne    11a0 <str_echo+0x50>
mov    (%rsp),%rcx
add    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    $0x400,%esi
lea    0xe00(%rip),%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
jmp    11b2 <str_echo+0x62>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%ld%ld\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
@.str.2 = [13 x i8] c"input error\0A\00"
define void @str_echo(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca [1024 x i8]
store i32 %0, i32* %2
br label %7
7: ; preds = %26, %1
%8 = load i32, i32* %2
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%10 = call i32 @Readline(i32 %8, i8* %9, i32 1024)
store i32 %10, i32* %5
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %7
ret void
13: ; preds = %7
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64* %3, i64* %4)
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%19 = load i64, i64* %3
%20 = load i64, i64* %4
%21 = add nsw i64 %19, %20
%22 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %18, i32 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %21)
br label %26
23: ; preds = %13
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%25 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %24, i32 1024, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %23, %17
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
store i32 %28, i32* %5
%29 = load i32, i32* %2
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%31 = load i32, i32* %5
%32 = call i32 @Writen(i32 %29, i8* %30, i32 %31)
br label %7
}

LLVM IR (-O2):
@.str = [7 x i8] c"%ld%ld\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
@.str.2 = [13 x i8] c"input error\0A\00"
define void @str_echo(i32 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca [1024 x i8]
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = call i32 @Readline(i32 %0, i8* %7, i32 1024)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %21, %1
ret void
11: ; preds = %1, %21
%12 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64* %2, i64* %3)
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i64, i64* %2
%16 = load i64, i64* %3
%17 = add nsw i64 %16, %15
%18 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %7, i32 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %17)
br label %21
19: ; preds = %11
%20 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %7, i32 1024, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %14
%22 = call i32 @strlen(i8* %7)
%23 = call i32 @Writen(i32 %0, i8* %7, i32 %22)
%24 = call i32 @Readline(i32 %0, i8* %7, i32 1024)
%25 = icmp eq i32 %24, 0
br i1 %25, label %10, label %11
}