#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int strtol(char *, int /*<<< orphan*/ *, int);
int main(void) {
  printf("Please enter a number: ");
  char string[256];
  int c, i = 0;
  while ((c = getchar()) != '\n' && c != EOF && i <= 255) {
    string[i++] = c;
  }
  string[i] = '\0';
  int a = strtol(string, NULL, 10);
  i = 0;
  printf("Please enter another number: ");
  while ((c = getchar()) != '\n' && c != EOF && i <= 255) {
    string[i++] = c;
  }
  string[i] = '\0';
  int b = strtol(string, NULL, 10);
  printf("%d\n", a + b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x118(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x114(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x121(%rbp)
je     11aa <main+0x7a>
mov    -0x114(%rbp),%ecx
xor    %eax,%eax
mov    0x2e5f(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x121(%rbp)
je     11aa <main+0x7a>
cmpl   $0xff,-0x118(%rbp)
setle  %al
mov    %al,-0x121(%rbp)
mov    -0x121(%rbp),%al
test   $0x1,%al
jne    11bd <main+0x8d>
jmp    11e4 <main+0xb4>
mov    -0x114(%rbp),%eax
mov    %al,%cl
mov    -0x118(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x118(%rbp)
cltq
mov    %cl,-0x110(%rbp,%rax,1)
jmp    115a <main+0x2a>
movslq -0x118(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x11c(%rbp)
movl   $0x0,-0x118(%rbp)
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x114(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x122(%rbp)
je     1276 <main+0x146>
mov    -0x114(%rbp),%ecx
xor    %eax,%eax
mov    0x2d93(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x122(%rbp)
je     1276 <main+0x146>
cmpl   $0xff,-0x118(%rbp)
setle  %al
mov    %al,-0x122(%rbp)
mov    -0x122(%rbp),%al
test   $0x1,%al
jne    1289 <main+0x159>
jmp    12b0 <main+0x180>
mov    -0x114(%rbp),%eax
mov    %al,%cl
mov    -0x118(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x118(%rbp)
cltq
mov    %cl,-0x110(%rbp,%rax,1)
jmp    1226 <main+0xf6>
movslq -0x118(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x120(%rbp)
mov    -0x11c(%rbp),%esi
add    -0x120(%rbp),%esi
lea    0xd49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
lea    0xebe(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1181 <main+0x51>
mov    0x2e8a(%rip),%rbp
xor    %ebx,%ebx
cmp    0x0(%rbp),%eax
je     1181 <main+0x51>
cmp    $0xff,%rbx
ja     1181 <main+0x51>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
jne    1160 <main+0x30>
movb   $0x0,(%rsp,%rbx,1)
xor    %ebx,%ebx
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%r14d
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     11e1 <main+0xb1>
mov    0x2e2e(%rip),%rbp
xor    %ebx,%ebx
nopl   0x0(%rax)
cmp    0x0(%rbp),%eax
je     11e1 <main+0xb1>
cmp    $0xff,%rbx
ja     11e1 <main+0xb1>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
jne    11c0 <main+0x90>
movb   $0x0,(%rsp,%rbx,1)
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
add    %eax,%r14d
lea    0xe38(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Please enter a number: \00"
@EOF = global i32 0
@.str.1 = [30 x i8] c"Please enter another number: \00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %8
8: ; preds = %20, %0
%9 = call i32 (...) @getchar()
store i32 %9, i32* %3
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load i32, i32* %3
%13 = load i32, i32* @EOF
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %4
%17 = icmp sle i32 %16, 255
br label %18
18: ; preds = %15, %11, %8
%19 = phi i1 [ false, %11 ], [ false, %8 ], [ %17, %15 ]
br i1 %19, label %20, label %27
20: ; preds = %18
%21 = load i32, i32* %3
%22 = trunc i32 %21 to i8
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %25
store i8 %22, i8* %26
br label %8
27: ; preds = %18
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %29
store i8 0, i8* %30
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%32 = call i32 @strtol(i8* %31, i32* null, i32 10)
store i32 %32, i32* %5
store i32 0, i32* %4
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %46, %27
%35 = call i32 (...) @getchar()
store i32 %35, i32* %3
%36 = icmp ne i32 %35, 10
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i32, i32* %3
%39 = load i32, i32* @EOF
%40 = icmp ne i32 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32, i32* %4
%43 = icmp sle i32 %42, 255
br label %44
44: ; preds = %41, %37, %34
%45 = phi i1 [ false, %37 ], [ false, %34 ], [ %43, %41 ]
br i1 %45, label %46, label %53
46: ; preds = %44
%47 = load i32, i32* %3
%48 = trunc i32 %47 to i8
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %4
%51 = sext i32 %49 to i64
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %51
store i8 %48, i8* %52
br label %34
53: ; preds = %44
%54 = load i32, i32* %4
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %55
store i8 0, i8* %56
%57 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%58 = call i32 @strtol(i8* %57, i32* null, i32 10)
store i32 %58, i32* %6
%59 = load i32, i32* %5
%60 = load i32, i32* %6
%61 = add nsw i32 %59, %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %61)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Please enter a number: \00"
@EOF = global i32 0
@.str.1 = [30 x i8] c"Please enter another number: \00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = tail call i32 (...) @getchar()
%5 = icmp eq i32 %4, 10
br i1 %5, label %19, label %6
6: ; preds = %0, %13
%7 = phi i64 [ %15, %13 ], [ 0, %0 ]
%8 = phi i32 [ %17, %13 ], [ %4, %0 ]
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
%11 = icmp ult i64 %7, 256
%12 = select i1 %10, i1 %11, i1 false
br i1 %12, label %13, label %19
13: ; preds = %6
%14 = trunc i32 %8 to i8
%15 = add nuw nsw i64 %7, 1
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %7
store i8 %14, i8* %16
%17 = tail call i32 (...) @getchar()
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %6
19: ; preds = %6, %13, %0
%20 = phi i64 [ 0, %0 ], [ %7, %6 ], [ %15, %13 ]
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %20
store i8 0, i8* %21
%22 = call i32 @strtol(i8* nocapture %3, i32* null, i32 10)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%24 = tail call i32 (...) @getchar()
%25 = icmp eq i32 %24, 10
br i1 %25, label %39, label %26
26: ; preds = %19, %33
%27 = phi i64 [ %35, %33 ], [ 0, %19 ]
%28 = phi i32 [ %37, %33 ], [ %24, %19 ]
%29 = load i32, i32* @EOF
%30 = icmp ne i32 %28, %29
%31 = icmp ult i64 %27, 256
%32 = select i1 %30, i1 %31, i1 false
br i1 %32, label %33, label %39
33: ; preds = %26
%34 = trunc i32 %28 to i8
%35 = add nuw nsw i64 %27, 1
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %27
store i8 %34, i8* %36
%37 = tail call i32 (...) @getchar()
%38 = icmp eq i32 %37, 10
br i1 %38, label %39, label %26
39: ; preds = %26, %33, %19
%40 = phi i64 [ 0, %19 ], [ %27, %26 ], [ %35, %33 ]
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %40
store i8 0, i8* %41
%42 = call i32 @strtol(i8* nocapture %3, i32* null, i32 10)
%43 = add nsw i32 %42, %22
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %43)
ret i32 0
}