#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 */
char *strchr(char const *, char);
char *__argz_next(const char *argz, size_t argz_len, const char *entry) {
  if (entry) {
    if (entry < argz + argz_len)
      entry = strchr(entry, '\0') + 1;
    return entry >= argz + argz_len ? NULL : (char *)entry;
  } else if (argz_len > 0)
    return (char *)argz;
  else
    return NULL;
}


x86 assembly (clang, -O0):
<__argz_next>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     118c <__argz_next+0x7c>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    -0x18(%rbp),%rcx
cmp    %rcx,%rax
jae    1157 <__argz_next+0x47>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1030 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    -0x18(%rbp),%rcx
cmp    %rcx,%rax
jb     1177 <__argz_next+0x67>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    117f <__argz_next+0x6f>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ac <__argz_next+0x9c>
cmpq   $0x0,-0x18(%rbp)
jbe    11a4 <__argz_next+0x94>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ac <__argz_next+0x9c>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__argz_next>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rdx,%rdx
je     1141 <__argz_next+0x31>
mov    %rdx,%rbx
add    %rsi,%r14
cmp    %rdx,%r14
jbe    1136 <__argz_next+0x26>
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    %rax,%rbx
add    $0x1,%rbx
xor    %eax,%eax
cmp    %r14,%rbx
cmovb  %rbx,%rax
jmp    114b <__argz_next+0x3b>
test   %rsi,%rsi
cmove  %rsi,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @__argz_next(i8* %0, i64 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
%8 = load i8*, i8** %7
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %31
10: ; preds = %3
%11 = load i8*, i8** %7
%12 = load i8*, i8** %5
%13 = load i64, i64* %6
%14 = getelementptr inbounds i8, i8* %12, i64 %13
%15 = icmp ult i8* %11, %14
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = load i8*, i8** %7
%18 = call i8* @strchr(i8* %17, i8 signext 0)
%19 = getelementptr inbounds i8, i8* %18, i64 1
store i8* %19, i8** %7
br label %20
20: ; preds = %16, %10
%21 = load i8*, i8** %7
%22 = load i8*, i8** %5
%23 = load i64, i64* %6
%24 = getelementptr inbounds i8, i8* %22, i64 %23
%25 = icmp uge i8* %21, %24
br i1 %25, label %26, label %27
26: ; preds = %20
br label %29
27: ; preds = %20
%28 = load i8*, i8** %7
br label %29
29: ; preds = %27, %26
%30 = phi i8* [ null, %26 ], [ %28, %27 ]
store i8* %30, i8** %4
br label %37
31: ; preds = %3
%32 = load i64, i64* %6
%33 = icmp ugt i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = load i8*, i8** %5
store i8* %35, i8** %4
br label %37
36: ; preds = %31
store i8* null, i8** %4
br label %37
37: ; preds = %36, %34, %29
%38 = load i8*, i8** %4
ret i8* %38
}

LLVM IR (-O2):
define i8* @__argz_next(i8* readnone %0, i64 %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %16, label %5
5: ; preds = %3
%6 = getelementptr inbounds i8, i8* %0, i64 %1
%7 = icmp ugt i8* %6, %2
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = tail call i64 @strlen(i8* %2)
%10 = getelementptr i8, i8* %2, i64 %9
%11 = getelementptr inbounds i8, i8* %10, i64 1
br label %12
12: ; preds = %8, %5
%13 = phi i8* [ %11, %8 ], [ %2, %5 ]
%14 = icmp ult i8* %13, %6
%15 = select i1 %14, i8* %13, i8* null
br label %19
16: ; preds = %3
%17 = icmp eq i64 %1, 0
%18 = select i1 %17, i8* null, i8* %0
br label %19
19: ; preds = %16, %12
%20 = phi i8* [ %15, %12 ], [ %18, %16 ]
ret i8* %20
}