#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 sum = 0, n, i, no = 0;
  for (i = 0; i < 10; i++) {
    printf("Enter A Number: ");
    scanf("%d", &n);
    if (n > 0) {
      sum += n;
      no++;
    }
    if (sum > 999)
      break;
  }
  printf("Sum of %d Positive Integers is: %d \n", no, 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,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    11ad <main+0x8d>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1188 <main+0x68>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x3e7,-0x8(%rbp)
jle    119a <main+0x7a>
jmp    11ad <main+0x8d>
jmp    119f <main+0x7f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <main+0x24>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecd(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%r12d
xor    %r15d,%r15d
test   %r12d,%r12d
setg   %r15b
mov    $0x0,%ebx
cmovg  %r12d,%ebx
cmp    $0x3e7,%ebx
ja     13b3 <main+0x293>
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe8b(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
test   %eax,%eax
cmovg  %eax,%ebp
setg   %cl
mov    %ebp,%r12d
add    %ebx,%r12d
add    %ecx,%r15d
cmp    $0x3e7,%r12d
ja     13b3 <main+0x293>
lea    0xe45(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe45(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
test   %eax,%eax
cmovle %r14d,%eax
setg   %cl
add    %eax,%r12d
add    %ecx,%r15d
cmp    $0x3e7,%r12d
ja     13b3 <main+0x293>
lea    0xe01(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe04(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
test   %eax,%eax
cmovg  %eax,%r14d
setg   %cl
add    %r14d,%r12d
add    %ecx,%r15d
cmp    $0x3e7,%r12d
ja     13b3 <main+0x293>
lea    0xdc0(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdc0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
test   %eax,%eax
cmovle %r14d,%eax
setg   %cl
add    %eax,%r12d
add    %ecx,%r15d
cmp    $0x3e7,%r12d
ja     13b3 <main+0x293>
lea    0xd7c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd7f(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
test   %eax,%eax
cmovg  %eax,%r14d
setg   %cl
add    %r14d,%r12d
add    %ecx,%r15d
cmp    $0x3e7,%r12d
ja     13b3 <main+0x293>
lea    0xd3b(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd3b(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
test   %eax,%eax
cmovle %r14d,%eax
setg   %cl
add    %eax,%r12d
add    %ecx,%r15d
cmp    $0x3e7,%r12d
ja     13b3 <main+0x293>
lea    0xcf7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xcfa(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
test   %eax,%eax
cmovg  %eax,%r14d
setg   %cl
add    %r14d,%r12d
add    %ecx,%r15d
cmp    $0x3e7,%r12d
ja     13b3 <main+0x293>
lea    0xcba(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xcba(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
test   %eax,%eax
cmovle %r14d,%eax
setg   %cl
add    %eax,%r12d
add    %ecx,%r15d
cmp    $0x3e7,%r12d
ja     13b3 <main+0x293>
lea    0xc7a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc7d(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
test   %eax,%eax
setg   %cl
cmovg  %eax,%r14d
add    %r14d,%r12d
add    %ecx,%r15d
lea    0xc5a(%rip),%rdi
mov    %r15d,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter A Number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"Sum of %d Positive Integers is: %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %5
store i32 0, i32* %4
br label %6
6: ; preds = %25, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %28
9: ; preds = %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = add nsw i32 %16, %15
store i32 %17, i32* %2
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %20
20: ; preds = %14, %9
%21 = load i32, i32* %2
%22 = icmp sgt i32 %21, 999
br i1 %22, label %23, label %24
23: ; preds = %20
br label %28
24: ; preds = %20
br label %25
25: ; preds = %24
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %6
28: ; preds = %23, %6
%29 = load i32, i32* %5
%30 = load i32, i32* %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter A Number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"Sum of %d Positive Integers is: %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = 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
%7 = select i1 %6, i32 %5, i32 0
%8 = zext i1 %6 to i32
%9 = icmp ugt i32 %7, 999
br i1 %9, label %99, label %10
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
%15 = select i1 %14, i32 %13, i32 0
%16 = add nuw nsw i32 %15, %7
%17 = zext i1 %14 to i32
%18 = add nuw nsw i32 %8, %17
%19 = icmp ugt i32 %16, 999
br i1 %19, label %99, label %20
20: ; preds = %10
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%23 = load i32, i32* %1
%24 = icmp sgt i32 %23, 0
%25 = select i1 %24, i32 %23, i32 0
%26 = add nuw nsw i32 %25, %16
%27 = zext i1 %24 to i32
%28 = add nuw nsw i32 %18, %27
%29 = icmp ugt i32 %26, 999
br i1 %29, label %99, label %30
30: ; preds = %20
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%33 = load i32, i32* %1
%34 = icmp sgt i32 %33, 0
%35 = select i1 %34, i32 %33, i32 0
%36 = add nuw nsw i32 %35, %26
%37 = zext i1 %34 to i32
%38 = add nuw nsw i32 %28, %37
%39 = icmp ugt i32 %36, 999
br i1 %39, label %99, label %40
40: ; preds = %30
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%42 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%43 = load i32, i32* %1
%44 = icmp sgt i32 %43, 0
%45 = select i1 %44, i32 %43, i32 0
%46 = add nuw nsw i32 %45, %36
%47 = zext i1 %44 to i32
%48 = add nuw nsw i32 %38, %47
%49 = icmp ugt i32 %46, 999
br i1 %49, label %99, label %50
50: ; preds = %40
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%52 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%53 = load i32, i32* %1
%54 = icmp sgt i32 %53, 0
%55 = select i1 %54, i32 %53, i32 0
%56 = add nuw nsw i32 %55, %46
%57 = zext i1 %54 to i32
%58 = add nuw nsw i32 %48, %57
%59 = icmp ugt i32 %56, 999
br i1 %59, label %99, label %60
60: ; preds = %50
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%62 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%63 = load i32, i32* %1
%64 = icmp sgt i32 %63, 0
%65 = select i1 %64, i32 %63, i32 0
%66 = add nuw nsw i32 %65, %56
%67 = zext i1 %64 to i32
%68 = add nuw nsw i32 %58, %67
%69 = icmp ugt i32 %66, 999
br i1 %69, label %99, label %70
70: ; preds = %60
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%72 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%73 = load i32, i32* %1
%74 = icmp sgt i32 %73, 0
%75 = select i1 %74, i32 %73, i32 0
%76 = add nuw nsw i32 %75, %66
%77 = zext i1 %74 to i32
%78 = add nuw nsw i32 %68, %77
%79 = icmp ugt i32 %76, 999
br i1 %79, label %99, label %80
80: ; preds = %70
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%82 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%83 = load i32, i32* %1
%84 = icmp sgt i32 %83, 0
%85 = select i1 %84, i32 %83, i32 0
%86 = add nuw nsw i32 %85, %76
%87 = zext i1 %84 to i32
%88 = add nuw nsw i32 %78, %87
%89 = icmp ugt i32 %86, 999
br i1 %89, label %99, label %90
90: ; preds = %80
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%92 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%93 = load i32, i32* %1
%94 = icmp sgt i32 %93, 0
%95 = select i1 %94, i32 %93, i32 0
%96 = add nuw nsw i32 %95, %86
%97 = zext i1 %94 to i32
%98 = add nuw nsw i32 %88, %97
br label %99
99: ; preds = %90, %80, %70, %60, %50, %40, %30, %20, %10, %0
%100 = phi i32 [ %5, %0 ], [ %16, %10 ], [ %26, %20 ], [ %36, %30 ], [ %46, %40 ], [ %56, %50 ], [ %66, %60 ], [ %76, %70 ], [ %86, %80 ], [ %96, %90 ]
%101 = phi i32 [ %8, %0 ], [ %18, %10 ], [ %28, %20 ], [ %38, %30 ], [ %48, %40 ], [ %58, %50 ], [ %68, %60 ], [ %78, %70 ], [ %88, %80 ], [ %98, %90 ]
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %101, i32 %100)
ret i32 0
}