#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 */
typedef int uint;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void fprint_oid(FILE *f, unsigned char *p, unsigned char *e) {
  uint component = 0;
  if (p < e) {
    fprintf(f, "%u.%u", *p / 40, *p - (*p / 40) * 40);
    if (p < e)
      fputc('.', f);
    p++;
  }
  while (p < e) {
    component <<= 7;
    component |= (*p & 0x7f);
    if (*p++ & 0x80)
      continue;
    fprintf(f, "%u", component);
    if (p < e)
      fputc('.', f);
    component = 0;
  }
}


x86 assembly (clang, -O0):
<fprint_oid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11b3 <fprint_oid+0x93>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    $0x28,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%ecx
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    $0x28,%esi
cltd
idiv   %esi
mov    -0x20(%rbp),%edx
imul   $0x28,%eax,%eax
sub    %eax,%ecx
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11a7 <fprint_oid+0x87>
mov    -0x8(%rbp),%rsi
mov    $0x2e,%edi
call   1030 <fputc@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11b8 <fprint_oid+0x98>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1241 <fprint_oid+0x121>
mov    -0x1c(%rbp),%eax
shl    $0x7,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
and    $0x7f,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1204 <fprint_oid+0xe4>
jmp    11b8 <fprint_oid+0x98>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1235 <fprint_oid+0x115>
mov    -0x8(%rbp),%rsi
mov    $0x2e,%edi
call   1030 <fputc@plt>
movl   $0x0,-0x1c(%rbp)
jmp    11b8 <fprint_oid+0x98>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_oid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r15
cmp    %rdx,%rsi
jae    1175 <fprint_oid+0x55>
movzbl 0x0(%r13),%ecx
imul   $0xcd,%ecx,%edx
shr    $0xd,%edx
lea    0x0(,%rdx,8),%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ecx
lea    0xea6(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x2e,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0x1,%r13
cmp    %r14,%r13
jae    11d2 <fprint_oid+0xb2>
mov    %r14,%rbx
sub    %r13,%rbx
add    $0x1,%r13
xor    %ebp,%ebp
lea    0xe76(%rip),%r12
jmp    119c <fprint_oid+0x7c>
nop
mov    %edx,%ebp
add    $0x1,%r13
add    $0xffffffffffffffff,%rbx
je     11d2 <fprint_oid+0xb2>
shl    $0x7,%ebp
movzbl -0x1(%r13),%eax
mov    %eax,%edx
and    $0x7f,%edx
or     %ebp,%edx
test   $0x80,%al
jne    1190 <fprint_oid+0x70>
xor    %ebp,%ebp
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    %r14,%r13
jae    1192 <fprint_oid+0x72>
mov    $0x2e,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
jmp    1192 <fprint_oid+0x72>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%u.%u\00"
@.str.1 = [3 x i8] c"%u\00"
define void @fprint_oid(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
%8 = load i8*, i8** %5
%9 = load i8*, i8** %6
%10 = icmp ult i8* %8, %9
br i1 %10, label %11, label %36
11: ; preds = %3
%12 = load i32*, i32** %4
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = sdiv i32 %15, 40
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = load i8*, i8** %5
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = sdiv i32 %22, 40
%24 = mul nsw i32 %23, 40
%25 = sub nsw i32 %19, %24
%26 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %25)
%27 = load i8*, i8** %5
%28 = load i8*, i8** %6
%29 = icmp ult i8* %27, %28
br i1 %29, label %30, label %33
30: ; preds = %11
%31 = load i32*, i32** %4
%32 = call i32 @fputc(i8 signext 46, i32* %31)
br label %33
33: ; preds = %30, %11
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %5
br label %36
36: ; preds = %33, %3
br label %37
37: ; preds = %67, %56, %36
%38 = load i8*, i8** %5
%39 = load i8*, i8** %6
%40 = icmp ult i8* %38, %39
br i1 %40, label %41, label %68
41: ; preds = %37
%42 = load i32, i32* %7
%43 = shl i32 %42, 7
store i32 %43, i32* %7
%44 = load i8*, i8** %5
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = and i32 %46, 127
%48 = load i32, i32* %7
%49 = or i32 %48, %47
store i32 %49, i32* %7
%50 = load i8*, i8** %5
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %5
%52 = load i8, i8* %50
%53 = zext i8 %52 to i32
%54 = and i32 %53, 128
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %41
br label %37
57: ; preds = %41
%58 = load i32*, i32** %4
%59 = load i32, i32* %7
%60 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %59)
%61 = load i8*, i8** %5
%62 = load i8*, i8** %6
%63 = icmp ult i8* %61, %62
br i1 %63, label %64, label %67
64: ; preds = %57
%65 = load i32*, i32** %4
%66 = call i32 @fputc(i8 signext 46, i32* %65)
br label %67
67: ; preds = %64, %57
store i32 0, i32* %7
br label %37
68: ; preds = %37
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%u.%u\00"
@.str.1 = [3 x i8] c"%u\00"
define void @fprint_oid(i32* nocapture %0, i8* %1, i8* readnone %2) {
%4 = ptrtoint i8* %2 to i64
%5 = icmp ult i8* %1, %2
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = load i8, i8* %1
%8 = zext i8 %7 to i32
%9 = udiv i8 %7, 40
%10 = zext i8 %9 to i32
%11 = mul nsw i32 %10, -40
%12 = add nsw i32 %11, %8
%13 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %12)
%14 = tail call i32 @fputc(i8 signext 46, i32* %0)
%15 = getelementptr inbounds i8, i8* %1, i64 1
br label %16
16: ; preds = %6, %3
%17 = phi i8* [ %15, %6 ], [ %1, %3 ]
%18 = icmp ult i8* %17, %2
br i1 %18, label %19, label %42
19: ; preds = %16
%20 = ptrtoint i8* %17 to i64
%21 = sub i64 %4, %20
%22 = getelementptr i8, i8* %17, i64 %21
br label %23
23: ; preds = %19, %39
%24 = phi i32 [ %40, %39 ], [ 0, %19 ]
%25 = phi i8* [ %31, %39 ], [ %17, %19 ]
%26 = shl i32 %24, 7
%27 = load i8, i8* %25
%28 = zext i8 %27 to i32
%29 = and i32 %28, 127
%30 = or i32 %29, %26
%31 = getelementptr inbounds i8, i8* %25, i64 1
%32 = and i32 %28, 128
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %23
%35 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%36 = icmp ult i8* %31, %2
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = tail call i32 @fputc(i8 signext 46, i32* %0)
br label %39
39: ; preds = %34, %37, %23
%40 = phi i32 [ %30, %23 ], [ 0, %37 ], [ 0, %34 ]
%41 = icmp eq i8* %31, %22
br i1 %41, label %42, label %23
42: ; preds = %39, %16
ret void
}