#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 /*<<< orphan*/ _DIAGASSERT(int /*<<< orphan*/);
size_t strlen(char *const);
size_t fts_maxarglen(char *const *argv) {
  size_t len, max;
  _DIAGASSERT(argv != NULL);
  for (max = 0; *argv; ++argv)
    if ((len = strlen(*argv)) > max)
      max = len;
  return (max + 1);
}


x86 assembly (clang, -O0):
<fts_maxarglen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <_DIAGASSERT@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     118c <fts_maxarglen+0x6c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
cmp    -0x18(%rbp),%rax
jbe    1176 <fts_maxarglen+0x56>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    117b <fts_maxarglen+0x5b>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    1146 <fts_maxarglen+0x26>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts_maxarglen>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <_DIAGASSERT@plt>
mov    (%r14),%rdi
test   %rdi,%rdi
je     116e <fts_maxarglen+0x4e>
add    $0x8,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1030 <strlen@plt>
cmp    %rbx,%rax
cmova  %rax,%rbx
mov    (%r14),%rdi
add    $0x8,%r14
test   %rdi,%rdi
jne    1150 <fts_maxarglen+0x30>
add    $0x1,%rbx
jmp    1173 <fts_maxarglen+0x53>
mov    $0x1,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @fts_maxarglen(i8** %0) {
%2 = alloca i8**
%3 = alloca i64
%4 = alloca i64
store i8** %0, i8*** %2
%5 = load i8**, i8*** %2
%6 = icmp ne i8** %5, null
%7 = zext i1 %6 to i32
%8 = call i32 @_DIAGASSERT(i32 %7)
store i64 0, i64* %4
br label %9
9: ; preds = %22, %1
%10 = load i8**, i8*** %2
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = load i8**, i8*** %2
%15 = load i8*, i8** %14
%16 = call i64 @strlen(i8* %15)
store i64 %16, i64* %3
%17 = load i64, i64* %4
%18 = icmp ugt i64 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = load i64, i64* %3
store i64 %20, i64* %4
br label %21
21: ; preds = %19, %13
br label %22
22: ; preds = %21
%23 = load i8**, i8*** %2
%24 = getelementptr inbounds i8*, i8** %23, i32 1
store i8** %24, i8*** %2
br label %9
25: ; preds = %9
%26 = load i64, i64* %4
%27 = add i64 %26, 1
ret i64 %27
}

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