#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 atoi(char *);
int /*<<< orphan*/ free(char *);
char *strdup(char *);
char *strtok_r(char *, char *, char **);
void oid_split(char *oid, int *dest) {
  int next_part = 0;
  char *temp = strdup(oid);
  char *save_ptr;
  char *p = strtok_r(temp, ".", &save_ptr);
  while (p) {
    dest[next_part] = atoi(p);
    next_part++;
    p = strtok_r(NULL, ".", &save_ptr);
  }
  free(temp);
}


x86 assembly (clang, -O0):
<oid_split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe91(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11c3 <oid_split+0x83>
mov    -0x30(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe4f(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
jmp    117c <oid_split+0x3c>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oid_split>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
call   1060 <strdup@plt>
mov    %rax,%r14
lea    0xea6(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1040 <strtok_r@plt>
test   %rax,%rax
je     11a0 <oid_split+0x60>
lea    0xe8f(%rip),%r15
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %eax,(%rbx)
xor    %edi,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <strtok_r@plt>
add    $0x4,%rbx
test   %rax,%rax
jne    1180 <oid_split+0x40>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
define void @oid_split(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 0, i32* %5
%9 = load i8*, i8** %3
%10 = call i8* @strdup(i8* %9)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = call i8* @strtok_r(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %7)
store i8* %12, i8** %8
br label %13
13: ; preds = %16, %2
%14 = load i8*, i8** %8
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i8*, i8** %8
%18 = call i32 @atoi(i8* %17)
%19 = load i32*, i32** %4
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 %18, i32* %22
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
%25 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %7)
store i8* %25, i8** %8
br label %13
26: ; preds = %13
%27 = load i8*, i8** %6
%28 = call i32 @free(i8* %27)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
define void @oid_split(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = alloca i8*
%4 = tail call i8* @strdup(i8* %0)
%5 = bitcast i8** %3 to i8*
%6 = call i8* @strtok_r(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %3)
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %2, %8
%9 = phi i64 [ %13, %8 ], [ 0, %2 ]
%10 = phi i8* [ %14, %8 ], [ %6, %2 ]
%11 = call i32 @atoi(i8* %10)
%12 = getelementptr inbounds i32, i32* %1, i64 %9
store i32 %11, i32* %12
%13 = add nuw i64 %9, 1
%14 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %3)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %8
16: ; preds = %8, %2
%17 = call i32 @free(i8* %4)
ret void
}