#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdout;
int main() {
  int entrada = 0, resultado = 0, iteraciones = 0, sumaRestados = 0;
  do {
    printf("#: ");
    scanf("%d", &entrada);
    if (++iteraciones % 2 == 0) {
      resultado += entrada;
    } else {
      resultado -= entrada;
      sumaRestados += entrada;
    }
  } while (resultado != 0);
  fprintf(stdout, "############################\n");
  fprintf(stdout, "Resultado: %d\n", resultado);
  fprintf(stdout, "Operandos realizados: %d\n", iteraciones);
  fprintf(stdout, "Suma de los numeros a restar: %d\n", sumaRestados);
  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,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    0xe96(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119f <main+0x6f>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11b3 <main+0x83>
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11b8 <main+0x88>
cmpl   $0x0,-0xc(%rbp)
jne    115b <main+0x2b>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%edx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
xor    %ebx,%ebx
lea    0xeb4(%rip),%r14
lea    0xeb1(%rip),%r15
lea    0x4(%rsp),%r12
xor    %ebp,%ebp
xor    %r13d,%r13d
nopl   (%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
add    $0x1,%ebp
mov    %ebp,%eax
and    $0x1,%eax
mov    %eax,%ecx
neg    %ecx
mov    0x4(%rsp),%edx
mov    %edx,%esi
neg    %esi
test   %eax,%eax
cmove  %edx,%esi
and    %edx,%ecx
add    %ecx,%r13d
add    %esi,%ebx
jne    1160 <main+0x30>
mov    0x2e44(%rip),%rbx
mov    (%rbx),%edi
lea    0xe62(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe70(%rip),%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe6d(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe75(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"#: \00"
@.str.1 = [3 x i8] c"%d\00"
@stdout = global i32 0
@.str.2 = [30 x i8] c"############################\0A\00"
@.str.3 = [15 x i8] c"Resultado: %d\0A\00"
@.str.4 = [26 x i8] c"Operandos realizados: %d\0A\00"
@.str.5 = [34 x i8] c"Suma de los numeros a restar: %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* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %25, %0
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %4
%10 = add nsw i32 %9, 1
store i32 %10, i32* %4
%11 = srem i32 %10, 2
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %6
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = add nsw i32 %15, %14
store i32 %16, i32* %3
br label %24
17: ; preds = %6
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, %18
store i32 %20, i32* %3
%21 = load i32, i32* %2
%22 = load i32, i32* %5
%23 = add nsw i32 %22, %21
store i32 %23, i32* %5
br label %24
24: ; preds = %17, %13
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 0
br i1 %27, label %6, label %28
28: ; preds = %25
%29 = load i32, i32* @stdout
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32, i32* @stdout
%32 = load i32, i32* %3
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = load i32, i32* @stdout
%35 = load i32, i32* %4
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = load i32, i32* @stdout
%38 = load i32, i32* %5
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"#: \00"
@.str.1 = [3 x i8] c"%d\00"
@stdout = global i32 0
@.str.2 = [30 x i8] c"############################\0A\00"
@.str.3 = [15 x i8] c"Resultado: %d\0A\00"
@.str.4 = [26 x i8] c"Operandos realizados: %d\0A\00"
@.str.5 = [34 x i8] c"Suma de los numeros a restar: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %3, %0
%4 = phi i32 [ 0, %0 ], [ %15, %3 ]
%5 = phi i32 [ 0, %0 ], [ %9, %3 ]
%6 = phi i32 [ 0, %0 ], [ %17, %3 ]
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = add nuw nsw i32 %5, 1
%10 = and i32 %9, 1
%11 = icmp eq i32 %10, 0
%12 = load i32, i32* %1
%13 = sub i32 0, %12
%14 = select i1 %11, i32 %12, i32 %13
%15 = add i32 %4, %14
%16 = select i1 %11, i32 0, i32 %12
%17 = add nsw i32 %6, %16
%18 = icmp eq i32 %15, 0
br i1 %18, label %19, label %3
19: ; preds = %3
%20 = load i32, i32* @stdout
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* @stdout
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 0)
%24 = load i32, i32* @stdout
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%26 = load i32, i32* @stdout
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %17)
ret i32 0
}