#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 */
struct binary_exponential_buffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ binary_exponential_buffer_data(struct binary_exponential_buffer *);
unsigned int binary_exponential_buffer_size(struct binary_exponential_buffer *);
unsigned int get_length(unsigned char *);
unsigned int set_lengths(struct binary_exponential_buffer *lengths,
                         unsigned char **search_strs) {
  unsigned int *p = (unsigned int *)binary_exponential_buffer_data(lengths);
  unsigned int num_lengths = binary_exponential_buffer_size(lengths);
  unsigned int i;
  unsigned int longest = 0;
  for (i = 0; i < num_lengths; i++) {
    unsigned int l = get_length(search_strs[i]);
    assert(l != 0);
    p[i] = l;
    if (l > longest) {
      longest = l;
    }
  }
  return longest;
}


x86 assembly (clang, -O0):
<set_lengths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <binary_exponential_buffer_data@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <binary_exponential_buffer_size@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11d9 <set_lengths+0x99>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1030 <get_length@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x28(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jbe    11c6 <set_lengths+0x86>
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11cb <set_lengths+0x8b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1177 <set_lengths+0x37>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_lengths>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbp
call   1060 <binary_exponential_buffer_data@plt>
mov    %rax,%r15
mov    %rbp,%rdi
call   1050 <binary_exponential_buffer_size@plt>
test   %eax,%eax
je     119e <set_lengths+0x5e>
mov    %eax,%r12d
xor    %ebp,%ebp
xor    %r13d,%r13d
nopl   (%rax)
mov    (%r14,%rbp,8),%rdi
call   1030 <get_length@plt>
mov    %eax,%ebx
xor    %edi,%edi
test   %eax,%eax
setne  %dil
call   1040 <assert@plt>
cmp    %r13d,%ebx
cmova  %ebx,%r13d
mov    %ebx,(%r15,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1170 <set_lengths+0x30>
jmp    11a1 <set_lengths+0x61>
xor    %r13d,%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.binary_exponential_buffer = type { i32 }
define i32 @set_lengths(%struct.binary_exponential_buffer* %0, i8** %1) {
%3 = alloca %struct.binary_exponential_buffer*
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store %struct.binary_exponential_buffer* %0, %struct.binary_exponential_buffer** %3
store i8** %1, i8*** %4
%10 = load %struct.binary_exponential_buffer*, %struct.binary_exponential_buffer** %3
%11 = call i64 @binary_exponential_buffer_data(%struct.binary_exponential_buffer* %10)
%12 = inttoptr i64 %11 to i32*
store i32* %12, i32** %5
%13 = load %struct.binary_exponential_buffer*, %struct.binary_exponential_buffer** %3
%14 = call i32 @binary_exponential_buffer_size(%struct.binary_exponential_buffer* %13)
store i32 %14, i32* %6
store i32 0, i32* %8
store i32 0, i32* %7
br label %15
15: ; preds = %41, %2
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = icmp ult i32 %16, %17
br i1 %18, label %19, label %44
19: ; preds = %15
%20 = load i8**, i8*** %4
%21 = load i32, i32* %7
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @get_length(i8* %24)
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i32, i32* %9
%31 = load i32*, i32** %5
%32 = load i32, i32* %7
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
store i32 %30, i32* %34
%35 = load i32, i32* %9
%36 = load i32, i32* %8
%37 = icmp ugt i32 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %19
%39 = load i32, i32* %9
store i32 %39, i32* %8
br label %40
40: ; preds = %38, %19
br label %41
41: ; preds = %40
%42 = load i32, i32* %7
%43 = add i32 %42, 1
store i32 %43, i32* %7
br label %15
44: ; preds = %15
%45 = load i32, i32* %8
ret i32 %45
}

LLVM IR (-O2):
%struct.binary_exponential_buffer = type { i32 }
define i32 @set_lengths(%struct.binary_exponential_buffer* %0, i8** nocapture %1) {
%3 = tail call i64 @binary_exponential_buffer_data(%struct.binary_exponential_buffer* %0)
%4 = inttoptr i64 %3 to i32*
%5 = tail call i32 @binary_exponential_buffer_size(%struct.binary_exponential_buffer* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %23, label %7
7: ; preds = %2
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %21, %9 ]
%11 = phi i32 [ 0, %7 ], [ %20, %9 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %10
%13 = load i8*, i8** %12
%14 = tail call i32 @get_length(i8* %13)
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = getelementptr inbounds i32, i32* %4, i64 %10
store i32 %14, i32* %18
%19 = icmp ugt i32 %14, %11
%20 = select i1 %19, i32 %14, i32 %11
%21 = add nuw nsw i64 %10, 1
%22 = icmp eq i64 %21, %8
br i1 %22, label %23, label %9
23: ; preds = %9, %2
%24 = phi i32 [ 0, %2 ], [ %20, %9 ]
ret i32 %24
}