#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 *);
scalar_t__ checkIfNumber(char *);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ printInvalidCommandMessage();
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
void setBreakPoints(int *breakPoints, char **tokens) {
  int i = 0;
  if (strcmp(tokens[0], "-r") == 0) {
    tokens++;
    while (*tokens) {
      if (checkIfNumber(*tokens) == 0) {
        printInvalidCommandMessage();
        return;
      }
      if (breakPoints[i] == atoi(*tokens)) {
        breakPoints[i] = -1;
      };
      if (breakPoints[i] == -1) {
        printInvalidCommandMessage();
        printf("breakpoint does not exists");
        return;
      }
      i++;
      tokens++;
    }
  } else if (strcmp(tokens[0], "-a") == 0) {
    tokens++;
    int *temp = malloc(sizeof(int) * 100);
    while (*tokens) {
      if (checkIfNumber(*tokens) == 0) {
        printInvalidCommandMessage();
        return;
      }
      temp[i] = atoi(*tokens);
      i++;
      tokens++;
    }
    memcpy(breakPoints, temp, sizeof(int) * i);
    free(temp);
  }
}


x86 assembly (clang, -O0):
<setBreakPoints>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe5b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    126f <setBreakPoints+0xef>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     126a <setBreakPoints+0xea>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <checkIfNumber@plt>
cmp    $0x0,%rax
jne    11f0 <setBreakPoints+0x70>
mov    $0x0,%al
call   1040 <printInvalidCommandMessage@plt>
jmp    132e <setBreakPoints+0x1ae>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jne    1226 <setBreakPoints+0xa6>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
jne    1250 <setBreakPoints+0xd0>
mov    $0x0,%al
call   1040 <printInvalidCommandMessage@plt>
lea    0xdbd(%rip),%rdi
call   1050 <printf@plt>
jmp    132e <setBreakPoints+0x1ae>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11c0 <setBreakPoints+0x40>
jmp    132e <setBreakPoints+0x1ae>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xda1(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1329 <setBreakPoints+0x1a9>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    $0x190,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1309 <setBreakPoints+0x189>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <checkIfNumber@plt>
cmp    $0x0,%rax
jne    12d6 <setBreakPoints+0x156>
mov    $0x0,%al
call   1040 <printInvalidCommandMessage@plt>
jmp    132e <setBreakPoints+0x1ae>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    12a6 <setBreakPoints+0x126>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1080 <memcpy@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    132e <setBreakPoints+0x1ae>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setBreakPoints>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r14
mov    (%rsi),%rdi
lea    0xe68(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1223 <setBreakPoints+0xa3>
mov    (%r12),%rdi
lea    0xe6d(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    125f <setBreakPoints+0xdf>
mov    $0x190,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    0x8(%r12),%rdi
xor    %ebx,%ebx
test   %rdi,%rdi
je     1206 <setBreakPoints+0x86>
nopl   0x0(%rax,%rax,1)
call   1060 <checkIfNumber@plt>
test   %rax,%rax
je     1268 <setBreakPoints+0xe8>
mov    0x8(%r12,%rbx,2),%rdi
call   10a0 <atoi@plt>
mov    %eax,(%r15,%rbx,1)
mov    0x10(%r12,%rbx,2),%rdi
add    $0x4,%rbx
test   %rdi,%rdi
jne    11e0 <setBreakPoints+0x60>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1080 <memcpy@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
mov    0x8(%r12),%rdi
test   %rdi,%rdi
je     125f <setBreakPoints+0xdf>
xor    %ebx,%ebx
nop
call   1060 <checkIfNumber@plt>
test   %rax,%rax
je     1268 <setBreakPoints+0xe8>
mov    (%r14,%rbx,4),%ebp
mov    0x8(%r12,%rbx,8),%rdi
call   10a0 <atoi@plt>
cmp    %eax,%ebp
je     1277 <setBreakPoints+0xf7>
cmp    $0xffffffff,%ebp
je     1281 <setBreakPoints+0x101>
mov    0x10(%r12,%rbx,8),%rdi
add    $0x1,%rbx
test   %rdi,%rdi
jne    1230 <setBreakPoints+0xb0>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printInvalidCommandMessage@plt>
mov    %ebx,%eax
movl   $0xffffffff,(%r14,%rax,4)
ff
xor    %eax,%eax
call   1040 <printInvalidCommandMessage@plt>
lea    0xd74(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-r\00"
@.str.1 = [27 x i8] c"breakpoint does not exists\00"
@.str.2 = [3 x i8] c"-a\00"
define void @setBreakPoints(i32* %0, i8** %1) {
%3 = alloca i32*
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32*
store i32* %0, i32** %3
store i8** %1, i8*** %4
store i32 0, i32* %5
%7 = load i8**, i8*** %4
%8 = getelementptr inbounds i8*, i8** %7, i64 0
%9 = load i8*, i8** %8
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %57
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i32 1
store i8** %14, i8*** %4
br label %15
15: ; preds = %51, %12
%16 = load i8**, i8*** %4
%17 = load i8*, i8** %16
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %56
19: ; preds = %15
%20 = load i8**, i8*** %4
%21 = load i8*, i8** %20
%22 = call i64 @checkIfNumber(i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 (...) @printInvalidCommandMessage()
br label %101
26: ; preds = %19
%27 = load i32*, i32** %3
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = load i8**, i8*** %4
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
%35 = icmp eq i32 %31, %34
br i1 %35, label %36, label %41
36: ; preds = %26
%37 = load i32*, i32** %3
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
store i32 -1, i32* %40
br label %41
41: ; preds = %36, %26
%42 = load i32*, i32** %3
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %51
48: ; preds = %41
%49 = call i32 (...) @printInvalidCommandMessage()
%50 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %101
51: ; preds = %41
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
%54 = load i8**, i8*** %4
%55 = getelementptr inbounds i8*, i8** %54, i32 1
store i8** %55, i8*** %4
br label %15
56: ; preds = %15
br label %101
57: ; preds = %2
%58 = load i8**, i8*** %4
%59 = getelementptr inbounds i8*, i8** %58, i64 0
%60 = load i8*, i8** %59
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %100
63: ; preds = %57
%64 = load i8**, i8*** %4
%65 = getelementptr inbounds i8*, i8** %64, i32 1
store i8** %65, i8*** %4
%66 = call i32* @malloc(i32 400)
store i32* %66, i32** %6
br label %67
67: ; preds = %78, %63
%68 = load i8**, i8*** %4
%69 = load i8*, i8** %68
%70 = icmp ne i8* %69, null
br i1 %70, label %71, label %90
71: ; preds = %67
%72 = load i8**, i8*** %4
%73 = load i8*, i8** %72
%74 = call i64 @checkIfNumber(i8* %73)
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = call i32 (...) @printInvalidCommandMessage()
br label %101
78: ; preds = %71
%79 = load i8**, i8*** %4
%80 = load i8*, i8** %79
%81 = call i32 @atoi(i8* %80)
%82 = load i32*, i32** %6
%83 = load i32, i32* %5
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i32, i32* %82, i64 %84
store i32 %81, i32* %85
%86 = load i32, i32* %5
%87 = add nsw i32 %86, 1
store i32 %87, i32* %5
%88 = load i8**, i8*** %4
%89 = getelementptr inbounds i8*, i8** %88, i32 1
store i8** %89, i8*** %4
br label %67
90: ; preds = %67
%91 = load i32*, i32** %3
%92 = load i32*, i32** %6
%93 = load i32, i32* %5
%94 = sext i32 %93 to i64
%95 = mul i64 4, %94
%96 = trunc i64 %95 to i32
%97 = call i32 @memcpy(i32* %91, i32* %92, i32 %96)
%98 = load i32*, i32** %6
%99 = call i32 @free(i32* %98)
br label %100
100: ; preds = %90, %57
br label %101
101: ; preds = %24, %48, %76, %100, %56
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"-r\00"
@.str.1 = [27 x i8] c"breakpoint does not exists\00"
@.str.2 = [3 x i8] c"-a\00"
define void @setBreakPoints(i32* %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %37
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %69, label %10
10: ; preds = %6, %32
%11 = phi i64 [ %33, %32 ], [ 0, %6 ]
%12 = phi i8* [ %35, %32 ], [ %8, %6 ]
%13 = phi i8** [ %34, %32 ], [ %7, %6 ]
%14 = tail call i64 @checkIfNumber(i8* %12)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = tail call i32 (...) @printInvalidCommandMessage()
br label %69
18: ; preds = %10
%19 = getelementptr inbounds i32, i32* %0, i64 %11
%20 = load i32, i32* %19
%21 = load i8*, i8** %13
%22 = tail call i32 @atoi(i8* %21)
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = and i64 %11, 4294967295
%26 = getelementptr inbounds i32, i32* %0, i64 %25
store i32 -1, i32* %26
br label %29
27: ; preds = %18
%28 = icmp eq i32 %20, -1
br i1 %28, label %29, label %32
29: ; preds = %27, %24
%30 = tail call i32 (...) @printInvalidCommandMessage()
%31 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %69
32: ; preds = %27
%33 = add nuw i64 %11, 1
%34 = getelementptr inbounds i8*, i8** %13, i64 1
%35 = load i8*, i8** %34
%36 = icmp eq i8* %35, null
br i1 %36, label %69, label %10
37: ; preds = %2
%38 = load i8*, i8** %1
%39 = tail call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %69
41: ; preds = %37
%42 = tail call i32* @malloc(i32 400)
%43 = getelementptr inbounds i8*, i8** %1, i64 1
%44 = load i8*, i8** %43
%45 = icmp eq i8* %44, null
br i1 %45, label %65, label %46
46: ; preds = %41, %54
%47 = phi i64 [ %58, %54 ], [ 0, %41 ]
%48 = phi i8* [ %60, %54 ], [ %44, %41 ]
%49 = phi i8** [ %59, %54 ], [ %43, %41 ]
%50 = tail call i64 @checkIfNumber(i8* %48)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %46
%53 = tail call i32 (...) @printInvalidCommandMessage()
br label %69
54: ; preds = %46
%55 = load i8*, i8** %49
%56 = tail call i32 @atoi(i8* %55)
%57 = getelementptr inbounds i32, i32* %42, i64 %47
store i32 %56, i32* %57
%58 = add nuw i64 %47, 1
%59 = getelementptr inbounds i8*, i8** %49, i64 1
%60 = load i8*, i8** %59
%61 = icmp eq i8* %60, null
br i1 %61, label %62, label %46
62: ; preds = %54
%63 = trunc i64 %58 to i32
%64 = shl i32 %63, 2
br label %65
65: ; preds = %62, %41
%66 = phi i32 [ 0, %41 ], [ %64, %62 ]
%67 = tail call i32 @memcpy(i32* %0, i32* %42, i32 %66)
%68 = tail call i32 @free(i32* %42)
br label %69
69: ; preds = %32, %6, %52, %65, %37, %29, %16
ret void
}