#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 getkey();
int /*<<< orphan*/ insert_char_in_insert_mode(int);
int /*<<< orphan*/ isdigit(int);
int /*<<< orphan*/ minibuf_write(char *, int, ...);
int quoted_insert_octal(int c1) {
  int c2, c3;
  minibuf_write("C-q %d-", c1 - '0');
  c2 = getkey();
  if (!isdigit(c2) || c2 - '0' >= 8) {
    insert_char_in_insert_mode(c1 - '0');
    insert_char_in_insert_mode(c2);
    return 1;
  }
  minibuf_write("C-q %d %d-", c1 - '0', c2 - '0');
  c3 = getkey();
  if (!isdigit(c3) || c3 - '0' >= 8) {
    insert_char_in_insert_mode((c1 - '0') * 8 + (c2 - '0'));
    insert_char_in_insert_mode(c3);
    return 1;
  }
  insert_char_in_insert_mode((c1 - '8') * 64 + (c2 - '0') * 8 + (c3 - '0'));
  return 1;
}


x86 assembly (clang, -O0):
<quoted_insert_octal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%esi
sub    $0x30,%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1050 <minibuf_write@plt>
mov    $0x0,%al
call   1060 <getkey@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     1189 <quoted_insert_octal+0x49>
mov    -0xc(%rbp),%eax
sub    $0x30,%eax
cmp    $0x8,%eax
jl     11a8 <quoted_insert_octal+0x68>
mov    -0x8(%rbp),%edi
sub    $0x30,%edi
call   1040 <insert_char_in_insert_mode@plt>
mov    -0xc(%rbp),%edi
call   1040 <insert_char_in_insert_mode@plt>
movl   $0x1,-0x4(%rbp)
jmp    123e <quoted_insert_octal+0xfe>
mov    -0x8(%rbp),%esi
sub    $0x30,%esi
mov    -0xc(%rbp),%edx
sub    $0x30,%edx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1050 <minibuf_write@plt>
mov    $0x0,%al
call   1060 <getkey@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11ec <quoted_insert_octal+0xac>
mov    -0x10(%rbp),%eax
sub    $0x30,%eax
cmp    $0x8,%eax
jl     1216 <quoted_insert_octal+0xd6>
mov    -0x8(%rbp),%edi
sub    $0x30,%edi
shl    $0x3,%edi
mov    -0xc(%rbp),%eax
sub    $0x30,%eax
add    %eax,%edi
call   1040 <insert_char_in_insert_mode@plt>
mov    -0x10(%rbp),%edi
call   1040 <insert_char_in_insert_mode@plt>
movl   $0x1,-0x4(%rbp)
jmp    123e <quoted_insert_octal+0xfe>
mov    -0x8(%rbp),%edi
sub    $0x38,%edi
shl    $0x6,%edi
mov    -0xc(%rbp),%eax
sub    $0x30,%eax
shl    $0x3,%eax
add    %eax,%edi
mov    -0x10(%rbp),%eax
sub    $0x30,%eax
add    %eax,%edi
call   1040 <insert_char_in_insert_mode@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quoted_insert_octal>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%r15d
lea    -0x30(%r15),%r14d
lea    0xeba(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <minibuf_write@plt>
xor    %eax,%eax
call   1050 <getkey@plt>
mov    %eax,%ebx
lea    -0x38(%rbx),%eax
cmp    $0xfffffff7,%eax
ja     116b <quoted_insert_octal+0x3b>
mov    %r14d,%edi
call   1030 <insert_char_in_insert_mode@plt>
jmp    11b5 <quoted_insert_octal+0x85>
add    $0xffffffd0,%ebx
lea    0xe93(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <minibuf_write@plt>
xor    %eax,%eax
call   1050 <getkey@plt>
mov    %eax,%r12d
lea    -0x38(%r12),%eax
cmp    $0xfffffff7,%eax
ja     11a3 <quoted_insert_octal+0x73>
lea    (%rbx,%r14,8),%edi
call   1030 <insert_char_in_insert_mode@plt>
mov    %r12d,%ebx
jmp    11b5 <quoted_insert_octal+0x85>
shl    $0x6,%r15d
lea    (%r15,%rbx,8),%eax
lea    (%r12,%rax,1),%ebx
add    $0xfffff1d0,%ebx
mov    %ebx,%edi
call   1030 <insert_char_in_insert_mode@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"C-q %d-\00"
@.str.1 = [11 x i8] c"C-q %d %d-\00"
define i32 @quoted_insert_octal(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = sub nsw i32 %6, 48
%8 = call i32 (i8*, i32, ...) @minibuf_write(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 (...) @getkey()
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = call i32 @isdigit(i32 %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = load i32, i32* %4
%15 = sub nsw i32 %14, 48
%16 = icmp sge i32 %15, 8
br i1 %16, label %17, label %23
17: ; preds = %13, %1
%18 = load i32, i32* %3
%19 = sub nsw i32 %18, 48
%20 = call i32 @insert_char_in_insert_mode(i32 %19)
%21 = load i32, i32* %4
%22 = call i32 @insert_char_in_insert_mode(i32 %21)
store i32 1, i32* %2
br label %59
23: ; preds = %13
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, 48
%26 = load i32, i32* %4
%27 = sub nsw i32 %26, 48
%28 = call i32 (i8*, i32, ...) @minibuf_write(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %27)
%29 = call i32 (...) @getkey()
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = call i32 @isdigit(i32 %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %23
%34 = load i32, i32* %5
%35 = sub nsw i32 %34, 48
%36 = icmp sge i32 %35, 8
br i1 %36, label %37, label %47
37: ; preds = %33, %23
%38 = load i32, i32* %3
%39 = sub nsw i32 %38, 48
%40 = mul nsw i32 %39, 8
%41 = load i32, i32* %4
%42 = sub nsw i32 %41, 48
%43 = add nsw i32 %40, %42
%44 = call i32 @insert_char_in_insert_mode(i32 %43)
%45 = load i32, i32* %5
%46 = call i32 @insert_char_in_insert_mode(i32 %45)
store i32 1, i32* %2
br label %59
47: ; preds = %33
%48 = load i32, i32* %3
%49 = sub nsw i32 %48, 56
%50 = mul nsw i32 %49, 64
%51 = load i32, i32* %4
%52 = sub nsw i32 %51, 48
%53 = mul nsw i32 %52, 8
%54 = add nsw i32 %50, %53
%55 = load i32, i32* %5
%56 = sub nsw i32 %55, 48
%57 = add nsw i32 %54, %56
%58 = call i32 @insert_char_in_insert_mode(i32 %57)
store i32 1, i32* %2
br label %59
59: ; preds = %47, %37, %17
%60 = load i32, i32* %2
ret i32 %60
}

LLVM IR (-O2):
@.str = [8 x i8] c"C-q %d-\00"
@.str.1 = [11 x i8] c"C-q %d %d-\00"
define i32 @quoted_insert_octal(i32 %0) {
%2 = add nsw i32 %0, -48
%3 = tail call i32 (i8*, i32, ...) @minibuf_write(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = tail call i32 (...) @getkey()
%5 = add i32 %4, -48
%6 = add i32 %4, -56
%7 = icmp ult i32 %6, -8
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = tail call i32 @insert_char_in_insert_mode(i32 %2)
br label %25
10: ; preds = %1
%11 = tail call i32 (i8*, i32, ...) @minibuf_write(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %5)
%12 = tail call i32 (...) @getkey()
%13 = add i32 %12, -56
%14 = icmp ult i32 %13, -8
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = shl nsw i32 %2, 3
%17 = add nuw nsw i32 %5, %16
%18 = tail call i32 @insert_char_in_insert_mode(i32 %17)
br label %25
19: ; preds = %10
%20 = shl i32 %0, 6
%21 = shl nuw nsw i32 %5, 3
%22 = add i32 %20, -3632
%23 = add i32 %22, %21
%24 = add i32 %23, %12
br label %25
25: ; preds = %19, %15, %8
%26 = phi i32 [ %24, %19 ], [ %12, %15 ], [ %4, %8 ]
%27 = tail call i32 @insert_char_in_insert_mode(i32 %26)
ret i32 1
}