#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*/ getLine(char *, int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ stringToInt(char *);
int main() {
  char input[10];
  int i, sum = 0;
  for (i = 1; i <= 4; i++) {
    printf("Enter number #%d: ", i);
    getLine(input, 10);
    sum += stringToInt(input);
  }
  printf("The sum of the 4 values is %d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jg     1198 <main+0x68>
mov    -0x14(%rbp),%esi
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
lea    -0xe(%rbp),%rdi
mov    $0xa,%esi
call   1050 <getLine@plt>
lea    -0xe(%rbp),%rdi
call   1040 <stringToInt@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
mov    -0x18(%rbp),%esi
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%r15
mov    %r15,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
lea    0x6(%rsp),%r14
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <getLine@plt>
mov    %r14,%rdi
call   1040 <stringToInt@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <getLine@plt>
mov    %r14,%rdi
call   1040 <stringToInt@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <getLine@plt>
mov    %r14,%rdi
call   1040 <stringToInt@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <getLine@plt>
mov    %r14,%rdi
call   1040 <stringToInt@plt>
add    %eax,%ebx
lea    0xe36(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter number #%d: \00"
@.str.1 = [31 x i8] c"The sum of the 4 values is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 1, i32* %3
br label %5
5: ; preds = %19, %0
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 4
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%12 = call i32 @getLine(i8* %11, i32 10)
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%14 = call i64 @stringToInt(i8* %13)
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = add nsw i64 %16, %14
%18 = trunc i64 %17 to i32
store i32 %18, i32* %4
br label %19
19: ; preds = %8
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %5
22: ; preds = %5
%23 = load i32, i32* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter number #%d: \00"
@.str.1 = [31 x i8] c"The sum of the 4 values is %d\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 1)
%4 = call i32 @getLine(i8* %2, i32 10)
%5 = call i64 @stringToInt(i8* %2)
%6 = trunc i64 %5 to i32
%7 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 2)
%8 = call i32 @getLine(i8* %2, i32 10)
%9 = call i64 @stringToInt(i8* %2)
%10 = trunc i64 %9 to i32
%11 = add i32 %6, %10
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 3)
%13 = call i32 @getLine(i8* %2, i32 10)
%14 = call i64 @stringToInt(i8* %2)
%15 = trunc i64 %14 to i32
%16 = add i32 %11, %15
%17 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 4)
%18 = call i32 @getLine(i8* %2, i32 10)
%19 = call i64 @stringToInt(i8* %2)
%20 = trunc i64 %19 to i32
%21 = add i32 %16, %20
%22 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %21)
ret i32 0
}