#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int number, final, sum;
  int even(int n);
  printf("Input integers: ");
  scanf("%d", &number);
  sum = 0;
  while (number > 0) {
    final = even(number);
    if (final == 0)
      sum = sum + number;
    scanf("%d", &number);
  }
  printf("The sum of the odd numbers is %d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11a1 <main+0x71>
mov    -0x8(%rbp),%edi
call   1040 <even@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    118c <main+0x5c>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    0xe7e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
jmp    1164 <main+0x34>
mov    -0x10(%rbp),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jle    11a9 <main+0x79>
xor    %ebx,%ebx
lea    0xea6(%rip),%r14
lea    0xc(%rsp),%r15
jmp    1195 <main+0x65>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %ecx,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jle    11a9 <main+0x79>
call   1040 <even@plt>
mov    $0x0,%ecx
test   %eax,%eax
jne    1180 <main+0x50>
mov    0xc(%rsp),%ecx
jmp    1180 <main+0x50>
lea    0xe64(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Input integers: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"The sum of the odd numbers is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %4
br label %7
7: ; preds = %19, %0
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load i32, i32* %2
%12 = call i32 @even(i32 %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = add nsw i32 %16, %17
store i32 %18, i32* %4
br label %19
19: ; preds = %15, %10
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %7
21: ; preds = %7
%22 = load i32, i32* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Input integers: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"The sum of the odd numbers is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %0, %7
%8 = phi i32 [ %16, %7 ], [ %5, %0 ]
%9 = phi i32 [ %14, %7 ], [ 0, %0 ]
%10 = call i32 @even(i32 %8)
%11 = icmp eq i32 %10, 0
%12 = load i32, i32* %1
%13 = select i1 %11, i32 %12, i32 0
%14 = add nsw i32 %13, %9
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = icmp sgt i32 %16, 0
br i1 %17, label %7, label %18
18: ; preds = %7, %0
%19 = phi i32 [ 0, %0 ], [ %14, %7 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %19)
ret i32 0
}