#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 get_argCnt(char **);
int strlen(char *);
int getAfterPipe(char *args[]) {
  int ac = get_argCnt(args);
  int loc = 0;
  for (int i = 1; i < ac; i++) {
    if (strlen(args[i]) == 1 && args[i][0] == '|')
      loc = i;
    if (loc)
      break;
  }
  return loc + 1;
}


x86 assembly (clang, -O0):
<getAfterPipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <get_argCnt@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ac <getAfterPipe+0x8c>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    118a <getAfterPipe+0x6a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x7c,%eax
jne    118a <getAfterPipe+0x6a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1199 <getAfterPipe+0x79>
jmp    11ac <getAfterPipe+0x8c>
jmp    119e <getAfterPipe+0x7e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1146 <getAfterPipe+0x26>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getAfterPipe>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <get_argCnt@plt>
mov    $0x1,%r14d
cmp    $0x2,%eax
jl     1176 <getAfterPipe+0x56>
mov    %eax,%r15d
mov    $0x1,%ebp
jmp    1159 <getAfterPipe+0x39>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbp
cmp    %rbp,%r15
je     1176 <getAfterPipe+0x56>
mov    (%rbx,%rbp,8),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    1150 <getAfterPipe+0x30>
mov    (%rbx,%rbp,8),%rax
cmpb   $0x7c,(%rax)
jne    1150 <getAfterPipe+0x30>
add    $0x1,%ebp
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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