#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 */
struct Player {
  int dummy;
};
struct Config {
  int dummy;
};

/* Variables and functions */
int create_player(struct Player **, struct Config *);
int create_players(struct Player **players, int count, struct Config *config) {
  int i;
  int result = 0;
  for (i = 0; i < count; i++) {
    if ((result = create_player(players + i, config)) < 0) {
      return result;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<create_players>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    117f <create_players+0x6f>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
call   1030 <create_player@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    116c <create_players+0x5c>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <create_players+0x76>
jmp    1171 <create_players+0x61>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1131 <create_players+0x21>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_players>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
test   %esi,%esi
jle    114e <create_players+0x3e>
mov    %rdx,%r15
mov    %rdi,%rbp
mov    %esi,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <create_player@plt>
test   %eax,%eax
js     114b <create_players+0x3b>
add    $0x8,%rbp
add    $0xffffffffffffffff,%rbx
jne    1130 <create_players+0x20>
jmp    114e <create_players+0x3e>
mov    %eax,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.Player = type { i32 }
%struct.Config = type { i32 }
define i32 @create_players(%struct.Player** %0, i32 %1, %struct.Config* %2) {
%4 = alloca i32
%5 = alloca %struct.Player**
%6 = alloca i32
%7 = alloca %struct.Config*
%8 = alloca i32
%9 = alloca i32
store %struct.Player** %0, %struct.Player*** %5
store i32 %1, i32* %6
store %struct.Config* %2, %struct.Config** %7
store i32 0, i32* %9
store i32 0, i32* %8
br label %10
10: ; preds = %25, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = load %struct.Player**, %struct.Player*** %5
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds %struct.Player*, %struct.Player** %15, i64 %17
%19 = load %struct.Config*, %struct.Config** %7
%20 = call i32 @create_player(%struct.Player** %18, %struct.Config* %19)
store i32 %20, i32* %9
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = load i32, i32* %9
store i32 %23, i32* %4
br label %29
24: ; preds = %14
br label %25
25: ; preds = %24
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %10
28: ; preds = %10
store i32 0, i32* %4
br label %29
29: ; preds = %28, %22
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
%struct.Player = type { i32 }
%struct.Config = type { i32 }
define i32 @create_players(%struct.Player** %0, i32 %1, %struct.Config* %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %15
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %9
7: ; preds = %9
%8 = icmp eq i64 %14, %6
br i1 %8, label %15, label %9
9: ; preds = %5, %7
%10 = phi i64 [ 0, %5 ], [ %14, %7 ]
%11 = getelementptr inbounds %struct.Player*, %struct.Player** %0, i64 %10
%12 = tail call i32 @create_player(%struct.Player** %11, %struct.Config* %2)
%13 = icmp slt i32 %12, 0
%14 = add nuw nsw i64 %10, 1
br i1 %13, label %15, label %7
15: ; preds = %9, %7, %3
%16 = phi i32 [ 0, %3 ], [ 0, %7 ], [ %12, %9 ]
ret i32 %16
}