#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 strlen(char *);
int length_longest_filename(char **argv) {
  int n;
  for (n = 0; argv && *argv; argv++) {
    n = ((n) > (strlen(*argv)) ? (n) : (strlen(*argv)));
  }
  return n;
}


x86 assembly (clang, -O0):
<length_longest_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0xd(%rbp)
je     1141 <length_longest_filename+0x31>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1151 <length_longest_filename+0x41>
jmp    11a1 <length_longest_filename+0x91>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jle    117b <length_longest_filename+0x6b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    118a <length_longest_filename+0x7a>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    1123 <length_longest_filename+0x13>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<length_longest_filename>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     1152 <length_longest_filename+0x42>
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1152 <length_longest_filename+0x42>
add    $0x8,%rbx
xor    %ebp,%ebp
jmp    113c <length_longest_filename+0x2c>
nopl   (%rax)
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     1152 <length_longest_filename+0x42>
call   1030 <strlen@plt>
cmp    %eax,%ebp
jg     1130 <length_longest_filename+0x20>
mov    -0x8(%rbx),%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
jmp    1130 <length_longest_filename+0x20>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @length_longest_filename(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
store i8** %0, i8*** %2
store i32 0, i32* %3
br label %4
4: ; preds = %27, %1
%5 = load i8**, i8*** %2
%6 = icmp ne i8** %5, null
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = load i8**, i8*** %2
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br label %11
11: ; preds = %7, %4
%12 = phi i1 [ false, %4 ], [ %10, %7 ]
br i1 %12, label %13, label %30
13: ; preds = %11
%14 = load i32, i32* %3
%15 = load i8**, i8*** %2
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* %16)
%18 = icmp sgt i32 %14, %17
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = load i32, i32* %3
br label %25
21: ; preds = %13
%22 = load i8**, i8*** %2
%23 = load i8*, i8** %22
%24 = call i32 @strlen(i8* %23)
br label %25
25: ; preds = %21, %19
%26 = phi i32 [ %20, %19 ], [ %24, %21 ]
store i32 %26, i32* %3
br label %27
27: ; preds = %25
%28 = load i8**, i8*** %2
%29 = getelementptr inbounds i8*, i8** %28, i32 1
store i8** %29, i8*** %2
br label %4
30: ; preds = %11
%31 = load i32, i32* %3
ret i32 %31
}

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