#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*/ LC_ALL;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int main() {
  setlocale(LC_ALL, "RUS");
  int x = 1, positive_sum = 0, negative_sum = 0;
  for (; x != 0;) {
    printf("\nВведите целое число (0 - для остановки): ");
    scanf("%d", &x);
    if (x > 0)
      positive_sum += x;
    else
      negative_sum += x;
  }
  printf("Сумма положительных чисел: %d\n", positive_sum);
  printf("Сумма отрицательных чисел: %d\n", negative_sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xeb1(%rip),%rsi
call   1040 <setlocale@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b7 <main+0x87>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11a9 <main+0x79>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11b2 <main+0x82>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1169 <main+0x39>
mov    -0xc(%rbp),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xeb3(%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   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
lea    0xeb5(%rip),%rsi
call   1040 <setlocale@plt>
movl   $0x1,0x4(%rsp)
xor    %r13d,%r13d
lea    0xea2(%rip),%r14
lea    0xee3(%rip),%r15
lea    0x4(%rsp),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
mov    $0x0,%ecx
cmovg  %eax,%ecx
mov    %eax,%edx
cmovg  %r13d,%edx
add    %ecx,%ebp
add    %edx,%ebx
test   %eax,%eax
jne    1180 <main+0x50>
lea    0xe97(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [4 x i8] c"RUS\00"
@.str.1 = [72 x i8] c"\0A\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 \D1\86\D0\B5\D0\BB\D0\BE\D0\B5 \D1\87\D0\B8\D1\81\D0\BB\D0\BE (0 - \D0\B4\D0\BB\D1\8F \D0\BE\D1\81\D1\82\D0\B0\D0\BD\D0\BE\D0\B2\D0\BA\D0\B8): \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [54 x i8] c"\D0\A1\D1\83\D0\BC\D0\BC\D0\B0 \D0\BF\D0\BE\D0\BB\D0\BE\D0\B6\D0\B8\D1\82\D0\B5\D0\BB\D1\8C\D0\BD\D1\8B\D1\85 \D1\87\D0\B8\D1\81\D0\B5\D0\BB: %d\0A\00"
@.str.4 = [54 x i8] c"\D0\A1\D1\83\D0\BC\D0\BC\D0\B0 \D0\BE\D1\82\D1\80\D0\B8\D1\86\D0\B0\D1\82\D0\B5\D0\BB\D1\8C\D0\BD\D1\8B\D1\85 \D1\87\D0\B8\D1\81\D0\B5\D0\BB: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* @LC_ALL
%6 = call i32 @setlocale(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %23, %0
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = add nsw i32 %17, %16
store i32 %18, i32* %3
br label %23
19: ; preds = %10
%20 = load i32, i32* %2
%21 = load i32, i32* %4
%22 = add nsw i32 %21, %20
store i32 %22, i32* %4
br label %23
23: ; preds = %19, %15
br label %7
24: ; preds = %7
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %4
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i32 %27)
ret i32 0
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [4 x i8] c"RUS\00"
@.str.1 = [72 x i8] c"\0A\D0\92\D0\B2\D0\B5\D0\B4\D0\B8\D1\82\D0\B5 \D1\86\D0\B5\D0\BB\D0\BE\D0\B5 \D1\87\D0\B8\D1\81\D0\BB\D0\BE (0 - \D0\B4\D0\BB\D1\8F \D0\BE\D1\81\D1\82\D0\B0\D0\BD\D0\BE\D0\B2\D0\BA\D0\B8): \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [54 x i8] c"\D0\A1\D1\83\D0\BC\D0\BC\D0\B0 \D0\BF\D0\BE\D0\BB\D0\BE\D0\B6\D0\B8\D1\82\D0\B5\D0\BB\D1\8C\D0\BD\D1\8B\D1\85 \D1\87\D0\B8\D1\81\D0\B5\D0\BB: %d\0A\00"
@.str.4 = [54 x i8] c"\D0\A1\D1\83\D0\BC\D0\BC\D0\B0 \D0\BE\D1\82\D1\80\D0\B8\D1\86\D0\B0\D1\82\D0\B5\D0\BB\D1\8C\D0\BD\D1\8B\D1\85 \D1\87\D0\B8\D1\81\D0\B5\D0\BB: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = load i32, i32* @LC_ALL
%3 = tail call i32 @setlocale(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
store i32 1, i32* %1
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ 0, %0 ], [ %15, %5 ]
%7 = phi i32 [ 0, %0 ], [ %13, %5 ]
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
%12 = select i1 %11, i32 %10, i32 0
%13 = add nuw nsw i32 %12, %7
%14 = select i1 %11, i32 0, i32 %10
%15 = add nsw i32 %14, %6
%16 = icmp eq i32 %10, 0
br i1 %16, label %17, label %5
17: ; preds = %5
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i32 %15)
ret i32 0
}