#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 */
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, unsigned int);
int sscanf(char *, char *, unsigned int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
unsigned evaluate_opponents(unsigned numPlayers) {
  unsigned pot = 0;
  while (numPlayers) {
    char buffer[8];
    printf("Player #%d: ", numPlayers);
    if (!fgets(buffer, sizeof(buffer), stdin)) {
      fprintf(stderr, "ERROR: Problem reading input.\n");
      continue;
    }
    unsigned bet;
    int retval = sscanf(buffer, "%u", &bet);
    if (retval < 1) {
      fprintf(stderr, "ERROR: Unable to parse input.\n");
      continue;
    }
    pot += bet;
    numPlayers--;
  }
  return pot;
}


x86 assembly (clang, -O0):
<evaluate_opponents>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11f7 <evaluate_opponents+0xb7>
mov    -0x4(%rbp),%esi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
mov    $0x8,%esi
call   1040 <fgets@plt>
cmp    $0x0,%eax
jne    11a5 <evaluate_opponents+0x65>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1152 <evaluate_opponents+0x12>
lea    -0x10(%rbp),%rdi
lea    0xe7c(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jge    11e0 <evaluate_opponents+0xa0>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1152 <evaluate_opponents+0x12>
mov    -0x14(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1152 <evaluate_opponents+0x12>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evaluate_opponents>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
je     11f2 <evaluate_opponents+0xb2>
mov    %edi,%ebp
xor    %r15d,%r15d
lea    0xe9e(%rip),%r14
mov    0x2e7f(%rip),%r13
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r12
jmp    1199 <evaluate_opponents+0x59>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
call   1050 <fprintf@plt>
test   %ebp,%ebp
je     11f5 <evaluate_opponents+0xb5>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1040 <fgets@plt>
test   %eax,%eax
je     1180 <evaluate_opponents+0x40>
mov    %rbx,%rdi
lea    0xe6a(%rip),%rsi
mov    %r12,%rdx
call   1060 <sscanf@plt>
test   %eax,%eax
jle    11e0 <evaluate_opponents+0xa0>
add    0xc(%rsp),%r15d
add    $0xffffffff,%ebp
test   %ebp,%ebp
jne    1199 <evaluate_opponents+0x59>
jmp    11f5 <evaluate_opponents+0xb5>
nopl   0x0(%rax)
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
jmp    1190 <evaluate_opponents+0x50>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Player #%d: \00"
@stdin = global i32 0
@stderr = global i32 0
@.str.1 = [31 x i8] c"ERROR: Problem reading input.\0A\00"
@.str.2 = [3 x i8] c"%u\00"
@.str.3 = [31 x i8] c"ERROR: Unable to parse input.\0A\00"
define i32 @evaluate_opponents(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [8 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %7
7: ; preds = %28, %25, %17, %1
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %34
10: ; preds = %7
%11 = load i32, i32* %2
%12 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 8, i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %10
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %7
20: ; preds = %10
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %7
28: ; preds = %20
%29 = load i32, i32* %5
%30 = load i32, i32* %3
%31 = add i32 %30, %29
store i32 %31, i32* %3
%32 = load i32, i32* %2
%33 = add i32 %32, -1
store i32 %33, i32* %2
br label %7
34: ; preds = %7
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [13 x i8] c"Player #%d: \00"
@stdin = global i32 0
@stderr = global i32 0
@.str.1 = [31 x i8] c"ERROR: Problem reading input.\0A\00"
@.str.2 = [3 x i8] c"%u\00"
@.str.3 = [31 x i8] c"ERROR: Unable to parse input.\0A\00"
define i32 @evaluate_opponents(i32 %0) {
%2 = alloca [8 x i8]
%3 = alloca i32
%4 = icmp eq i32 %0, 0
br i1 %4, label %35, label %5
5: ; preds = %1
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%7 = bitcast i32* %3 to i8*
br label %8
8: ; preds = %5, %31
%9 = phi i32 [ %0, %5 ], [ %33, %31 ]
%10 = phi i32 [ 0, %5 ], [ %32, %31 ]
%11 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %9)
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %6, i32 8, i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %8
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %31
18: ; preds = %8
%19 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%20 = icmp slt i32 %19, 1
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %28
24: ; preds = %18
%25 = load i32, i32* %3
%26 = add i32 %25, %10
%27 = add i32 %9, -1
br label %28
28: ; preds = %24, %21
%29 = phi i32 [ %10, %21 ], [ %26, %24 ]
%30 = phi i32 [ %9, %21 ], [ %27, %24 ]
br label %31
31: ; preds = %28, %15
%32 = phi i32 [ %29, %28 ], [ %10, %15 ]
%33 = phi i32 [ %30, %28 ], [ %9, %15 ]
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %8
35: ; preds = %31, %1
%36 = phi i32 [ 0, %1 ], [ %32, %31 ]
ret i32 %36
}