#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 horseList {
  int dummy;
};

/* Variables and functions */
struct horseList *create_horse_listee(int /*<<< orphan*/, struct horseList *);
int /*<<< orphan*/ gen_horse();
struct horseList *create_horse_linked_list(int numOfRacers) {
  struct horseList *hLHead, *hLCurr;
  hLHead = NULL;
  int i;
  for (i = 0; i < numOfRacers; i++) {
    hLCurr = create_horse_listee(gen_horse(), hLHead);
    hLHead = hLCurr;
  };
  return hLHead;
}


x86 assembly (clang, -O0):
<create_horse_linked_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1172 <create_horse_linked_list+0x52>
mov    $0x0,%al
call   1030 <gen_horse@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1040 <create_horse_listee@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <create_horse_linked_list+0x1a>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_horse_linked_list>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    114b <create_horse_linked_list+0x2b>
mov    %edi,%ebx
xor    %r14d,%r14d
nopl   (%rax)
xor    %eax,%eax
call   1030 <gen_horse@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <create_horse_listee@plt>
mov    %rax,%r14
add    $0xffffffff,%ebx
jne    1130 <create_horse_linked_list+0x10>
jmp    114e <create_horse_linked_list+0x2e>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.horseList = type { i32 }
define %struct.horseList* @create_horse_linked_list(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.horseList*
%4 = alloca %struct.horseList*
%5 = alloca i32
store i32 %0, i32* %2
store %struct.horseList* null, %struct.horseList** %3
store i32 0, i32* %5
br label %6
6: ; preds = %15, %1
%7 = load i32, i32* %5
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %18
10: ; preds = %6
%11 = call i32 (...) @gen_horse()
%12 = load %struct.horseList*, %struct.horseList** %3
%13 = call %struct.horseList* @create_horse_listee(i32 %11, %struct.horseList* %12)
store %struct.horseList* %13, %struct.horseList** %4
%14 = load %struct.horseList*, %struct.horseList** %4
store %struct.horseList* %14, %struct.horseList** %3
br label %15
15: ; preds = %10
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
br label %6
18: ; preds = %6
%19 = load %struct.horseList*, %struct.horseList** %3
ret %struct.horseList* %19
}

LLVM IR (-O2):
%struct.horseList = type { i32 }
define %struct.horseList* @create_horse_linked_list(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %10
3: ; preds = %1, %3
%4 = phi i32 [ %8, %3 ], [ 0, %1 ]
%5 = phi %struct.horseList* [ %7, %3 ], [ null, %1 ]
%6 = tail call i32 (...) @gen_horse()
%7 = tail call %struct.horseList* @create_horse_listee(i32 %6, %struct.horseList* %5)
%8 = add nuw nsw i32 %4, 1
%9 = icmp eq i32 %8, %0
br i1 %9, label %10, label %3
10: ; preds = %3, %1
%11 = phi %struct.horseList* [ null, %1 ], [ %7, %3 ]
ret %struct.horseList* %11
}