#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 Platform_Halt(int);
int OPC_Length(unsigned char *s, long long s__len) {
  int _o_result;
  int i;
  i = 0;
  while (s[(((unsigned long long)(i) < (unsigned long long)(s__len))
                ? i
                : (Platform_Halt(-2), 0))] != 0x00) {
    i += 1;
  }
  _o_result = i;
  return _o_result;
}


x86 assembly (clang, -O0):
<OPC_Length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movslq -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1148 <OPC_Length+0x38>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1157 <OPC_Length+0x47>
mov    $0xfffffffe,%edi
call   1030 <Platform_Halt@plt>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     117c <OPC_Length+0x6c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1127 <OPC_Length+0x17>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OPC_Length>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
jmp    112d <OPC_Length+0x1d>
nop
mov    %eax,%eax
add    $0x1,%rbx
cmpb   $0x0,(%r15,%rax,1)
je     1143 <OPC_Length+0x33>
mov    %rbx,%rax
cmp    %r14,%rbx
jb     1120 <OPC_Length+0x10>
mov    $0xfffffffe,%edi
call   1030 <Platform_Halt@plt>
xor    %eax,%eax
jmp    1120 <OPC_Length+0x10>
add    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @OPC_Length(i8* nocapture %0, i64 %1) {
br label %3
3: ; preds = %8, %2
%4 = phi i64 [ %14, %8 ], [ 0, %2 ]
%5 = icmp ult i64 %4, %1
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @Platform_Halt(i32 -2)
br label %8
8: ; preds = %3, %6
%9 = phi i64 [ 0, %6 ], [ %4, %3 ]
%10 = and i64 %9, 4294967295
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
%14 = add nuw i64 %4, 1
br i1 %13, label %15, label %3
15: ; preds = %8
%16 = trunc i64 %4 to i32
ret i32 %16
}