#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*/ on_error(char *);
size_t strlen(char *);
void save_array(char *arr, char *input_data) {
  int i;
  size_t size = strlen(input_data);
  if (size >= (50) || size == 0) {
    (void)on_error("Input data either too big or too small.");
  }
  for (i = 0; i < size; i++) {
    if (((int)(*(input_data + i)) == 92) && size > i + 1 &&
        (((int)(*(input_data + i + 1))) == 110)) {
      (void)on_error("Input data either too big or too small.");
    }
    *(arr + i) = *(input_data + i);
  }
  *(arr + size) = '\0';
}


x86 assembly (clang, -O0):
<save_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x32,-0x20(%rbp)
jae    1153 <save_array+0x33>
cmpq   $0x0,-0x20(%rbp)
jne    115f <save_array+0x3f>
lea    0xea6(%rip),%rdi
call   1040 <on_error@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11e5 <save_array+0xc5>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    11c1 <save_array+0xa1>
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jbe    11c1 <save_array+0xa1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl 0x1(%rax,%rcx,1),%eax
cmp    $0x6e,%eax
jne    11c1 <save_array+0xa1>
lea    0xe44(%rip),%rdi
call   1040 <on_error@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <save_array+0x46>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
add    $0xffffffffffffffce,%rax
cmp    $0xffffffffffffffce,%rax
ja     1157 <save_array+0x37>
lea    0xeb3(%rip),%rdi
call   1040 <on_error@plt>
test   %r15,%r15
je     11af <save_array+0x8f>
mov    %r15,%r13
neg    %r13
mov    $0x1,%ebp
lea    0xe97(%rip),%r12
jmp    118a <save_array+0x6a>
nopl   0x0(%rax,%rax,1)
mov    %al,-0x1(%r14,%rbp,1)
lea    0x1(,%rbp,1),%rax
add    %r13,%rax
add    $0x1,%rbp
cmp    $0x1,%rax
je     11af <save_array+0x8f>
movzbl -0x1(%rbx,%rbp,1),%eax
cmp    $0x5c,%al
jne    1170 <save_array+0x50>
cmp    %rbp,%r15
jbe    1170 <save_array+0x50>
mov    $0x5c,%al
cmpb   $0x6e,(%rbx,%rbp,1)
jne    1170 <save_array+0x50>
mov    %r12,%rdi
call   1040 <on_error@plt>
movzbl -0x1(%rbx,%rbp,1),%eax
jmp    1170 <save_array+0x50>
movb   $0x0,(%r14,%r15,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Input data either too big or too small.\00"
define void @save_array(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %6
%9 = load i64, i64* %6
%10 = icmp uge i64 %9, 50
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i64, i64* %6
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11, %2
%15 = call i32 @on_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
store i32 0, i32* %5
br label %17
17: ; preds = %57, %16
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = load i64, i64* %6
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %60
22: ; preds = %17
%23 = load i8*, i8** %4
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 92
br i1 %29, label %30, label %47
30: ; preds = %22
%31 = load i64, i64* %6
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = icmp ugt i64 %31, %34
br i1 %35, label %36, label %47
36: ; preds = %30
%37 = load i8*, i8** %4
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 110
br i1 %44, label %45, label %47
45: ; preds = %36
%46 = call i32 @on_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %47
47: ; preds = %45, %36, %30, %22
%48 = load i8*, i8** %4
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = load i8*, i8** %3
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
store i8 %52, i8* %56
br label %57
57: ; preds = %47
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
br label %17
60: ; preds = %17
%61 = load i8*, i8** %3
%62 = load i64, i64* %6
%63 = getelementptr inbounds i8, i8* %61, i64 %62
store i8 0, i8* %63
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"Input data either too big or too small.\00"
define void @save_array(i8* nocapture writeonly %0, i8* nocapture %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%4 = add i64 %3, -50
%5 = icmp ult i64 %4, -49
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @on_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %3, 0
br i1 %8, label %29, label %9
9: ; preds = %2, %6
br label %10
10: ; preds = %9, %25
%11 = phi i64 [ %15, %25 ], [ 0, %9 ]
%12 = getelementptr inbounds i8, i8* %1, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 92
%15 = add nuw i64 %11, 1
%16 = icmp ugt i64 %3, %15
%17 = select i1 %14, i1 %16, i1 false
br i1 %17, label %18, label %25
18: ; preds = %10
%19 = getelementptr inbounds i8, i8* %12, i64 1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 110
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = tail call i32 @on_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%24 = load i8, i8* %12
br label %25
25: ; preds = %22, %18, %10
%26 = phi i8 [ %24, %22 ], [ 92, %18 ], [ %13, %10 ]
%27 = getelementptr inbounds i8, i8* %0, i64 %11
store i8 %26, i8* %27
%28 = icmp eq i64 %15, %3
br i1 %28, label %29, label %10
29: ; preds = %25, %6
%30 = getelementptr inbounds i8, i8* %0, i64 %3
store i8 0, i8* %30
ret void
}