#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*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  int sum = 0, i = 0;
  char input[5];
  while (1) {
    scanf("%s", input);
    for (i = 0; input[i] != '\0'; i++)
      sum = sum * 10 + input[i] - '0';
    printf("input=%d\n", sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x11(%rbp),%rsi
lea    0xeb8(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movsbl -0x11(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1189 <main+0x69>
imul   $0xa,-0x8(%rbp),%eax
movslq -0xc(%rbp),%rcx
movsbl -0x11(%rbp,%rcx,1),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <main+0x34>
mov    -0x8(%rbp),%esi
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
jmp    113d <main+0x1d>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
lea    0xc(%rsp),%r13
lea    0xec5(%rip),%r14
lea    0xb(%rsp),%r15
lea    0xebc(%rip),%r12
jmp    115a <main+0x3a>
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xb(%rsp),%cl
test   %cl,%cl
je     1150 <main+0x30>
mov    %r13,%rax
movsbl %cl,%ecx
lea    (%rbx,%rbx,4),%edx
lea    (%rcx,%rdx,2),%ebx
add    $0xffffffd0,%ebx
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1170 <main+0x50>
jmp    1150 <main+0x30>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [10 x i8] c"input=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [5 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %0, %28
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
store i32 0, i32* %3
br label %8
8: ; preds = %25, %5
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %8
%16 = load i32, i32* %2
%17 = mul nsw i32 %16, 10
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = add nsw i32 %17, %22
%24 = sub nsw i32 %23, 48
store i32 %24, i32* %2
br label %25
25: ; preds = %15
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %8
28: ; preds = %8
%29 = load i32, i32* %2
%30 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %5
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [10 x i8] c"input=%d\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %20, %0
%4 = phi i32 [ 0, %0 ], [ %21, %20 ]
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 0
br i1 %7, label %20, label %8
8: ; preds = %3, %8
%9 = phi i64 [ %16, %8 ], [ 0, %3 ]
%10 = phi i8 [ %18, %8 ], [ %6, %3 ]
%11 = phi i32 [ %15, %8 ], [ %4, %3 ]
%12 = sext i8 %10 to i32
%13 = mul nsw i32 %11, 10
%14 = add i32 %13, -48
%15 = add i32 %14, %12
%16 = add nuw nsw i64 %9, 1
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %8
20: ; preds = %8, %3
%21 = phi i32 [ %4, %3 ], [ %15, %8 ]
%22 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %3
}