#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 /*<<< orphan*/ insertchar(char);
int ch_cmd_i(int crpt, int cidx, int eidx, const char **s_r) {
  char c;
  const char *s;
  if (crpt < 0)
    crpt = -crpt;
  do {
    s = *s_r;
    while ((c = *s) != 0) {
      s++;
      if ((c == 4) || (c == 26))
        break;
      insertchar(c);
    }
  } while (--crpt > 0);
  *s_r = s;
  return (1);
}


x86 assembly (clang, -O0):
<ch_cmd_i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1137 <ch_cmd_i+0x27>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    113c <ch_cmd_i+0x2c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     1195 <ch_cmd_i+0x85>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x4,%eax
je     1182 <ch_cmd_i+0x72>
movsbl -0x19(%rbp),%eax
cmp    $0x1a,%eax
jne    1187 <ch_cmd_i+0x77>
jmp    1195 <ch_cmd_i+0x85>
movsbl -0x19(%rbp),%edi
call   1030 <insertchar@plt>
jmp    1147 <ch_cmd_i+0x37>
jmp    119a <ch_cmd_i+0x8a>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jg     113c <ch_cmd_i+0x2c>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ch_cmd_i>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %edi,%r15d
neg    %r15d
cmovs  %edi,%r15d
jmp    113d <ch_cmd_i+0x2d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x1(%r15),%eax
cmp    $0x1,%r15d
mov    %eax,%r15d
jle    1170 <ch_cmd_i+0x60>
mov    (%r14),%rbx
mov    (%rbx),%al
test   %al,%al
je     1130 <ch_cmd_i+0x20>
add    $0x1,%rbx
mov    %rbx,%rcx
nopl   (%rax)
mov    %rcx,%rbx
cmp    $0x4,%al
je     1130 <ch_cmd_i+0x20>
cmp    $0x1a,%al
je     1130 <ch_cmd_i+0x20>
movsbl %al,%edi
call   1030 <insertchar@plt>
movzbl (%rbx),%eax
lea    0x1(%rbx),%rcx
test   %al,%al
jne    1150 <ch_cmd_i+0x40>
jmp    1130 <ch_cmd_i+0x20>
mov    %rbx,(%r14)
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @ch_cmd_i(i32 %0, i32 %1, i32 %2, i8** %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8
%10 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = load i32, i32* %5
%15 = sub nsw i32 0, %14
store i32 %15, i32* %5
br label %16
16: ; preds = %13, %4
br label %17
17: ; preds = %40, %16
%18 = load i8**, i8*** %8
%19 = load i8*, i8** %18
store i8* %19, i8** %10
br label %20
20: ; preds = %36, %17
%21 = load i8*, i8** %10
%22 = load i8, i8* %21
store i8 %22, i8* %9
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %39
25: ; preds = %20
%26 = load i8*, i8** %10
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %10
%28 = load i8, i8* %9
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 4
br i1 %30, label %35, label %31
31: ; preds = %25
%32 = load i8, i8* %9
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 26
br i1 %34, label %35, label %36
35: ; preds = %31, %25
br label %39
36: ; preds = %31
%37 = load i8, i8* %9
%38 = call i32 @insertchar(i8 signext %37)
br label %20
39: ; preds = %35, %20
br label %40
40: ; preds = %39
%41 = load i32, i32* %5
%42 = add nsw i32 %41, -1
store i32 %42, i32* %5
%43 = icmp sgt i32 %42, 0
br i1 %43, label %17, label %44
44: ; preds = %40
%45 = load i8*, i8** %10
%46 = load i8**, i8*** %8
store i8* %45, i8** %46
ret i32 1
}

LLVM IR (-O2):
define i32 @ch_cmd_i(i32 %0, i32 %1, i32 %2, i8** nocapture %3) {
%5 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
br label %6
6: ; preds = %19, %4
%7 = phi i32 [ %5, %4 ], [ %21, %19 ]
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %6, %15
%12 = phi i8 [ %17, %15 ], [ %9, %6 ]
%13 = phi i8* [ %14, %15 ], [ %8, %6 ]
%14 = getelementptr inbounds i8, i8* %13, i64 1
switch i8 %12, label %15 [
i8 26, label %19
i8 4, label %19
]
15: ; preds = %11
%16 = tail call i32 @insertchar(i8 signext %12)
%17 = load i8, i8* %14
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %11
19: ; preds = %15, %11, %11, %6
%20 = phi i8* [ %8, %6 ], [ %14, %11 ], [ %14, %11 ], [ %14, %15 ]
%21 = add nsw i32 %7, -1
%22 = icmp sgt i32 %7, 1
br i1 %22, label %6, label %23
23: ; preds = %19
store i8* %20, i8** %3
ret i32 1
}