#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 */
scalar_t__ oid_part_length(int);
int oid_parts(char *);
int /*<<< orphan*/ oid_split(char *, int *);
int oid_length(char *oid) {
  int data_len = 1;
  int num_parts = oid_parts(oid);
  int parts[num_parts];
  int i;
  oid_split(oid, parts);
  for (i = 2; i < num_parts; i++) {
    data_len += oid_part_length(parts[i]);
  }
  return data_len;
}


x86 assembly (clang, -O0):
<oid_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <oid_parts@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x30(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <oid_split@plt>
movl   $0x2,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11bd <oid_length+0x8d>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1050 <oid_part_length@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1186 <oid_length+0x56>
mov    -0xc(%rbp),%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oid_length>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <oid_parts@plt>
mov    %eax,%r15d
mov    %eax,%r12d
mov    %rsp,%r14
lea    0xf(,%r12,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <oid_split@plt>
mov    $0x1,%r13d
cmp    $0x3,%r15d
jl     11a5 <oid_length+0x75>
mov    $0x1,%r13d
mov    $0x2,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14,%rbx,4),%edi
call   1050 <oid_part_length@plt>
add    %eax,%r13d
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1190 <oid_length+0x60>
mov    %r13d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @oid_length(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %3
%8 = load i8*, i8** %2
%9 = call i32 @oid_parts(i8* %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %5
%13 = alloca i32, i64 %11
store i64 %11, i64* %6
%14 = load i8*, i8** %2
%15 = call i32 @oid_split(i8* %14, i32* %13)
store i32 2, i32* %7
br label %16
16: ; preds = %30, %1
%17 = load i32, i32* %7
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %33
20: ; preds = %16
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %13, i64 %22
%24 = load i32, i32* %23
%25 = call i64 @oid_part_length(i32 %24)
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = add nsw i64 %27, %25
%29 = trunc i64 %28 to i32
store i32 %29, i32* %3
br label %30
30: ; preds = %20
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %16
33: ; preds = %16
%34 = load i32, i32* %3
%35 = load i8*, i8** %5
ret i32 %34
}

LLVM IR (-O2):
define i32 @oid_length(i8* %0) {
%2 = tail call i32 @oid_parts(i8* %0)
%3 = zext i32 %2 to i64
%4 = alloca i32, i64 %3
%5 = call i32 @oid_split(i8* %0, i32* %4)
%6 = icmp sgt i32 %2, 2
br i1 %6, label %7, label %17
7: ; preds = %1, %7
%8 = phi i64 [ %15, %7 ], [ 2, %1 ]
%9 = phi i32 [ %14, %7 ], [ 1, %1 ]
%10 = getelementptr inbounds i32, i32* %4, i64 %8
%11 = load i32, i32* %10
%12 = call i64 @oid_part_length(i32 %11)
%13 = trunc i64 %12 to i32
%14 = add i32 %9, %13
%15 = add nuw nsw i64 %8, 1
%16 = icmp eq i64 %15, %3
br i1 %16, label %17, label %7
17: ; preds = %7, %1
%18 = phi i32 [ 1, %1 ], [ %14, %7 ]
ret i32 %18
}