#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 num_shift(char *input, int start_position, int end_position) {
  char num[1000];
  int cpy = start_position;
  for (int c = 0; c < end_position - cpy; c++) {
    num[c] = input[start_position];
    start_position++;
  }
  num[end_position - cpy] = '\0';
  return atoi(num);
}


x86 assembly (clang, -O0):
<num_shift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x404(%rbp)
movl   $0x0,-0x408(%rbp)
mov    -0x408(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0x404(%rbp),%ecx
cmp    %ecx,%eax
jge    1185 <num_shift+0x75>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x408(%rbp),%rax
mov    %cl,-0x400(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x408(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408(%rbp)
jmp    1138 <num_shift+0x28>
mov    -0x10(%rbp),%eax
sub    -0x404(%rbp),%eax
cltq
movb   $0x0,-0x400(%rbp,%rax,1)
lea    -0x400(%rbp),%rdi
call   1030 <atoi@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_shift>:
push   %rbx
sub    $0x3f0,%rsp
mov    %esi,%eax
mov    %edx,%ebx
sub    %esi,%ebx
jle    114c <num_shift+0x2c>
mov    %rdi,%rsi
movslq %eax,%rcx
add    %rcx,%rsi
not    %eax
add    %edx,%eax
add    $0x1,%rax
mov    %rsp,%rdi
mov    %rax,%rdx
call   1030 <memcpy@plt>
movslq %ebx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1040 <atoi@plt>
add    $0x3f0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @num_shift(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1000 x i8]
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %5
store i32 %10, i32* %8
store i32 0, i32* %9
br label %11
11: ; preds = %28, %3
%12 = load i32, i32* %9
%13 = load i32, i32* %6
%14 = load i32, i32* %8
%15 = sub nsw i32 %13, %14
%16 = icmp slt i32 %12, %15
br i1 %16, label %17, label %31
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %24
store i8 %22, i8* %25
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %28
28: ; preds = %17
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
store i32 %30, i32* %9
br label %11
31: ; preds = %11
%32 = load i32, i32* %6
%33 = load i32, i32* %8
%34 = sub nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %35
store i8 0, i8* %36
%37 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%38 = call i32 @atoi(i8* %37)
ret i32 %38
}

LLVM IR (-O2):
define i32 @num_shift(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%6 = sub nsw i32 %2, %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %3
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%10 = sext i32 %1 to i64
%11 = getelementptr i8, i8* %0, i64 %10
%12 = xor i32 %1, -1
%13 = add i32 %12, %2
%14 = zext i32 %13 to i64
%15 = add nuw nsw i64 %14, 1
br label %16
16: ; preds = %8, %3
%17 = sext i32 %6 to i64
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i32 @atoi(i8* %5)
ret i32 %19
}