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

/* Variables and functions */
int getchar();
double strtod(char *, int /*<<< orphan*/ *);
double carry_in(void) {
  static char temp_buffer[64];
  register size_t i;
  for (i = 0; i < sizeof(temp_buffer); i++) {
    int character;
    temp_buffer[i] = '\0';
    character = getchar();
    if (character == '\n')
      return strtod(&temp_buffer[0], NULL);
    if (character < 0 || character > +127)
      return 0;
    temp_buffer[i] = (char)character;
  }
  return 0;
}


x86 assembly (clang, -O0):
<carry_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
cmpq   $0x40,-0x10(%rbp)
jae    11bd <carry_in+0x9d>
mov    -0x10(%rbp),%rcx
lea    0x2efa(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    1178 <carry_in+0x58>
lea    0x2edb(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11c5 <carry_in+0xa5>
cmpl   $0x0,-0x14(%rbp)
jl     118c <carry_in+0x6c>
cmpl   $0x7f,-0x14(%rbp)
jle    1199 <carry_in+0x79>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c5 <carry_in+0xa5>
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rcx
lea    0x2e97(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1130 <carry_in+0x10>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<carry_in>:
push   %r14
push   %rbx
push   %rax
lea    0x2f15(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
movb   $0x0,(%rbx,%r14,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     115f <carry_in+0x3f>
cmp    $0x7f,%eax
ja     1154 <carry_in+0x34>
mov    %al,(%rbx,%r14,1)
add    $0x1,%rbx
cmp    $0x40,%rbx
jne    1130 <carry_in+0x10>
xorps  %xmm0,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0x2eda(%rip),%rdi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strtod@plt>

LLVM IR (-O0):
@carry_in.temp_buffer = internal global [64 x i8] zeroinitializer
define double @carry_in() {
%1 = alloca double
%2 = alloca i64
%3 = alloca i32
store i64 0, i64* %2
br label %4
4: ; preds = %27, %0
%5 = load i64, i64* %2
%6 = icmp ult i64 %5, 64
br i1 %6, label %7, label %30
7: ; preds = %4
%8 = load i64, i64* %2
%9 = getelementptr inbounds [64 x i8], [64 x i8]* @carry_in.temp_buffer, i64 0, i64 %8
store i8 0, i8* %9
%10 = call i32 (...) @getchar()
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 10
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = call double @strtod(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @carry_in.temp_buffer, i64 0, i64 0), i32* null)
store double %14, double* %1
br label %31
15: ; preds = %7
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %3
%20 = icmp sgt i32 %19, 127
br i1 %20, label %21, label %22
21: ; preds = %18, %15
store double 0.000000e+00, double* %1
br label %31
22: ; preds = %18
%23 = load i32, i32* %3
%24 = trunc i32 %23 to i8
%25 = load i64, i64* %2
%26 = getelementptr inbounds [64 x i8], [64 x i8]* @carry_in.temp_buffer, i64 0, i64 %25
store i8 %24, i8* %26
br label %27
27: ; preds = %22
%28 = load i64, i64* %2
%29 = add i64 %28, 1
store i64 %29, i64* %2
br label %4
30: ; preds = %4
store double 0.000000e+00, double* %1
br label %31
31: ; preds = %30, %21, %13
%32 = load double, double* %1
ret double %32
}

LLVM IR (-O2):
@carry_in.temp_buffer = internal global [64 x i8] zeroinitializer
define double @carry_in() {
br label %1
1: ; preds = %0, %10
%2 = phi i64 [ 0, %0 ], [ %12, %10 ]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* @carry_in.temp_buffer, i64 0, i64 %2
store i8 0, i8* %3
%4 = tail call i32 (...) @getchar()
%5 = icmp eq i32 %4, 10
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call double @strtod(i8* nocapture getelementptr inbounds ([64 x i8], [64 x i8]* @carry_in.temp_buffer, i64 0, i64 0), i32* null)
br label %14
8: ; preds = %1
%9 = icmp ugt i32 %4, 127
br i1 %9, label %14, label %10
10: ; preds = %8
%11 = trunc i32 %4 to i8
store i8 %11, i8* %3
%12 = add nuw nsw i64 %2, 1
%13 = icmp eq i64 %12, 64
br i1 %13, label %14, label %1
14: ; preds = %8, %10, %6
%15 = phi double [ %7, %6 ], [ 0.000000e+00, %10 ], [ 0.000000e+00, %8 ]
ret double %15
}