#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 */
unsigned int input(unsigned int);
unsigned int num_peers();
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int);
int main() {
  unsigned int cur_sum_males = 0;
  unsigned int cur_sum_females = 0;
  for (unsigned int i = 0; i < num_peers(); i++) {
    unsigned int gender = input(i);
    unsigned int salary = input(i);
    if (gender == 1) {
      cur_sum_females += salary;
    } else {
      cur_sum_males += salary;
    }
  }
  printf("%d %d", cur_sum_males, cur_sum_females);
  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)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <num_peers@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jae    11b8 <main+0x88>
mov    -0x10(%rbp),%edi
call   1030 <input@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <input@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    119c <main+0x6c>
mov    -0x18(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11a5 <main+0x75>
mov    -0x18(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11aa <main+0x7a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1154 <main+0x24>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe3b(%rip),%rdi
call   1040 <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
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <num_peers@plt>
mov    $0x0,%ebp
test   %eax,%eax
je     1194 <main+0x64>
xor    %r12d,%r12d
xor    %ebp,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
call   1030 <input@plt>
mov    %eax,%r15d
mov    %ebx,%edi
call   1030 <input@plt>
cmp    $0x1,%r15d
mov    $0x0,%ecx
cmove  %eax,%ecx
cmove  %r12d,%eax
add    %ecx,%r14d
add    %eax,%ebp
add    $0x1,%ebx
xor    %eax,%eax
call   1050 <num_peers@plt>
cmp    %eax,%ebx
jb     1160 <main+0x30>
lea    0xe65(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %27, %0
%8 = load i32, i32* %4
%9 = call i32 (...) @num_peers()
%10 = icmp ult i32 %8, %9
br i1 %10, label %11, label %30
11: ; preds = %7
%12 = load i32, i32* %4
%13 = call i32 @input(i32 %12)
store i32 %13, i32* %5
%14 = load i32, i32* %4
%15 = call i32 @input(i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load i32, i32* %6
%20 = load i32, i32* %3
%21 = add i32 %20, %19
store i32 %21, i32* %3
br label %26
22: ; preds = %11
%23 = load i32, i32* %6
%24 = load i32, i32* %2
%25 = add i32 %24, %23
store i32 %25, i32* %2
br label %26
26: ; preds = %22, %18
br label %27
27: ; preds = %26
%28 = load i32, i32* %4
%29 = add i32 %28, 1
store i32 %29, i32* %4
br label %7
30: ; preds = %7
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %31, i32 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
define i32 @main() {
%1 = tail call i32 (...) @num_peers()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %7, %0
%4 = phi i32 [ 0, %0 ], [ %15, %7 ]
%5 = phi i32 [ 0, %0 ], [ %17, %7 ]
%6 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %4)
ret i32 0
7: ; preds = %0, %7
%8 = phi i32 [ %17, %7 ], [ 0, %0 ]
%9 = phi i32 [ %15, %7 ], [ 0, %0 ]
%10 = phi i32 [ %18, %7 ], [ 0, %0 ]
%11 = tail call i32 @input(i32 %10)
%12 = tail call i32 @input(i32 %10)
%13 = icmp eq i32 %11, 1
%14 = select i1 %13, i32 %12, i32 0
%15 = add i32 %14, %9
%16 = select i1 %13, i32 0, i32 %12
%17 = add i32 %16, %8
%18 = add nuw i32 %10, 1
%19 = tail call i32 (...) @num_peers()
%20 = icmp ult i32 %18, %19
br i1 %20, label %7, label %3
}