#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 */
int getPinNumber(char *);
int setPinsAction(int p_actionCode, int p_count, char *p_args[],
                  int *p_pinsStruc) {
  int pin;
  int found = 0;
  int iterator = 0;
  while (iterator < p_count) {
    if ((pin = getPinNumber(p_args[iterator])) != -1) {
      found++;
      p_pinsStruc[pin] = p_actionCode;
      iterator++;
      continue;
    }
    break;
  }
  return found;
}


x86 assembly (clang, -O0):
<setPinsAction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1187 <setPinsAction+0x77>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <getPinNumber@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     1182 <setPinsAction+0x72>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1134 <setPinsAction+0x24>
jmp    1187 <setPinsAction+0x77>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setPinsAction>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    1151 <setPinsAction+0x41>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %edi,%r12d
mov    %esi,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rdi
call   1030 <getPinNumber@plt>
cmp    $0xffffffff,%eax
je     1153 <setPinsAction+0x43>
add    $0x1,%rbx
cltq
mov    %r12d,(%r14,%rax,4)
cmp    %rbx,%rbp
jne    1130 <setPinsAction+0x20>
mov    %ebp,%ebx
jmp    1153 <setPinsAction+0x43>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @setPinsAction(i32 %0, i32 %1, i8** nocapture %2, i32* nocapture writeonly %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %21
6: ; preds = %4
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %14
%9 = phi i64 [ 0, %6 ], [ %15, %14 ]
%10 = getelementptr inbounds i8*, i8** %2, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @getPinNumber(i8* %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %19, label %14
14: ; preds = %8
%15 = add nuw nsw i64 %9, 1
%16 = sext i32 %12 to i64
%17 = getelementptr inbounds i32, i32* %3, i64 %16
store i32 %0, i32* %17
%18 = icmp eq i64 %15, %7
br i1 %18, label %21, label %8
19: ; preds = %8
%20 = trunc i64 %9 to i32
br label %21
21: ; preds = %14, %19, %4
%22 = phi i32 [ 0, %4 ], [ %20, %19 ], [ %1, %14 ]
ret i32 %22
}