#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[256];
  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    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <oid_parts@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1040 <oid_split@plt>
movl   $0x2,-0x414(%rbp)
mov    -0x414(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11af <oid_length+0x7f>
movslq -0x414(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%edi
call   1050 <oid_part_length@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    116c <oid_length+0x3c>
mov    -0xc(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oid_length>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rbx
call   1030 <oid_parts@plt>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <oid_split@plt>
mov    $0x1,%ebx
cmp    $0x3,%ebp
jl     1183 <oid_length+0x53>
mov    %ebp,%r14d
mov    $0x1,%ebx
mov    $0x2,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%rsp,%rbp,4),%edi
call   1050 <oid_part_length@plt>
add    %eax,%ebx
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1170 <oid_length+0x40>
mov    %ebx,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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