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

/* Variables and functions */
int abs(int);
int /*<<< orphan*/ searchOrAdd(int *, struct node *);
void step(int *cords, int cordIndex, int amt, struct node *ll) {
  int i;
  int increment = amt < 0 ? -1 : 1;
  for (i = 0; i < abs(amt); i++) {
    cords[cordIndex] = cords[cordIndex] + increment;
    searchOrAdd(cords, ll);
  }
}


x86 assembly (clang, -O0):
<step>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%edx
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%edx
cmovl  %ecx,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11a2 <step+0x82>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    -0x20(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <searchOrAdd@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1153 <step+0x33>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<step>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
je     1154 <step+0x44>
mov    %rcx,%r14
mov    %rdi,%rbx
mov    %edx,%r15d
sar    $0x1f,%r15d
or     $0x1,%r15d
mov    %edx,%ebp
neg    %ebp
cmovs  %edx,%ebp
movslq %esi,%r12
nopw   0x0(%rax,%rax,1)
add    %r15d,(%rbx,%r12,4)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <searchOrAdd@plt>
add    $0xffffffff,%ebp
jne    1140 <step+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.node = type { i32 }
define void @step(i32* %0, i32 %1, i32 %2, %struct.node* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.node*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store %struct.node* %3, %struct.node** %8
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 -1, i32 1
store i32 %14, i32* %10
store i32 0, i32* %9
br label %15
15: ; preds = %35, %4
%16 = load i32, i32* %9
%17 = load i32, i32* %7
%18 = call i32 @abs(i32 %17)
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %38
20: ; preds = %15
%21 = load i32*, i32** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = load i32, i32* %10
%27 = add nsw i32 %25, %26
%28 = load i32*, i32** %5
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
store i32 %27, i32* %31
%32 = load i32*, i32** %5
%33 = load %struct.node*, %struct.node** %8
%34 = call i32 @searchOrAdd(i32* %32, %struct.node* %33)
br label %35
35: ; preds = %20
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %15
38: ; preds = %15
ret void
}

LLVM IR (-O2):
%struct.node = type { i32 }
define void @step(i32* %0, i32 %1, i32 %2, %struct.node* %3) {
%5 = icmp sgt i32 %2, -1
%6 = select i1 %5, i32 1, i32 -1
%7 = icmp eq i32 %2, 0
br i1 %7, label %19, label %8
8: ; preds = %4
%9 = tail call i32 @llvm.abs.i32(i32 %2, i1 true)
%10 = sext i32 %1 to i64
%11 = getelementptr inbounds i32, i32* %0, i64 %10
br label %12
12: ; preds = %8, %12
%13 = phi i32 [ 0, %8 ], [ %17, %12 ]
%14 = load i32, i32* %11
%15 = add nsw i32 %14, %6
store i32 %15, i32* %11
%16 = tail call i32 @searchOrAdd(i32* %0, %struct.node* %3)
%17 = add nuw i32 %13, 1
%18 = icmp eq i32 %17, %9
br i1 %18, label %19, label %12
19: ; preds = %12, %4
ret void
}