#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 c_n = 0, c_p = 0, n;
  printf("Enter a Number (0 to quit) \n");
  scanf("%d", &n);
  while (n) {
    if (n > 0)
      c_p++;
    else
      c_n++;
    scanf("%d", &n);
  }
  printf("The Number of Positve terms are: %d \n", c_p);
  printf("The Number of Negative terms are: %d \n", c_n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
je     119b <main+0x7b>
cmpl   $0x0,-0x10(%rbp)
jle    117d <main+0x5d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1186 <main+0x66>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    0xe90(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
jmp    115b <main+0x3b>
mov    -0xc(%rbp),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xf12(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     1195 <main+0x65>
xor    %ebp,%ebp
lea    0xe9b(%rip),%r14
lea    0x4(%rsp),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %ecx,%ecx
xor    %edx,%edx
test   %eax,%eax
setg   %cl
setle  %dl
add    %edx,%ebx
add    %ecx,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jne    1170 <main+0x40>
jmp    1199 <main+0x69>
xor    %ebx,%ebx
xor    %ebp,%ebp
lea    0xe63(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe79(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Enter a Number (0 to quit) \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"The Number of Positve terms are: %d \0A\00"
@.str.3 = [39 x i8] c"The Number of Negative terms are: %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 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* %4)
br label %7
7: ; preds = %19, %0
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %19
16: ; preds = %10
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %19
19: ; preds = %16, %13
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %7
21: ; preds = %7
%22 = load i32, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"The Number of Positve terms are: %d \0A\00"
@.str.3 = [39 x i8] c"The Number of Negative terms are: %d \0A\00"
@str = [28 x i8] c"Enter a Number (0 to quit) \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 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 eq i32 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %18, %7 ], [ %5, %0 ]
%9 = phi i32 [ %16, %7 ], [ 0, %0 ]
%10 = phi i32 [ %14, %7 ], [ 0, %0 ]
%11 = icmp sgt i32 %8, 0
%12 = xor i1 %11, true
%13 = zext i1 %12 to i32
%14 = add nuw nsw i32 %10, %13
%15 = zext i1 %11 to i32
%16 = add nuw nsw i32 %9, %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %7
20: ; preds = %7, %0
%21 = phi i32 [ 0, %0 ], [ %14, %7 ]
%22 = phi i32 [ 0, %0 ], [ %16, %7 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %21)
ret i32 0
}