#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 oid_parts(char *);
int /*<<< orphan*/ oid_split(char *, int *);
void *render_byte(int, void *);
void *render_oid_part(int, void *);
void *render_oid(char *oid, void *dest) {
  int num_parts = oid_parts(oid);
  int parts[num_parts];
  int i;
  int first_two;
  oid_split(oid, parts);
  first_two = parts[0] * 40 + parts[1];
  dest = render_byte(first_two, dest);
  for (i = 2; i < num_parts; i++)
    dest = render_oid_part(parts[i], dest);
  return dest;
}


x86 assembly (clang, -O0):
<render_oid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <oid_parts@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x38(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <oid_split@plt>
mov    -0x38(%rbp),%rcx
imul   $0x28,(%rcx),%eax
add    0x4(%rcx),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <render_byte@plt>
mov    %rax,-0x10(%rbp)
movl   $0x2,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e2 <render_oid+0xa2>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rsi
call   1060 <render_oid_part@plt>
mov    %rax,-0x10(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b0 <render_oid+0x70>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<render_oid>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,-0x38(%rbp)
mov    %rdi,%r12
call   1030 <oid_parts@plt>
mov    %eax,-0x2c(%rbp)
mov    %eax,%r13d
mov    %rsp,%rbx
lea    0xf(,%r13,4),%r15
and    $0xfffffffffffffff0,%r15
mov    %rbx,%r14
sub    %r15,%r14
mov    %r14,%rsp
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <oid_split@plt>
mov    (%r14),%eax
lea    (%rax,%rax,4),%edi
shl    $0x3,%edi
neg    %r15
add    0x4(%rbx,%r15,1),%edi
mov    -0x38(%rbp),%rsi
call   1040 <render_byte@plt>
cmpl   $0x3,-0x2c(%rbp)
jl     11c5 <render_oid+0x85>
mov    $0x2,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,4),%edi
mov    %rax,%rsi
call   1060 <render_oid_part@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11b0 <render_oid+0x70>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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