#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*/ scanf(char *, int *);
int sqr_sum_line(int count) {
  if (count == 0)
    return 0;
  int i_num;
  scanf("%d", &i_num);
  if (i_num > 0)
    return sqr_sum_line(count - 1) + i_num * i_num;
  else
    return sqr_sum_line(count - 1);
}


x86 assembly (clang, -O0):
<sqr_sum_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1141 <sqr_sum_line+0x21>
movl   $0x0,-0x4(%rbp)
jmp    1185 <sqr_sum_line+0x65>
lea    0xeb8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1177 <sqr_sum_line+0x57>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1040 <sqr_sum_line@plt>
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1185 <sqr_sum_line+0x65>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1040 <sqr_sum_line@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqr_sum_line>:
test   %edi,%edi
je     1161 <sqr_sum_line+0x41>
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xed0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1030 <scanf@plt>
mov    0x4(%rsp),%ebp
add    $0xffffffff,%ebx
mov    %ebx,%edi
call   1040 <sqr_sum_line@plt>
mov    %eax,%ecx
mov    0x4(%rsp),%edx
imul   %edx,%edx
xor    %eax,%eax
test   %ebp,%ebp
cmovg  %edx,%eax
add    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @sqr_sum_line(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %24
8: ; preds = %1
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i32, i32* %3
%14 = sub nsw i32 %13, 1
%15 = call i32 @sqr_sum_line(i32 %14)
%16 = load i32, i32* %4
%17 = load i32, i32* %4
%18 = mul nsw i32 %16, %17
%19 = add nsw i32 %15, %18
store i32 %19, i32* %2
br label %24
20: ; preds = %8
%21 = load i32, i32* %3
%22 = sub nsw i32 %21, 1
%23 = call i32 @sqr_sum_line(i32 %22)
store i32 %23, i32* %2
br label %24
24: ; preds = %20, %12, %7
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @sqr_sum_line(i32 %0) {
%2 = alloca i32
%3 = icmp eq i32 %0, 0
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = bitcast i32* %2 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
%9 = add nsw i32 %0, -1
%10 = call i32 @sqr_sum_line(i32 %9)
%11 = load i32, i32* %2
%12 = mul nsw i32 %11, %11
%13 = select i1 %8, i32 %12, i32 0
%14 = add nsw i32 %10, %13
br label %15
15: ; preds = %1, %4
%16 = phi i32 [ %14, %4 ], [ 0, %1 ]
ret i32 %16
}